Skip to content

Commit 94eb642

Browse files
committed
Add support for s390x via "apt-get source --compile"
This takes advantage of the fact that http://nginx.org/packages/ includes the source packages as well, and simply compiles them on non-prebuilt architectures instead, which ensures we have a completely compatible experience with minimal maintenance overhead.
1 parent 5f62ef9 commit 94eb642

File tree

5 files changed

+268
-42
lines changed

5 files changed

+268
-42
lines changed

generate-stackbrew-library.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ for version in "${versions[@]}"; do
6565
echo
6666
cat <<-EOE
6767
Tags: $(join ', ' "${versionAliases[@]}")
68+
Architectures: amd64, i386, s390x
6869
GitCommit: $commit
6970
Directory: $version/$base
7071
EOE
@@ -78,6 +79,7 @@ for version in "${versions[@]}"; do
7879
echo
7980
cat <<-EOE
8081
Tags: $(join ', ' "${variantAliases[@]}")
82+
Architectures: amd64, i386, s390x
8183
GitCommit: $commit
8284
Directory: $version/$variant
8385
EOE

mainline/stretch-perl/Dockerfile

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
55
ENV NGINX_VERSION 1.13.4-1~stretch
66
ENV NJS_VERSION 1.13.4.0.1.12-1~stretch
77

