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 support for multiple architectures #16

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

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

dpkgArches() {
_awkArch '{ print $2 }'
}

dpkgToBashbrewArch() {
local dpkgArch="$1"; shift
_awkArch '$2 == dpkgArch { print $1; exit }' -v dpkgArch="$dpkgArch"
}

dpkgToPyPyArch() {
local dpkgArch="$1"; shift
_awkArch '$2 == dpkgArch { print $3; exit }' -v dpkgArch="$dpkgArch"
}

_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 'pypy'

hasBashbrewArch() {
local dir="$1"; shift
local bashbrewArch="$1"; shift
grep -qE "^# ${bashbrewArch}\$" "$dir/Dockerfile"
}

parentArches() {
local dir="$1"; shift # "2", "3/slim", etc

local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$dir/Dockerfile")"
local parentArches="${parentRepoToArches[$parent]:-}"

local arches=()
for arch in $parentArches; do
if hasBashbrewArch "$dir" "$arch"; then
arches+=( "$arch" )
fi
done
echo "${arches[*]:-}"
}
24 changes: 20 additions & 4 deletions 2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION 5.8.0
ENV PYPY_SHA256SUM 6274292d0e954a2609b15978cde6efa30942ba20aa5d2acbbf1c70c0a54e9b1e

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
# amd64
amd64) pypyArch='linux64'; sha256='6274292d0e954a2609b15978cde6efa30942ba20aa5d2acbbf1c70c0a54e9b1e' ;; \
# arm32v5
armel) pypyArch='linux-armel'; sha256='28b7fd0cc7418ffc66c71520728e87941be40ebf4b82675c57e25598a2a702b0' ;; \
# arm32v7
armhf) pypyArch='linux-armhf-raring'; sha256='ddceca9c5c9a456d4bf1beab177660adffbbdf255a922244e1cc05f20318be46' ;; \
# i386
i386) pypyArch='linux32'; sha256='a0b125a5781f7e5ddfc3baca46503b14f4ee6a0e234e8d72bfcf3afdf4120bef' ;; \
*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding PyPy $PYPY_VERSION binary release"; exit 1 ;; \
esac; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2
rm pypy.tar.bz2; \
\
pypy --version

RUN set -ex; \
\
Expand Down
21 changes: 18 additions & 3 deletions 2/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,39 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION 5.8.0
ENV PYPY_SHA256SUM 6274292d0e954a2609b15978cde6efa30942ba20aa5d2acbbf1c70c0a54e9b1e

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
# amd64
amd64) pypyArch='linux64'; sha256='6274292d0e954a2609b15978cde6efa30942ba20aa5d2acbbf1c70c0a54e9b1e' ;; \
# arm32v5
armel) pypyArch='linux-armel'; sha256='28b7fd0cc7418ffc66c71520728e87941be40ebf4b82675c57e25598a2a702b0' ;; \
# arm32v7
armhf) pypyArch='linux-armhf-raring'; sha256='ddceca9c5c9a456d4bf1beab177660adffbbdf255a922244e1cc05f20318be46' ;; \
# i386
i386) pypyArch='linux32'; sha256='a0b125a5781f7e5ddfc3baca46503b14f4ee6a0e234e8d72bfcf3afdf4120bef' ;; \
*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding PyPy $PYPY_VERSION binary release"; exit 1 ;; \
esac; \
\
fetchDeps=' \
bzip2 \
wget \
'; \
apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/*; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2; \
\
pypy --version; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
pypy get-pip.py \
Expand Down
18 changes: 14 additions & 4 deletions 3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION 5.8.0
ENV PYPY_SHA256SUM 57d871a7f1135719c138cee4e3533c3275d682a76a40ff668e95150c65923035

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
# amd64
amd64) pypyArch='linux64'; sha256='57d871a7f1135719c138cee4e3533c3275d682a76a40ff668e95150c65923035' ;; \
*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding PyPy $PYPY_VERSION binary release"; exit 1 ;; \
esac; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2
rm pypy.tar.bz2; \
\
pypy3 --version

