Skip to content

Windows update #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 20.10/windows/windowsservercore-1809/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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';"]
Expand All @@ -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; \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN set -eux; \
{{
[
.arches | to_entries[]
| select(.value.dockerUrl)
| select(.value.dockerUrl and (.key | startswith("windows-") | not))
| .key as $bashbrewArch
| (
{
Expand Down
23 changes: 19 additions & 4 deletions apply-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
28 changes: 24 additions & 4 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]:-}"
Expand Down Expand Up @@ -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=()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want shared tags between Windows & Linux too? (like python)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't previously, which is why I didn't here -- I think that was a conscious choice due to the massive differences in their ability to be functional/useful on the different platforms.

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
6 changes: 5 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@
},
"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",
"variants": [
"",
"dind",
"dind-rootless",
"git"
"git",
"windows/windowsservercore-1809"
],
"version": "20.10.6"
},
Expand Down
17 changes: 15 additions & 2 deletions versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")")"
Expand Down Expand Up @@ -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="$(
Expand All @@ -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??
Expand All @@ -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
Expand Down