-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run Builds in Docker Container Locally #328
Run Builds in Docker Container Locally #328
Conversation
$PSVersionTable.Platform on my machine (Windows 10, PowerShell 5.1) returns nothing because it was not supported then. and causes the following errors: WARNING: Platform is not Win32NT based but ''. Windows container do not work on linux based systems. Ignoring windows containers...
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/json?filters=%7B%22reference%22%3A%7B%22vsteam%2Flinux%22%3Atrue%7D%7D: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
unable to prepare context: unable to evaluate symlinks in Dockerfile path: CreateFile R:\repos\vsteam\build\docker: The system cannot find the file specified.
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/json?all=1&filters=%7B%22name%22%3A%7B%22vsteam_linux_ps7_tests%22%3Atrue%7D%7D: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/json?filters=%7B%22name%22%3A%7B%22vsteam_linux_ps7_tests%22%3Atrue%7D%7D: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
C:\Program Files\Docker\Docker\resources\bin\docker.exe: error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/create?name=vsteam_linux_ps7_tests: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
See 'C:\Program Files\Docker\Docker\resources\bin\docker.exe run --help'.
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/vsteam_linux_ps7_tests/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Exception calling "Substring" with "2" argument(s): "StartIndex cannot be less than zero.
Parameter name: startIndex"
At R:\repos\vsteam\tools\docker\Run-ContainerTests.ps1:157 char:10
+ $versiontable = $output.Substring($outputFirst, $ouputLast+1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentOutOfRangeException
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/vsteam_linux_ps7_tests/wait?condition=: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running. Get-OperatingSystem works everywhere and is a better way to check OS. I changed it locally but still getting different errors. I will keep playing with it. |
I tried to push my change but got an error
|
tools/docker/Run-ContainerTests.ps1
Outdated
$scriptPath = $PSScriptRoot | ||
$rootDir = (Resolve-Path -Path "$scriptPath\..\..\").ToString().trim('\') | ||
$containerFolder = "c:/vsteam" | ||
$containerFilePath = "$rootDir/build/docker" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be "$rootDir/Tools/docker" not build/docker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fixed the dir. I moved it before.
I am getting close. I have the Linux version working on Windows. But the Windows images are failing to build. |
tools/docker/Run-ContainerTests.ps1
Outdated
$output = (docker exec -it $Container $Shell -c '$PSVersionTable | ConvertTo-Json -Compress;') -join '' | ||
$outputFirst = $output.IndexOf('{') | ||
$ouputLast = $output.LastIndexOf('}') | ||
$versiontable = $output.Substring($outputFirst, $ouputLast+1-$outputFirst) | ConvertFrom-Json -Depth 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConvertFrom-Json does not have a -Depth. Only ConvertTo-Json has that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it. Didnt get an error before and VSCode seems to suggest that as a parameter.
I can't seen to get my Windows containers access to the internet so all the module installs are failing. Did you have to do anything special to get your Window containers to see the internet? |
I got internet in my Windows VMS but following this docker/for-win#2760 |
Now that I have it working this is pretty cool! I wonder if we should just add a -UseDocker switch to the build-module.ps1 and roll this into that script. |
It is strange. I don't see the PR checkbox to give you write access. I just gave you maintainer access to my fork repo! I hope you can commit now to it. |
About integrating it into the build script. I was thinking to refactor some of the build files we use into an extra folder! I would suggest something like "tools/XYZ". There we put an extra structure for everything. |
We can discuss during our meeting. I will try to have it this week. |
Testing on my Linux machine now. Looks to be working. I will move to Mac to test next. |
Still having issues pushing my changes to this PR. So I will create a new one with my changes. I have tested it on all three platforms. This is a really cool idea! Thanks. |
Merged in a different PR. |
I have been playing around to run the builds with Pester 5 in container locally for the following configurations
It uses docker and I have created 2 images with our modules preinstalled. There were some problems to run PS5.1, but I managed to have this run. I think it still needs some minor changes, but 95% I feel it is good enough to have it for developers to use.
They all seem to work. IN between build the daemon switches from windows to linux since linux based containers cannot run with windows containers in parallel.
Tell me what you think and if it works for you @DarqueWarrior