8-
RUN apt-get update \
8+
RUN set -x \
9+
&& apt-get update \
910
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
1011
&& \
1112
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
@@ -20,18 +21,73 @@ RUN apt-get update \
2021
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
2122
done; \
2223
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23-
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24-
&& echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
25-
&& apt-get update \
24+
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
25+
&& dpkgArch="$(dpkg --print-architecture)" \
26+
&& nginxPackages=" \
27+
nginx=${NGINX_VERSION} \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-perl=${NGINX_VERSION} \
32+
nginx-module-njs=${NJS_VERSION} \
33+
" \
34+
&& case "$dpkgArch" in \
35+
amd64|i386) \
36+
# arches officialy built by upstream
37+
echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
38+
&& apt-get update \
39+
;; \
40+
*) \
41+
# we're on an architecture upstream doesn't officially build for
42+
# let's build binaries from the published source packages
43+
echo "deb-src http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
44+
\
45+
# new directory for storing sources and .deb files
46+
&& tempDir="$(mktemp -d)" \
47+
&& chmod 777 "$tempDir" \
48+
# (777 to ensure APT's "_apt" user can access it too)
49+
\
50+
# save list of currently-installed packages so build dependencies can be cleanly removed later
51+
&& savedAptMark="$(apt-mark showmanual)" \
52+
\
53+
# build .deb files from upstream's source packages (which are verified by apt-get)
54+
&& apt-get update \
55+
&& apt-get build-dep -y $nginxPackages \
56+
&& ( \
57+
cd "$tempDir" \
58+
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
59+
apt-get source --compile $nginxPackages \
60+
) \
61+
# we don't remove APT lists here because they get re-downloaded and removed later
62+
\
63+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
64+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
65+
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
66+
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
67+
\
68+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
69+
&& ls -lAFh "$tempDir" \
70+
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
71+
&& grep '^Package: ' "$tempDir/Packages" \
72+
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
73+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
74+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
75+
# ...
76+
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
77+
&& apt-get -o Acquire::GzipIndexes=false update \
78+
;; \
79+
esac \
80+
\
2681
&& apt-get install --no-install-recommends --no-install-suggests -y \
27-
nginx=${NGINX_VERSION} \
28-
nginx-module-xslt=${NGINX_VERSION} \
29-
nginx-module-geoip=${NGINX_VERSION} \
30-
nginx-module-image-filter=${NGINX_VERSION} \
31-
nginx-module-perl=${NGINX_VERSION} \
32-
nginx-module-njs=${NJS_VERSION} \
82+
$nginxPackages \
3383
gettext-base \
34-
&& rm -rf /var/lib/apt/lists/*
84+
&& rm -rf /var/lib/apt/lists/* \
85+
\
86+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
87+
&& if [ -n "$tempDir" ]; then \
88+
apt-get purge -y --auto-remove \
89+
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
90+
fi
3591

3692
# forward request and error logs to docker log collector
3793
RUN ln -sf /dev/stdout /var/log/nginx/access.log \

mainline/stretch/Dockerfile

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
55
ENV NGINX_VERSION 1.13.4-1~stretch
66
ENV NJS_VERSION 1.13.4.0.1.12-1~stretch
77

8-
RUN apt-get update \
8+
RUN set -x \
9+
&& apt-get update \
910
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
1011
&& \
1112
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
@@ -20,17 +21,72 @@ RUN apt-get update \
2021
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
2122
done; \
2223
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23-
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24-
&& echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
25-
&& apt-get update \
24+
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
25+
&& dpkgArch="$(dpkg --print-architecture)" \
26+
&& nginxPackages=" \
27+
nginx=${NGINX_VERSION} \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-njs=${NJS_VERSION} \
32+
" \
33+
&& case "$dpkgArch" in \
34+
amd64|i386) \
35+
# arches officialy built by upstream
36+
echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
37+
&& apt-get update \
38+
;; \
39+
*) \
40+
# we're on an architecture upstream doesn't officially build for
41+
# let's build binaries from the published source packages
42+
echo "deb-src http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
43+
\
44+
# new directory for storing sources and .deb files
45+
&& tempDir="$(mktemp -d)" \
46+
&& chmod 777 "$tempDir" \
47+
# (777 to ensure APT's "_apt" user can access it too)
48+
\
49+
# save list of currently-installed packages so build dependencies can be cleanly removed later
50+
&& savedAptMark="$(apt-mark showmanual)" \
51+
\
52+
# build .deb files from upstream's source packages (which are verified by apt-get)
53+
&& apt-get update \
54+
&& apt-get build-dep -y $nginxPackages \
55+
&& ( \
56+
cd "$tempDir" \
57+
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
58+
apt-get source --compile $nginxPackages \
59+
) \
60+
# we don't remove APT lists here because they get re-downloaded and removed later
61+
\
62+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
63+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
64+
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
65+
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
66+
\
67+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
68+
&& ls -lAFh "$tempDir" \
69+
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
70+
&& grep '^Package: ' "$tempDir/Packages" \
71+
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
72+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
73+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
74+
# ...
75+
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
76+
&& apt-get -o Acquire::GzipIndexes=false update \
77+
;; \
78+
esac \
79+
\
2680
&& apt-get install --no-install-recommends --no-install-suggests -y \
27-
nginx=${NGINX_VERSION} \
28-
nginx-module-xslt=${NGINX_VERSION} \
29-
nginx-module-geoip=${NGINX_VERSION} \
30-
nginx-module-image-filter=${NGINX_VERSION} \
31-
nginx-module-njs=${NJS_VERSION} \
81+
$nginxPackages \
3282
gettext-base \
33-
&& rm -rf /var/lib/apt/lists/*
83+
&& rm -rf /var/lib/apt/lists/* \
84+
\
85+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
86+
&& if [ -n "$tempDir" ]; then \
87+
apt-get purge -y --auto-remove \
88+
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
89+
fi
3490

3591
# forward request and error logs to docker log collector
3692
RUN ln -sf /dev/stdout /var/log/nginx/access.log \

stable/stretch-perl/Dockerfile

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
55
ENV NGINX_VERSION 1.12.1-1~stretch
66
ENV NJS_VERSION 1.12.1.0.1.10-1~stretch
77

8-
RUN apt-get update \
8+
RUN set -x \
9+
&& apt-get update \
910
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
1011
&& \
1112
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
@@ -20,18 +21,73 @@ RUN apt-get update \
2021
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
2122
done; \
2223
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23-
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24-
&& echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
25-
&& apt-get update \
24+
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
25+
&& dpkgArch="$(dpkg --print-architecture)" \
26+
&& nginxPackages=" \
27+
nginx=${NGINX_VERSION} \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-perl=${NGINX_VERSION} \
32+
nginx-module-njs=${NJS_VERSION} \
33+
" \
34+
&& case "$dpkgArch" in \
35+
amd64|i386) \
36+
# arches officialy built by upstream
37+
echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
38+
&& apt-get update \
39+
;; \
40+
*) \
41+
# we're on an architecture upstream doesn't officially build for
42+
# let's build binaries from the published source packages
43+
echo "deb-src http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
44+
\
45+
# new directory for storing sources and .deb files
46+
&& tempDir="$(mktemp -d)" \
47+
&& chmod 777 "$tempDir" \
48+
# (777 to ensure APT's "_apt" user can access it too)
49+
\
50+
# save list of currently-installed packages so build dependencies can be cleanly removed later
51+
&& savedAptMark="$(apt-mark showmanual)" \
52+
\
53+
# build .deb files from upstream's source packages (which are verified by apt-get)
54+
&& apt-get update \
55+
&& apt-get build-dep -y $nginxPackages \
56+
&& ( \
57+
cd "$tempDir" \
58+
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
59+
apt-get source --compile $nginxPackages \
60+
) \
61+
# we don't remove APT lists here because they get re-downloaded and removed later
62+
\
63+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
64+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
65+
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
66+
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
67+
\
68+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
69+
&& ls -lAFh "$tempDir" \
70+
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
71+
&& grep '^Package: ' "$tempDir/Packages" \
72+
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
73+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
74+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
75+
# ...
76+
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
77+
&& apt-get -o Acquire::GzipIndexes=false update \
78+
;; \
79+
esac \
80+
\
2681
&& apt-get install --no-install-recommends --no-install-suggests -y \
27-
nginx=${NGINX_VERSION} \
28-
nginx-module-xslt=${NGINX_VERSION} \
29-
nginx-module-geoip=${NGINX_VERSION} \
30-
nginx-module-image-filter=${NGINX_VERSION} \
31-
nginx-module-perl=${NGINX_VERSION} \
32-
nginx-module-njs=${NJS_VERSION} \
82+
$nginxPackages \
3383
gettext-base \
34-
&& rm -rf /var/lib/apt/lists/*
84+
&& rm -rf /var/lib/apt/lists/* \
85+
\
86+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
87+
&& if [ -n "$tempDir" ]; then \
88+
apt-get purge -y --auto-remove \
89+
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
90+
fi
3591

3692
# forward request and error logs to docker log collector
3793
RUN ln -sf /dev/stdout /var/log/nginx/access.log \

stable/stretch/Dockerfile

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
55
ENV NGINX_VERSION 1.12.1-1~stretch
66
ENV NJS_VERSION 1.12.1.0.1.10-1~stretch
77

8-
RUN apt-get update \
8+
RUN set -x \
9+
&& apt-get update \
910
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
1011
&& \
1112
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
@@ -20,17 +21,72 @@ RUN apt-get update \
2021
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
2122
done; \
2223
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23-
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24-
&& echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
25-
&& apt-get update \
24+
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
25+
&& dpkgArch="$(dpkg --print-architecture)" \
26+
&& nginxPackages=" \
27+
nginx=${NGINX_VERSION} \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-njs=${NJS_VERSION} \
32+
" \
33+
&& case "$dpkgArch" in \
34+
amd64|i386) \
35+
# arches officialy built by upstream
36+
echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
37+
&& apt-get update \
38+
;; \
39+
*) \
40+
# we're on an architecture upstream doesn't officially build for
41+
# let's build binaries from the published source packages
42+
echo "deb-src http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list \
43+
\
44+
# new directory for storing sources and .deb files
45+
&& tempDir="$(mktemp -d)" \
46+
&& chmod 777 "$tempDir" \
47+
# (777 to ensure APT's "_apt" user can access it too)
48+
\
49+
# save list of currently-installed packages so build dependencies can be cleanly removed later
50+
&& savedAptMark="$(apt-mark showmanual)" \
51+
\
52+
# build .deb files from upstream's source packages (which are verified by apt-get)
53+
&& apt-get update \
54+
&& apt-get build-dep -y $nginxPackages \
55+
&& ( \
56+
cd "$tempDir" \
57+
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
58+
apt-get source --compile $nginxPackages \
59+
) \
60+
# we don't remove APT lists here because they get re-downloaded and removed later
61+
\
62+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
63+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
64+
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
65+
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
66+
\
67+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
68+
&& ls -lAFh "$tempDir" \
69+
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
70+
&& grep '^Package: ' "$tempDir/Packages" \
71+
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
72+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
73+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
74+
# ...
75+
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
76+
&& apt-get -o Acquire::GzipIndexes=false update \
77+
;; \
78+
esac \
79+
\
2680
&& apt-get install --no-install-recommends --no-install-suggests -y \
27-
nginx=${NGINX_VERSION} \
28-
nginx-module-xslt=${NGINX_VERSION} \
29-
nginx-module-geoip=${NGINX_VERSION} \
30-
nginx-module-image-filter=${NGINX_VERSION} \
31-
nginx-module-njs=${NJS_VERSION} \
81+
$nginxPackages \
3282
gettext-base \
33-
&& rm -rf /var/lib/apt/lists/*
83+
&& rm -rf /var/lib/apt/lists/* \
84+
\
85+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
86+
&& if [ -n "$tempDir" ]; then \
87+
apt-get purge -y --auto-remove \
88+
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
89+
fi
3490

3591
# forward request and error logs to docker log collector
3692
RUN ln -sf /dev/stdout /var/log/nginx/access.log \

0 commit comments

Comments
 (0)