Skip to content
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

Add multiarch support (again) and update to 17.06.0-ce-rc2 #63

Merged
merged 1 commit into from
Jun 7, 2017
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
60 changes: 60 additions & 0 deletions .architectures-lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

_awkArch() {
local version="$1"; shift
local awkExpr="$1"; shift
awk "$@" "/^#|^\$/ { next } $awkExpr" "$version/release-architectures"
}

apkArches() {
local version="$1"; shift
_awkArch "$version" '{ print $2 }'
}

hasBashbrewArch() {
local version="$1"; shift
local bashbrewArch="$1"; shift
_awkArch "$version" 'BEGIN { exitCode = 1 } $1 == bashbrewArch { exitCode = 0 } END { exit exitCode }' -v bashbrewArch="$bashbrewArch"
}

apkToDockerArch() {
local version="$1"; shift
local apkArch="$1"; shift
_awkArch "$version" '$2 == apkArch { print $3; exit }' -v apkArch="$apkArch"
}

_generateParentRepoToArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'

eval "declare -g -A parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
_generateParentRepoToArches 'docker'

parentArches() {
local version="$1"; shift # "17.06", etc

local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
echo "${parentRepoToArches[$parent]:-}"
}
versionArches() {
local version="$1"; shift

local parentArches="$(parentArches "$version")"

local versionArches=()
for arch in $parentArches; do
if hasBashbrewArch "$version" "$arch"; then
versionArches+=( "$arch" )
fi
done
echo "${versionArches[*]}"
}
20 changes: 19 additions & 1 deletion 17.03-rc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ RUN apk add --no-cache \
ENV DOCKER_CHANNEL test
ENV DOCKER_VERSION 17.03.2-ce-rc1
# 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 set -ex; \
# why we use "curl" instead of "wget":
Expand All @@ -16,14 +18,30 @@ RUN set -ex; \
curl \
tar \
; \
curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz"; \
\
# this "case" statement is generated via "update.sh"
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
x86_64) dockerArch='x86_64' ;; \
*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\
esac; \
\
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}-${dockerArch}.tgz"; then \
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \
echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \
exit 1; \
fi; \
fi; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
; \
rm docker.tgz; \
\
apk del .fetch-deps; \
\
dockerd -v; \
docker -v

Expand Down
4 changes: 4 additions & 0 deletions 17.03-rc/release-architectures
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# see subdirectories of https://download.docker.com/linux/static/

# bashbrew-arch apk-arch docker-release-arch
amd64 x86_64 x86_64
20 changes: 19 additions & 1 deletion 17.03/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ RUN apk add --no-cache \
ENV DOCKER_CHANNEL stable
ENV DOCKER_VERSION 17.03.1-ce
# 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 set -ex; \
# why we use "curl" instead of "wget":
Expand All @@ -16,14 +18,30 @@ RUN set -ex; \
curl \
tar \
; \
curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz"; \
\
# this "case" statement is generated via "update.sh"
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
x86_64) dockerArch='x86_64' ;; \
*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\
esac; \
\
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}-${dockerArch}.tgz"; then \
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \
echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \
exit 1; \
fi; \
fi; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
; \
rm docker.tgz; \
\
apk del .fetch-deps; \
\
dockerd -v; \
docker -v

Expand Down
4 changes: 4 additions & 0 deletions 17.03/release-architectures
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# see subdirectories of https://download.docker.com/linux/static/

# bashbrew-arch apk-arch docker-release-arch
amd64 x86_64 x86_64
20 changes: 19 additions & 1 deletion 17.05/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ RUN apk add --no-cache \
ENV DOCKER_CHANNEL edge
ENV DOCKER_VERSION 17.05.0-ce
# 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 set -ex; \
# why we use "curl" instead of "wget":
Expand All @@ -16,14 +18,30 @@ RUN set -ex; \
curl \
tar \
; \
curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz"; \
\
# this "case" statement is generated via "update.sh"
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
x86_64) dockerArch='x86_64' ;; \
*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\
esac; \
\
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}-${dockerArch}.tgz"; then \
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \
echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \
exit 1; \
fi; \
fi; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
; \
rm docker.tgz; \
\
apk del .fetch-deps; \
\
dockerd -v; \
docker -v

Expand Down
4 changes: 4 additions & 0 deletions 17.05/release-architectures
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# see subdirectories of https://download.docker.com/linux/static/

# bashbrew-arch apk-arch docker-release-arch
amd64 x86_64 x86_64
23 changes: 21 additions & 2 deletions 17.06-rc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ RUN apk add --no-cache \
ca-certificates