RUN set -ex; \
\
Expand Down
15 changes: 12 additions & 3 deletions 3/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION 5.8.0
ENV PYPY_SHA256SUM 57d871a7f1135719c138cee4e3533c3275d682a76a40ff668e95150c65923035

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
# amd64
amd64) pypyArch='linux64'; sha256='57d871a7f1135719c138cee4e3533c3275d682a76a40ff668e95150c65923035' ;; \
*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding PyPy $PYPY_VERSION binary release"; exit 1 ;; \
esac; \
\
fetchDeps=' \
bzip2 \
wget \
'; \
apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/*; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2; \
\
pypy3 --version; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
pypy3 get-pip.py \
Expand Down
54 changes: 54 additions & 0 deletions Dockerfile-slim.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM debian:jessie-slim

# ensure local pypy is preferred over distribution python
ENV PATH /usr/local/bin:$PATH

# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libexpat1 \
libffi6 \
libgdbm3 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION %%PYPY_VERSION%%

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
# this "case" statement is generated via "update.sh"
%%ARCH-CASE%%; \
\
fetchDeps=' \
bzip2 \
wget \
'; \
apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/*; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/%%TAR%%-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2; \
\
%%CMD%% --version; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
%%CMD%% get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
rm -f get-pip.py; \
\
apt-get purge -y --auto-remove $fetchDeps

CMD ["%%CMD%%"]
46 changes: 46 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM buildpack-deps:jessie

# ensure local pypy is preferred over distribution python
ENV PATH /usr/local/bin:$PATH

# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8

# runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
tcl \
tk \
&& rm -rf /var/lib/apt/lists/*

ENV PYPY_VERSION %%PYPY_VERSION%%

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
# this "case" statement is generated via "update.sh"
%%ARCH-CASE%%; \
\
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/%%TAR%%-v${PYPY_VERSION}-${pypyArch}.tar.bz2"; \
echo "$sha256 *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2; \
\
%%CMD%% --version

RUN set -ex; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
%%CMD%% get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
rm -f get-pip.py

CMD ["%%CMD%%"]
33 changes: 19 additions & 14 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
#!/usr/bin/env bash
set -Eeuo pipefail

declare -A aliases=(
[3]='latest'
Expand All @@ -8,6 +8,8 @@ declare -A aliases=(
self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

source '.architectures-lib'

versions=( */ )
versions=( "${versions[@]%/}" )

Expand Down Expand Up @@ -61,26 +63,29 @@ for version in "${versions[@]}"; do
done
versionAliases+=( $version ${aliases[$version]:-} )

echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
GitCommit: $commit
Directory: $version
EOE
for variant in '' slim onbuild; do
dir="$version${variant:+/$variant}"
[ -f "$dir/Dockerfile" ] || continue

for variant in slim onbuild; do
[ -f "$version/$variant/Dockerfile" ] || continue
commit="$(dirCommit "$dir")"

commit="$(dirCommit "$version/$variant")"
variantAliases=( "${versionAliases[@]}" )
if [ -n "$variant" ]; then
variantAliases=( "${variantAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" )
fi

variantAliases=( "${versionAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" )
case "$variant" in
onbuild) variantArches="$(parentArches "$(dirname "$dir")" )" ;;
*) variantArches="$(parentArches "$dir")" ;;
esac

echo
cat <<-EOE
Tags: $(join ', ' "${variantAliases[@]}")
Architectures: $(join ', ' $variantArches)
GitCommit: $commit
Directory: $version/$variant
Directory: $dir
EOE
done
done
14 changes: 14 additions & 0 deletions release-architectures
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# see https://bitbucket.org/pypy/pypy/downloads/
# and https://pypy.org/download.html#checksums

# bashbrew-arch dpkg-arch pypy-release-arch
amd64 amd64 linux64
arm32v5 armel linux-armel
arm32v7 armhf linux-armhf-raring
i386 i386 linux32

# pypy: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory
#ppc64le ppc64el ppc64le

# pypy: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory
#s390x s390x s390x
Loading