Skip to content

Commit 01ecb28

Browse files
Add back Windows variant
See https://download.docker.com/win/static/stable/x86_64/ 🎉 Co-authored-by: Tianon Gravi <[email protected]>
1 parent d0d3a6a commit 01ecb28

File tree

7 files changed

+109
-18
lines changed

7 files changed

+109
-18
lines changed

20.10/windows/windowsservercore-1809/Dockerfile

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile-windows-windowsservercore.template renamed to Dockerfile-windows-servercore.template

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM microsoft/windowsservercore:%%TAG%%
1+
FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }}
22

33
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
44
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
@@ -9,15 +9,14 @@ RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \
99
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
1010
# doing this first to share cache across versions more aggressively
1111

12-
ENV DOCKER_CHANNEL %%DOCKER-CHANNEL%%
13-
ENV DOCKER_VERSION %%DOCKER-VERSION%%
12+
ENV DOCKER_VERSION {{ .version }}
13+
ENV DOCKER_URL {{ .arches["windows-amd64"].dockerUrl }}
1414
# TODO ENV DOCKER_SHA256
1515
# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !!
1616
# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though)
1717

18-
RUN $url = ('https://download.docker.com/win/static/{0}/x86_64/docker-{1}.zip' -f $env:DOCKER_CHANNEL, $env:DOCKER_VERSION); \
19-
Write-Host ('Downloading {0} ...' -f $url); \
20-
Invoke-WebRequest -Uri $url -OutFile 'docker.zip'; \
18+
RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \
19+
Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \
2120
\
2221
Write-Host 'Expanding ...'; \
2322
Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \

Dockerfile.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN set -eux; \
2323
{{
2424
[
2525
.arches | to_entries[]
26-
| select(.value.dockerUrl)
26+
| select(.value.dockerUrl and (.key | startswith("windows-") | not))
2727
| .key as $bashbrewArch
2828
| (
2929
{

apply-templates.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,28 @@ for version; do
3333
eval "variants=( $variants )"
3434

3535
for variant in "${variants[@]}"; do
36-
template="Dockerfile${variant:+-$variant}.template"
37-
target="$version${variant:+/$variant}/Dockerfile"
38-
36+
dir="$version${variant:+/$variant}"
37+
38+
case "$variant" in
39+
windows/*)
40+
variant="$(basename "$variant")" # "windowsservercore-1809", etc
41+
windowsVariant="${variant%%-*}" # "windowsservercore", "nanoserver"
42+
windowsRelease="${variant#$windowsVariant-}" # "1809", "ltsc2016", etc
43+
windowsVariant="${windowsVariant#windows}" # "servercore", "nanoserver"
44+
export windowsVariant windowsRelease
45+
template="Dockerfile-windows-$windowsVariant.template"
46+
;;
47+
48+
*)
49+
template="Dockerfile${variant:+-$variant}.template"
50+
;;
51+
esac
52+
53+
mkdir -p "$dir"
3954
{
4055
generated_warning
4156
gawk -f "$jqt" "$template"
42-
} > "$target"
57+
} > "$dir/Dockerfile"
4358
done
4459

4560
cp -a docker-entrypoint.sh modprobe.sh "$version/"

generate-stackbrew-library.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ versionArches() {
5555
selector='rootlessExtrasUrl'
5656
fi
5757

58+
if [[ "$variant" = windows/* ]]; then
59+
version="$version" jq -r '
60+
.[env.version].arches
61+
| keys[]
62+
| select(startswith("windows-"))
63+
' versions.json | sort
64+
return
65+
fi
66+
5867
local parent parentArches
5968
parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
6069
parentArches="${parentRepoToArches[$parent]:-}"
@@ -154,21 +163,32 @@ for version; do
154163
variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)"
155164
eval "variants=( $variants )"
156165

157-
for variant in "${variants[@]}"; do
158-
dir="$version${variant:+/$variant}"
166+
for v in "${variants[@]}"; do
167+
dir="$version${v:+/$v}"
159168
[ -f "$dir/Dockerfile" ] || continue
160169

161170
commit="$(dirCommit "$dir")"
162171

172+
variant="$(basename "$v")"
163173
variantAliases=( "${versionAliases[@]/%/${variant:+-$variant}}" )
164174
variantAliases=( "${variantAliases[@]//latest-/}" )
165175

176+
sharedTags=()
177+
if [[ "$variant" == windowsservercore* ]]; then
178+
sharedTags=( "${versionAliases[@]/%/-windowsservercore}" )
179+
sharedTags=( "${sharedTags[@]//latest-/}" )
180+
fi
181+
166182
echo
183+
echo "Tags: $(join ', ' "${variantAliases[@]}")"
184+
if [ "${#sharedTags[@]}" -gt 0 ]; then
185+
echo "SharedTags: $(join ', ' "${sharedTags[@]}")"
186+
fi
167187
cat <<-EOE
168-
Tags: $(join ', ' "${variantAliases[@]}")
169-
Architectures: $(join ', ' $(versionArches "$version" "$variant"))
188+
Architectures: $(join ', ' $(versionArches "$version" "$v"))
170189
GitCommit: $commit
171190
Directory: $dir
172191
EOE
192+
[ "$variant" = "$v" ] || echo "Constraints: $variant"
173193
done
174194
done

versions.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,18 @@
6666
},
6767
"arm64v8": {
6868
"dockerUrl": "https://download.docker.com/linux/static/stable/aarch64/docker-20.10.6.tgz"
69+
},
70+
"windows-amd64": {
71+
"dockerUrl": "https://download.docker.com/win/static/stable/x86_64/docker-20.10.6.zip"
6972
}
7073
},
7174
"dindCommit": "42b1175eda071c0e9121e1d64345928384a93df1",
7275
"variants": [
7376
"",
7477
"dind",
7578
"dind-rootless",
76-
"git"
79+
"git",
80+
"windows/windowsservercore-1809"
7781
],
7882
"version": "20.10.6"
7983
},

versions.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ declare -A dockerArches=(
1414
['arm64v8']='aarch64'
1515
['ppc64le']='ppc64le'
1616
['s390x']='s390x'
17-
# ['windows-amd64']='windows-amd64'
17+
['windows-amd64']='x86_64'
1818
)
1919

2020
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
@@ -98,10 +98,14 @@ for version in "${versions[@]}"; do
9898
}'
9999
)"
100100

101+
hasWindows=
101102
for bashbrewArch in "${!dockerArches[@]}"; do
102103
arch="${dockerArches[$bashbrewArch]}"
103104
# check whether the given architecture is supported for this release
104-
url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz"
105+
case "$bashbrewArch" in
106+
windows-*) url="https://download.docker.com/win/static/$channel/$arch/docker-$fullVersion.zip"; windows=1 ;;
107+
*) url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz"; windows= ;;
108+
esac
105109
if wget --quiet --spider "$url" &> /dev/null; then
106110
export bashbrewArch url
107111
doc="$(
@@ -113,6 +117,11 @@ for version in "${versions[@]}"; do
113117
continue
114118
fi
115119

120+
if [ -n "$windows" ]; then
121+
hasWindows=1
122+
continue # Windows doesn't have rootless extras :)
123+
fi
124+
116125
rootlessExtrasUrl="https://download.docker.com/linux/static/$channel/$arch/docker-rootless-extras-$fullVersion.tgz"
117126
# https://github.com/docker/docker-ce/blob/8fb3bb7b2210789a4471c017561c1b0de0b4f145/components/engine/hack/make/binary-daemon#L24
118127
# "vpnkit is amd64-only" ... for now??
@@ -131,9 +140,13 @@ for version in "${versions[@]}"; do
131140
dind \
132141
dind-rootless \
133142
git \
143+
windows/windowsservercore-1809 \
134144
; do
135145
base="${variant%%/*}" # "buster", "windows", etc.
136146
[ -d "$version/$base" ] || continue
147+
if [ "$base" = 'windows' ] && [ -z "$hasWindows" ]; then
148+
continue
149+
fi
137150
export variant
138151
doc="$(jq <<<"$doc" -c '.variants += [ env.variant ]')"
139152
done

0 commit comments

Comments
 (0)