JetBrains / teamcity-docker-agent

TeamCity agent docker image sources
https://hub.docker.com/r/jetbrains/teamcity-agent/
Apache License 2.0
77 stars 64 forks source link

Agent on Docker for Windows? #2

Closed angularsen closed 7 years ago

angularsen commented 7 years ago

Hi, is there any way to run a similar TeamCity build agent on a Windows host using Docker? Or any plans for this?

I haven't found a lot of resources on running Windows based build-agents on docker, let alone TeamCity agents.

Some sources for msbuild on Windows: http://blog.alexellis.io/3-steps-to-msbuild-with-docker/ https://github.com/Microsoft/dotnet-framework-docker/issues/2

yhrunyk commented 7 years ago

+1 I would like to use Docker container based on Windows as a TeamCity build agent.

Vertygo commented 7 years ago

+1 for the windows agent.

repi commented 7 years ago

+1 here also for Windows agent, would be great

daghb commented 7 years ago

+1 from me, too. I've tried to set up build agents on nano server, but have problems with socket connections. Follow the forum thread on https://teamcity-support.jetbrains.com/hc/en-us/community/posts/115000548404-Problems-running-agent-on-Nano-Server. If I succeed, I will post a recipe.

daghb commented 7 years ago

A first shot for a Build Agent on either Nano Server or Windows Server Core is availale at https://github.com/daghb/tcagent-nanoserver

burnasheva commented 7 years ago

We're planning to release the official TeamCity Windows Docker image soon. Please, watch\vote for the feature in our YouTrack - https://youtrack.jetbrains.com/issue/TW-47392.

dtretyakov commented 7 years ago

Now we have experimental windows docker images for latest teamcity eap build: https://hub.docker.com/r/jetbrains/teamcity-agent/

Feel free to share feedback.

ghost commented 7 years ago

I have been doing some research on Teamcity and Docker and came across multiple blog posts, "wild Dockerfiles" and the likes to be able to use MSBuild and the .NET framework in Docker. Since I saw this issue as well I'd like to ask a question in order to see whether I understand the images correct.

I am working on a solution that consists of multiple C# projects (.NET 4.7), native C++ applications and static libraries targeting 64bit and corresponding native test projects relying on the internal Microsoft::VisualStudio::CppUnitTestFramework. As far as I have understood it should be possible to have a Teamcity agent pulling the sources from GitHub and execute MSBuild for various configurations and projects as well as running the unit tests using vstest.console.exe.

Are the Docker images with Windows agents able to perform that as well or do I need to build on top of them by finding out how to install the toolchain from .NET to MSVC and VSTest manually?

dtretyakov commented 7 years ago

@NearAutomata, due to licensing policy we could not provide agent image with MSBuild and tools pre-installed, but you could create derived image from our windowsservercore image.

In this case your Dockerfile will look like that:

FROM jetbrains/teamcity-agent:latest-windowsservercore

# ... steps to install build tools

Sample steps to install required build tools you could find in the following Dockerfile.

Other examples could be found in the following repository: https://github.com/StefanScherer/dockerfiles-windows

Then you could push it to some docker registry and use it to start TeamCity agents.

ghost commented 7 years ago

Thanks for the followup. I just noticed I will be running into problems since working with MSBuild requires a Windows agent Docker image that cannot be executed on a Linux machine since it requires Hyper-V and thus a Windows host. I'll need to reconsider how I can run a build agent otherwise but it seems I need a Windows machine for that nonetheless.

daghb commented 7 years ago

@NearAutomata, you may find a few hints on installing MSBuild onto a windowsservercore or nanoserver image on https://github.com/daghb/tcagent-nanoserver. The process is not entirely self explaining, but you may shave off some study time by looking into this Dockerfile (lines 28-34) and installMSBuildTools.ps1.

ghost commented 7 years ago

Is it actually reasonable, to not consider building a MSBuild docker agent right away, to install local agents on development machines themselves and not other servers since I only have access to Linux based servers?

daghb commented 7 years ago

Not sure if I understand, @NearAutomata - but you can use exactly the same approach building agent images running on local Windows based developer machines. However, if you are building .NET Framework based applications, your only option server side is basing your image on windowsservercore, not nanoserver.

ghost commented 7 years ago

My question is, whether it's reasonable to install build agents (either natively or via Docker) on local machines I am developing on rather than in the cloud as I initially expected.

daghb commented 7 years ago

It is reasonable to install them locally if you are running Linux only in the cloud with MSBuild based projects. I cannot see any way around that if you may only use one provider with Linux only servers. On our site, we are on AmazonWS with a Windows 2016 Server host running Windows Server Core containers.

dtretyakov commented 6 years ago

Since TeamCity 2017.2.2 agent image includes MS Build Tools and all images support windows 1709 docker containers.

bzier commented 6 years ago

@dtretyakov Back in October, you had mentioned that there was a licensing policy issue with including MS Build Tools. I'm just curious if that has since changed. Did MS change their licensing policy for the build tools with respect to Docker images? Did you guys work something out with them?

dtretyakov commented 6 years ago

@bzier, yes, now MSFT allows to install MS Build in containers and even provides docker image with pre-installaled build tools on top of which we have rebased our jetbrains/teamcity-agent -windowsservercore images.

bzier commented 6 years ago

@dtretyakov Awesome, that means less maintenance for all of us. I'll rebase our image on your latest, which will allow me to clean up the MS Build install steps in our Dockerfile. Thanks for the update and the information.