From 01ecb284d31bd8253dcf37a8a353bc5f7ecbb7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kry=C5=A1tof=20Wold=C5=99ich?= Date: Tue, 1 Jun 2021 15:20:30 +0200 Subject: [PATCH] Add back Windows variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://download.docker.com/win/static/stable/x86_64/ 🎉 Co-authored-by: Tianon Gravi --- .../windows/windowsservercore-1809/Dockerfile | 40 +++++++++++++++++++ ... => Dockerfile-windows-servercore.template | 11 +++-- Dockerfile.template | 2 +- apply-templates.sh | 23 +++++++++-- generate-stackbrew-library.sh | 28 +++++++++++-- versions.json | 6 ++- versions.sh | 17 +++++++- 7 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 20.10/windows/windowsservercore-1809/Dockerfile rename Dockerfile-windows-windowsservercore.template => Dockerfile-windows-servercore.template (78%) diff --git a/20.10/windows/windowsservercore-1809/Dockerfile b/20.10/windows/windowsservercore-1809/Dockerfile new file mode 100644 index 000000000..e7489b8fe --- /dev/null +++ b/20.10/windows/windowsservercore-1809/Dockerfile @@ -0,0 +1,40 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM mcr.microsoft.com/windows/servercore:1809 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# PATH isn't actually set in the Docker image, so we have to set it from within the container +RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ + Write-Host ('Updating PATH: {0}' -f $newPath); \ + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); +# doing this first to share cache across versions more aggressively + +ENV DOCKER_VERSION 20.10.6 +ENV DOCKER_URL https://download.docker.com/win/static/stable/x86_64/docker-20.10.6.zip +# TODO ENV DOCKER_SHA256 +# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! +# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) + +RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ + \ + Write-Host 'Expanding ...'; \ + Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ +# (this archive has a "docker/..." directory in it already) + \ + Write-Host 'Removing ...'; \ + Remove-Item @( \ + 'docker.zip', \ + ('{0}\docker\dockerd.exe' -f $env:ProgramFiles) \ + ) -Force; \ + \ + Write-Host 'Verifying install ("docker --version") ...'; \ + docker --version; \ + \ + Write-Host 'Complete.'; diff --git a/Dockerfile-windows-windowsservercore.template b/Dockerfile-windows-servercore.template similarity index 78% rename from Dockerfile-windows-windowsservercore.template rename to Dockerfile-windows-servercore.template index 89ad458cb..8b1f2628c 100644 --- a/Dockerfile-windows-windowsservercore.template +++ b/Dockerfile-windows-servercore.template @@ -1,4 +1,4 @@ -FROM microsoft/windowsservercore:%%TAG%% +FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }} # $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] @@ -9,15 +9,14 @@ RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); # doing this first to share cache across versions more aggressively -ENV DOCKER_CHANNEL %%DOCKER-CHANNEL%% -ENV DOCKER_VERSION %%DOCKER-VERSION%% +ENV DOCKER_VERSION {{ .version }} +ENV DOCKER_URL {{ .arches["windows-amd64"].dockerUrl }} # TODO ENV DOCKER_SHA256 # https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! # (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) -RUN $url = ('https://download.docker.com/win/static/{0}/x86_64/docker-{1}.zip' -f $env:DOCKER_CHANNEL, $env:DOCKER_VERSION); \ - Write-Host ('Downloading {0} ...' -f $url); \ - Invoke-WebRequest -Uri $url -OutFile 'docker.zip'; \ +RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ \ Write-Host 'Expanding ...'; \ Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ diff --git a/Dockerfile.template b/Dockerfile.template index a51f771a5..3b7dac846 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -23,7 +23,7 @@ RUN set -eux; \ {{ [ .arches | to_entries[] - | select(.value.dockerUrl) + | select(.value.dockerUrl and (.key | startswith("windows-") | not)) | .key as $bashbrewArch | ( { diff --git a/apply-templates.sh b/apply-templates.sh index 65a4cbbf9..ca7de349e 100755 --- a/apply-templates.sh +++ b/apply-templates.sh @@ -33,13 +33,28 @@ for version; do eval "variants=( $variants )" for variant in "${variants[@]}"; do - template="Dockerfile${variant:+-$variant}.template" - target="$version${variant:+/$variant}/Dockerfile" - + dir="$version${variant:+/$variant}" + + case "$variant" in + windows/*) + variant="$(basename "$variant")" # "windowsservercore-1809", etc + windowsVariant="${variant%%-*}" # "windowsservercore", "nanoserver" + windowsRelease="${variant#$windowsVariant-}" # "1809", "ltsc2016", etc + windowsVariant="${windowsVariant#windows}" # "servercore", "nanoserver" + export windowsVariant windowsRelease + template="Dockerfile-windows-$windowsVariant.template" + ;; + + *) + template="Dockerfile${variant:+-$variant}.template" + ;; + esac + + mkdir -p "$dir" { generated_warning gawk -f "$jqt" "$template" - } > "$target" + } > "$dir/Dockerfile" done cp -a docker-entrypoint.sh modprobe.sh "$version/" diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 24f0a69b1..58fa4c731 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -55,6 +55,15 @@ versionArches() { selector='rootlessExtrasUrl' fi + if [[ "$variant" = windows/* ]]; then + version="$version" jq -r ' + .[env.version].arches + | keys[] + | select(startswith("windows-")) + ' versions.json | sort + return + fi + local parent parentArches parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")" parentArches="${parentRepoToArches[$parent]:-}" @@ -154,21 +163,32 @@ for version; do variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" eval "variants=( $variants )" - for variant in "${variants[@]}"; do - dir="$version${variant:+/$variant}" + for v in "${variants[@]}"; do + dir="$version${v:+/$v}" [ -f "$dir/Dockerfile" ] || continue commit="$(dirCommit "$dir")" + variant="$(basename "$v")" variantAliases=( "${versionAliases[@]/%/${variant:+-$variant}}" ) variantAliases=( "${variantAliases[@]//latest-/}" ) + sharedTags=() + if [[ "$variant" == windowsservercore* ]]; then + sharedTags=( "${versionAliases[@]/%/-windowsservercore}" ) + sharedTags=( "${sharedTags[@]//latest-/}" ) + fi + echo + echo "Tags: $(join ', ' "${variantAliases[@]}")" + if [ "${#sharedTags[@]}" -gt 0 ]; then + echo "SharedTags: $(join ', ' "${sharedTags[@]}")" + fi cat <<-EOE - Tags: $(join ', ' "${variantAliases[@]}") - Architectures: $(join ', ' $(versionArches "$version" "$variant")) + Architectures: $(join ', ' $(versionArches "$version" "$v")) GitCommit: $commit Directory: $dir EOE + [ "$variant" = "$v" ] || echo "Constraints: $variant" done done diff --git a/versions.json b/versions.json index dbeba07b9..bb19943d7 100644 --- a/versions.json +++ b/versions.json @@ -66,6 +66,9 @@ }, "arm64v8": { "dockerUrl": "https://download.docker.com/linux/static/stable/aarch64/docker-20.10.6.tgz" + }, + "windows-amd64": { + "dockerUrl": "https://download.docker.com/win/static/stable/x86_64/docker-20.10.6.zip" } }, "dindCommit": "42b1175eda071c0e9121e1d64345928384a93df1", @@ -73,7 +76,8 @@ "", "dind", "dind-rootless", - "git" + "git", + "windows/windowsservercore-1809" ], "version": "20.10.6" }, diff --git a/versions.sh b/versions.sh index a4aba6d1f..de0a4f64d 100755 --- a/versions.sh +++ b/versions.sh @@ -14,7 +14,7 @@ declare -A dockerArches=( ['arm64v8']='aarch64' ['ppc64le']='ppc64le' ['s390x']='s390x' -# ['windows-amd64']='windows-amd64' + ['windows-amd64']='x86_64' ) cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" @@ -98,10 +98,14 @@ for version in "${versions[@]}"; do }' )" + hasWindows= for bashbrewArch in "${!dockerArches[@]}"; do arch="${dockerArches[$bashbrewArch]}" # check whether the given architecture is supported for this release - url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz" + case "$bashbrewArch" in + windows-*) url="https://download.docker.com/win/static/$channel/$arch/docker-$fullVersion.zip"; windows=1 ;; + *) url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz"; windows= ;; + esac if wget --quiet --spider "$url" &> /dev/null; then export bashbrewArch url doc="$( @@ -113,6 +117,11 @@ for version in "${versions[@]}"; do continue fi + if [ -n "$windows" ]; then + hasWindows=1 + continue # Windows doesn't have rootless extras :) + fi + rootlessExtrasUrl="https://download.docker.com/linux/static/$channel/$arch/docker-rootless-extras-$fullVersion.tgz" # https://github.com/docker/docker-ce/blob/8fb3bb7b2210789a4471c017561c1b0de0b4f145/components/engine/hack/make/binary-daemon#L24 # "vpnkit is amd64-only" ... for now?? @@ -131,9 +140,13 @@ for version in "${versions[@]}"; do dind \ dind-rootless \ git \ + windows/windowsservercore-1809 \ ; do base="${variant%%/*}" # "buster", "windows", etc. [ -d "$version/$base" ] || continue + if [ "$base" = 'windows' ] && [ -z "$hasWindows" ]; then + continue + fi export variant doc="$(jq <<<"$doc" -c '.variants += [ env.variant ]')" done