ENV DOCKER_CHANNEL test
ENV DOCKER_VERSION 17.06.0-ce-rc1
ENV DOCKER_VERSION 17.06.0-ce-rc2
# 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 set -ex; \
# why we use "curl" instead of "wget":
Expand All @@ -16,14 +18,31 @@ RUN set -ex; \
curl \
tar \
; \
curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz"; \
\
# this "case" statement is generated via "update.sh"
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
x86_64) dockerArch='x86_64' ;; \
s390x) dockerArch='s390x' ;; \
*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\
esac; \
\
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}-${dockerArch}.tgz"; then \
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \
echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \
exit 1; \
fi; \
fi; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
; \
rm docker.tgz; \
\
apk del .fetch-deps; \
\
dockerd -v; \
docker -v

Expand Down
9 changes: 9 additions & 0 deletions 17.06-rc/release-architectures
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# see subdirectories of https://download.docker.com/linux/static/

# bashbrew-arch apk-arch docker-release-arch
amd64 x86_64 x86_64
s390x s390x s390x

# Docker's "armhf" is ARMv7 (as of 2017-06-07, 17.06.0-ce-rc2)
#arm32v6 armhf armhf
# https://dockercommunity.slackarchive.io/arm/page-13
35 changes: 35 additions & 0 deletions Dockerfile-dind.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM docker:%%VERSION%%

# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
RUN apk add --no-cache \
btrfs-progs \
e2fsprogs \
e2fsprogs-extra \
iptables \
xfsprogs \
xz

# TODO aufs-tools

# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box
RUN set -x \
&& addgroup -S dockremap \
&& adduser -S -G dockremap dockremap \
&& echo 'dockremap:165536:65536' >> /etc/subuid \
&& echo 'dockremap:165536:65536' >> /etc/subgid

ENV DIND_COMMIT 3b5fac462d21ca164b3778647420016315289034

RUN set -ex; \
apk add --no-cache --virtual .fetch-deps libressl; \
wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \
chmod +x /usr/local/bin/dind; \
apk del .fetch-deps

COPY dockerd-entrypoint.sh /usr/local/bin/

VOLUME /var/lib/docker
EXPOSE 2375

ENTRYPOINT ["dockerd-entrypoint.sh"]
CMD []
5 changes: 5 additions & 0 deletions Dockerfile-git.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM docker:%%VERSION%%

RUN apk add --no-cache \
git \
openssh-client
47 changes: 47 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM alpine:%%ALPINE-VERSION%%

RUN apk add --no-cache \
ca-certificates

ENV DOCKER_CHANNEL %%DOCKER-CHANNEL%%
ENV DOCKER_VERSION %%DOCKER-VERSION%%
# 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 set -ex; \
# why we use "curl" instead of "wget":
# + wget -O docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-17.03.1-ce.tgz
# Connecting to download.docker.com (54.230.87.253:443)
# wget: error getting response: Connection reset by peer
apk add --no-cache --virtual .fetch-deps \
curl \
tar \
; \
\
# this "case" statement is generated via "update.sh"
%%ARCH-CASE%%; \
\
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}-${dockerArch}.tgz"; then \
if ! curl -fL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \
echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \
exit 1; \
fi; \
fi; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
; \
rm docker.tgz; \
\
apk del .fetch-deps; \
\
dockerd -v; \
docker -v

COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["sh"]
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- docker "$@"
fi

# if our command is a valid Docker subcommand, let's invoke it through Docker instead
# (this allows for "docker run docker ps", etc)
if docker help "$1" > /dev/null 2>&1; then
set -- docker "$@"
fi

# if we have "--link some-docker:docker" and not DOCKER_HOST, let's set DOCKER_HOST automatically
if [ -z "$DOCKER_HOST" -a "$DOCKER_PORT_2375_TCP" ]; then
export DOCKER_HOST='tcp://docker:2375'
fi

exec "$@"
21 changes: 21 additions & 0 deletions dockerd-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e

# no arguments passed
# or first arg is `-f` or `--some-option`
if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then
# add our default arguments
set -- dockerd \
--host=unix:///var/run/docker.sock \
--host=tcp://0.0.0.0:2375 \
--storage-driver=vfs \
"$@"
fi

if [ "$1" = 'dockerd' ]; then
# if we're running Docker, let's pipe through dind
# (and we'll run dind explicitly with "sh" since its shebang is /bin/bash)
set -- sh "$(which dind)" "$@"
fi

exec "$@"
Loading