Refactor Windows Gitea runner Dockerfiles and update CI configuration

This commit is contained in:
2026-07-03 23:56:19 +02:00
parent 9a9b36cac6
commit dfeaea3283
7 changed files with 80 additions and 9 deletions
@@ -2,7 +2,7 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# Base image for Windows Gitea runners with Git for Windows tools and gitea runner.
# Base image for Windows Gitea runners with Git tools and gitea runner.
ARG ACT_RUNNER_VERSION=2.0.0
RUN Set-StrictMode -Version Latest; \
$ErrorActionPreference = 'Stop'; \
@@ -5,5 +5,4 @@ SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# C/C++ profile with cmake and ninja.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'; \
choco install ninja; \
choco clean --yes
choco install ninja
@@ -4,5 +4,4 @@ SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# .NET profile for building and testing managed workloads.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install dotnet-sdk --version=8.0.204; \
choco clean --yes
choco install dotnet-sdk --version=8.0.204
@@ -4,5 +4,4 @@ SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# Go profile for Windows builds.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install golang --version=1.22.4; \
choco clean --yes
choco install golang --version=1.22.4
@@ -0,0 +1,9 @@
FROM local/gitea-windows-runner:windows-msys
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# Dedicated profile for image builds. Docker daemon access is provided at runtime
# through the host named pipe mount configured in host_vars.
RUN Set-StrictMode -Version Latest; \
$ErrorActionPreference = 'Stop'; \
choco install docker-cli --yes --no-progress --limit-output
@@ -181,3 +181,42 @@ windows_gitea_runner_windows_runners:
config_file: "D:\\GiteaRunner\\windows-msys\\config.yaml"
data_dir: "D:\\GiteaRunner\\windows-msys\\data"
log_dir: "D:\\Logs\\GiteaRunner\\windows-msys"
- profile: windows-cpp
name: "gitea-runner-windows-cpp"
container_name: "gitea-runner-windows-cpp"
image: "local/gitea-windows-runner:windows-cpp"
dockerfile_src: "Dockerfile.windows-cpp"
labels: "windows:host,windows-cpp"
config_file: "D:\\GiteaRunner\\windows-cpp\\config.yaml"
data_dir: "D:\\GiteaRunner\\windows-cpp\\data"
log_dir: "D:\\Logs\\GiteaRunner\\windows-cpp"
- profile: windows-go
name: "gitea-runner-windows-go"
container_name: "gitea-runner-windows-go"
image: "local/gitea-windows-runner:windows-go"
dockerfile_src: "Dockerfile.windows-go"
labels: "windows:host,windows-go"
config_file: "D:\\GiteaRunner\\windows-go\\config.yaml"
data_dir: "D:\\GiteaRunner\\windows-go\\data"
log_dir: "D:\\Logs\\GiteaRunner\\windows-go"
- profile: windows-dotnet
name: "gitea-runner-windows-dotnet"
container_name: "gitea-runner-windows-dotnet"
image: "local/gitea-windows-runner:windows-dotnet"
dockerfile_src: "Dockerfile.windows-dotnet"
labels: "windows:host,windows-dotnet"
config_file: "D:\\GiteaRunner\\windows-dotnet\\config.yaml"
data_dir: "D:\\GiteaRunner\\windows-dotnet\\data"
log_dir: "D:\\Logs\\GiteaRunner\\windows-dotnet"
- profile: windows-image-build
name: "gitea-runner-windows-image-build"
container_name: "gitea-runner-windows-image-build"
image: "local/gitea-windows-runner:windows-image-build"
dockerfile_src: "Dockerfile.windows-image-build"
labels: "windows:host,windows-image-build"
config_file: "D:\\GiteaRunner\\windows-image-build\\config.yaml"
data_dir: "D:\\GiteaRunner\\windows-image-build\\data"
log_dir: "D:\\Logs\\GiteaRunner\\windows-image-build"
run_args:
- "-v"
- "\\\\.\\pipe\\docker_engine:\\\\.\\pipe\\docker_engine"
@@ -311,6 +311,19 @@
$ErrorActionPreference = "Stop"
$docker = "{{ windows_gitea_runner_windows_runtime_bin }}"
$name = "{{ __windows_gitea_runner_windows_container_name }}"
$runArgsJson = '{{ __windows_gitea_runner_windows_run_args | to_json }}'
$runArgs = @()
if (-not [string]::IsNullOrWhiteSpace($runArgsJson)) {
$parsedRunArgs = $runArgsJson | ConvertFrom-Json
if ($null -ne $parsedRunArgs) {
if ($parsedRunArgs -is [System.Array]) {
$runArgs = @($parsedRunArgs)
}
else {
$runArgs = @($parsedRunArgs)
}
}
}
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
}
@@ -331,7 +344,7 @@
$env:GITEA_RUNNER_LABELS = {{ __windows_gitea_runner_windows_labels | to_json }}
& $docker run -d --name $name --restart "{{ windows_gitea_runner_windows_restart_policy }}" `
@({{ __windows_gitea_runner_windows_run_args | map('to_json') | join(', ') }}) `
@($runArgs) `
--label "{{
windows_gitea_runner_windows_container_hash_label
}}={{ __windows_gitea_runner_windows_desired_container_hash }}" `
@@ -364,6 +377,19 @@
$image = "{{ __windows_gitea_runner_windows_image }}"
$hostData = "{{ __windows_gitea_runner_windows_data_dir }}"
$hostConfig = "{{ __windows_gitea_runner_windows_runtime_config_file }}"
$runArgsJson = '{{ __windows_gitea_runner_windows_run_args | to_json }}'
$runArgs = @()
if (-not [string]::IsNullOrWhiteSpace($runArgsJson)) {
$parsedRunArgs = $runArgsJson | ConvertFrom-Json
if ($null -ne $parsedRunArgs) {
if ($parsedRunArgs -is [System.Array]) {
$runArgs = @($parsedRunArgs)
}
else {
$runArgs = @($parsedRunArgs)
}
}
}
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
@@ -399,7 +425,7 @@
$diagName = "$name-diag-$([guid]::NewGuid().ToString('N').Substring(0, 8))"
$diagRun = & $docker run --rm --name $diagName `
--entrypoint "C:\Windows\System32\cmd.exe" `
@({{ __windows_gitea_runner_windows_run_args | map('to_json') | join(', ') }}) `
@($runArgs) `
--mount "type=bind,source={{ __windows_gitea_runner_windows_data_dir }},target=C:\runner-data" `
-e "CONFIG_FILE=C:\runner-data\config.yaml" `
-e "GITEA_INSTANCE_URL={{ windows_gitea_runner_windows_instance_url }}" `