Last active
December 3, 2019 00:58
-
-
Save zheharry/3605050316441b3ae67e9f2f87f49632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# escape=` | |
# ---- Base Node ---- | |
### | |
# reference: | |
# - https://devblogs.microsoft.com/cppblog/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ | |
# - https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2017 | |
# - https://docs.microsoft.com/en-us/visualstudio/install/advanced-build-tools-container?view=vs-2017 | |
# - https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2017 | |
# - https://docs.microsoft.com/en-us/visualstudio/install/create-a-network-installation-of-visual-studio?view=vs-2017 | |
# - https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility | |
# - https://software.intel.com/en-us/articles/build-dldt-app-inside-windows-docker-container | |
# - https://forums.docker.com/t/connect-to-the-internet-from-a-windows-container-behind-a-http-proxy/41307/8 | |
# - https://stackoverflow.com/questions/43933425/best-way-to-extract-list-of-visual-studio-2017-installed-components | |
# | |
# Multistages: docker build -m 4GB -t vs15 --target=base . | |
# | |
# there is problem that docker images cannot connect external network via WiFi. use wired network. | |
# but it should work in the corp network with proper proxy settings. | |
# | |
### download vs2017 offline packages | |
# wget https://aka.ms/vs/15/release/vs_buildtools.exe | |
# vs_BuildTools.exe --layout vs2017 --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.140 --add Microsoft.VisualStudio.Component.Windows10SDK.17763 --add Microsoft.VisualStudio.Component.Windows10SDK.17134 --includeRecommended | |
# | |
## | |
FROM mcr.microsoft.com/windows:1809-amd64 AS base | |
#FROM mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-1803 AS base | |
RUN powershell Set-ExecutionPolicy Bypass | |
SHELL ["cmd", "/S", "/C"] | |
# Install Chocolatey | |
RUN powershell -Command ` | |
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
RUN choco feature disable --name showDownloadProgress | |
# gnuwin32 (ls, rm, sort, and friends) | |
RUN choco install -y gnuwin32-coreutils.install | |
# Add gnuwin32 to PATH | |
RUN powershell $newpath = $env:path + "';C:\Program Files (x86)\GnuWin32\bin;'" ;` | |
Set-ItemProperty -Path ` | |
'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session ` | |
Manager\Environment' -Name PATH -Value $newpath | |
# other tools by choco | |
RUN choco install -y diffutils 7zip.install zip unzip which sed wget curl git.install tortoisesvn python2 openjdk nasm jq jfrog-cli vim | |
RUN choco install -y python --version 3.6.6 | |
# pipeline-trigger for gitlab | |
RUN git clone https://gitlab.com/finestructure/pipeline-trigger.git | |
RUN pip3 install -r pipeline-trigger\requirements.txt | |
RUN cp pipeline-trigger\trigger.py C:\Python36\Scripts\ | |
# other tools by pip | |
RUN pip3 install anybadge pyyaml enum34 | |
RUN refreshenv | |
# vs2017 | |
FROM base AS vs2017 | |
WORKDIR C:\temp | |
COPY vs2017 C:\temp\ | |
RUN vs_buildtools.exe --quiet --wait --norestart ` | |
--add Microsoft.VisualStudio.Workload.VCTools ` | |
--add Microsoft.VisualStudio.Component.VC.140 ` | |
--add Microsoft.VisualStudio.Component.Windows10SDK.17763 ` | |
--add Microsoft.VisualStudio.Component.Windows10SDK.17134 ` | |
--includeRecommended ` | |
|| IF "%ERRORLEVEL%"=="3010" EXIT 0 | |
RUN powershell [System.Environment]::SetEnvironmentVariable('VS120COMNTOOLS', 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\', 'Machine') | |
RUN powershell [System.Environment]::SetEnvironmentVariable('VS140COMNTOOLS', 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\', 'Machine') | |
RUN refreshenv | |
# Clean up | |
RUN rmdir /q /s C:\temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://notes.alelec.net/blog/post/andrew@alelec.net/Windows-Docker-Gitlab-CI-Runner-2 | |
# | |
# Get registration token from https://gitlab.com/<project settings>/runners | |
# | |
# multiple roles are in single Windows host. | |
# 1. docker images update | |
# 2. docker run | |
# | |
# 0. prepare | |
# official now has windows docker support | |
$url = "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe" | |
Start-BitsTransfer -Source $url -Destination c:\windows\system32\gitlab-runner.exe | |
mkdir c:\gitlab | |
# 1. docker images update | |
$env:REGISTRATION_TOKEN="" | |
$env:CI_SERVER_URL="https://gitlab.com" | |
$env:RUNNER_NAME="docker-build" | |
$env:CONFIG_FILE="C:\gitlab\config.toml" | |
$env:REGISTER_LOCKED="false" | |
$env:RUNNER_EXECUTOR="shell" | |
$env:RUNNER_TAG_LIST="windows" | |
$env:RUNNER_SHELL="powershell" | |
$env:RUNNER_BUILDS_DIR="c:\gitlab\builds" | |
#$env:RUNNER_CACHE_DIR="c:\gitlab\cache" | |
$env:REGISTER_RUN_UNTAGGED="true" | |
gitlab-runner register --non-interactive | |
# 2. docker run | |
$env:REGISTRATION_TOKEN="" | |
$env:RUNNER_NAME="docker-host1" | |
$env:RUNNER_EXECUTOR="docker-windows" | |
$env:RUNNER_TAG_LIST="docker,windows,1809" | |
$env:DOCKER_MEMORY="4g" | |
$env:DOCKER_TLS_VERIFY="false" | |
#$env:DOCKER_PRIVILEGED="true" | |
$env:DOCKER_IMAGE="vs2017" | |
#$env:DOCKER_VOLUMES="\\.\pipe\docker_engine" | |
#$env:DOCKER_CACHE_DIR="c:\gitlab\cache" | |
$env:DOCKER_PULL_POLICY="if-not-present" | |
#$env:DOCKER_HELPER_IMAGE="registry.gitlab.com/andrewleech/gitlab-runner/gitlab-runner-helper:win-x86_64-1809-latest" | |
# TODO Switch back to npipe once it works in gitlab (see note above) | |
#$ip=(Get-NetAdapter -Name "*Internal vSwitch*" | Get-NetIPAddress -AddressFamily IPv4).IPAddress | |
#$env:DOCKER_HOST="tcp://${ip}:2375" | |
#$env:RUNNER_ENV="DOCKER_HOST=tcp://${ip}:2375" | |
gitlab-runner register --non-interactive | |
# You may want to increase the number of concurrent jobs, if so: | |
#notepad c:\gitlab\config.toml | |
# Then add/edit the following line to the top of the file (withouth the #) | |
# concurrent = 4 | |
# Save and close | |
# Install the service | |
#gitlab-runner install -user .\LocalSystem --working-directory="C:\gitlab" --config=$env:CONFIG_FILE | |
#cmd /c "sc.exe config gitlab-runner start= delayed-auto" | |
# edit config.toml, add session_server listen address, then open it in firewall: | |
#New-NetFirewallRule -DisplayName "Allow inbound TCP port 8093 (gitlab runner session server)" -Direction inbound -LocalPort 8093 -Protocol TCP -Action Allow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment