Create a Windows Server 2022 instance on OVH (Docker is not compatible with Windows Server 2016).
-
Finish instance configuration directly through the "Console VNC" on the OVH instance page (beware of the keyboard language when defining your account password!).
-
To allow connection with
rdesktop
, disable the "Allow connections only from computers running Remote Desktop with Network Level Authentification" setting in "Control Panel" -> "System and Security" -> "Allow remote access". There should be a more secure way to handle this... -
Set the correct time zone.
Now, lets install docker. Launch Windows PowerShell as Administrator and run the following commands:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
.\install-docker-ce.ps1
The system will reboot!
Follow instructions from Install Build Tools into a container to generate the buildtools
docker image. Use the following Dockerfile:
# escape=`
# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
RUN `
# Download the Build Tools bootstrapper.
curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
`
# Install Build Tools.
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Workload.MSBuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--includeRecommended `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
`
# Cleanup
&& del /q vs_buildtools.exe
# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
--includeRecommended
is required to get the cl
command, but add a lot of extra stuff).
Install Gitlab runner:
mkdir C:\GitLab-Runner
cd C:\GitLab-Runner
Invoke-WebRequest -UseBasicParsing "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe" -o gitlab-runner-windows-amd64.exe
.\gitlab-runner-windows-amd64.exe install
.\gitlab-runner-windows-amd64.exe start
Register the runner using the informations provided in the "Runners" section in Gitlab project "Settings" -> "CI/CD":
.\gitlab-runner-windows-amd64.exe register
Fill in windows
for the tag, docker-windows
for the executor and just copy-past the example for the default Docker image.
Edit the C:\GitLab-Runner\config.toml
to change the shell from pwsh
to powershell
. You can also increase the number of concurrent
jobs (first line) to match at least the number of vcores. You may also need to add pull_policy = ["if-not-present", "always"]
in the [runners.docker]
section.
Eventually, the C:\GitLab-Runner\config.toml
shoud look like:
concurrent = 2
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "..."
url = "https://gitlab.eclipse.org/"
id = 884
token = "..."
token_obtained_at = 2023-08-28T14:51:47Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker-windows"
shell = "powershell"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "mcr.microsoft.com/windows/servercore:1809"
pull_policy = ["if-not-present", "always"]
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["c:\\cache"]
shm_size = 0
Troubleshooting
-
You get the following error:
ERROR: Job failed (system failure): Error response from daemon: container ... encountered an error during hcs::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) (exec.go:78:5s)
The shell command is probably not right. Did you change
pwsh
topowershell
inC:\GitLab-Runner\config.toml
? Do you use another docker image? Did you check that the shell is available on the image? (Powershell is not available innanoserver
images). -
You get the following error:
ERROR: Job failed: failed to pull image "buildtools" with specified policies [always]: Error response from daemon: pull access denied for buildtools, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:237:1s)
Did you add
pull_policy = ["if-not-present", "always"]
in the[runners.docker]
section of theC:\GitLab-Runner\config.toml
file?
Debug inside Docker
It may be necessary to run commands inside the Docker to understand why the CI fails. In order to do so, connect to the server and run docker run -v C:/:C:/C -it buildtools
. With this command, you will have access to the C:\
drive of the server inside the C:\C\
folder in the container. This way, you may download for example build artifacts in the server and access them inside the Docker to re-run the failing commands.
You will need to first execute in the docker the commands in the before_script
section from the corresponding YML CI file, in order to setup the environment requirements.
If you get Exit code 0xc0000135
in all test cases, check if there is some DLL missing. Use this kind of command in the Docker (it requires to have Git installed):
& 'C:\Program Files\Git\bin\bash.exe' -c 'C:/builds/eclipse/aidge/aidge_core/build_cpp/unit_tests/Debug/tests_aidge_core.exe'