Skip to content

Commit 436c6e3

Browse files
committed
Based perl variants off default ones.
1 parent b87bbb8 commit 436c6e3

File tree

6 files changed

+178
-7
lines changed

6 files changed

+178
-7
lines changed

Dockerfile-alpine-perl.template

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM nginx:%%NGINX_VERSION%%-alpine
2+
3+
RUN set -x \
4+
&& apkArch="$(cat /etc/apk/arch)" \
5+
&& nginxPackages="%%PACKAGES%%
6+
" \
7+
# install prerequisites for public key and pkg-oss checks
8+
&& apk add --no-cache --virtual .checksum-deps \
9+
openssl \
10+
&& case "$apkArch" in \
11+
x86_64|aarch64) \
12+
# arches officially built by upstream
13+
set -x \
14+
&& KEY_SHA512="e7fa8303923d9b95db37a77ad46c68fd4755ff935d0a534d26eba83de193c76166c68bfe7f65471bf8881004ef4aa6df3e34689c305662750c0172fca5d8552a *stdin" \
15+
&& wget -O /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub \
16+
&& if [ "$(openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout | openssl sha512 -r)" = "$KEY_SHA512" ]; then \
17+
echo "key verification succeeded!"; \
18+
mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/; \
19+
else \
20+
echo "key verification failed!"; \
21+
exit 1; \
22+
fi \
23+
&& apk add -X "%%PACKAGEREPO%%v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" --no-cache $nginxPackages \
24+
;; \
25+
*) \
26+
# we're on an architecture upstream doesn't officially build for
27+
# let's build binaries from the published packaging sources
28+
set -x \
29+
&& tempDir="$(mktemp -d)" \
30+
&& chown nobody:nobody $tempDir \
31+
&& apk add --no-cache --virtual .build-deps \
32+
gcc \
33+
libc-dev \
34+
make \
35+
openssl-dev \
36+
pcre2-dev \
37+
zlib-dev \
38+
linux-headers \
39+
perl-dev \
40+
bash \
41+
alpine-sdk \
42+
findutils \
43+
&& su nobody -s /bin/sh -c " \
44+
export HOME=${tempDir} \
45+
&& cd ${tempDir} \
46+
&& curl -f -O https://hg.nginx.org/pkg-oss/archive/%%REVISION%%.tar.gz \
47+
&& PKGOSSCHECKSUM=\"%%PKGOSSCHECKSUM%% *%%REVISION%%.tar.gz\" \
48+
&& if [ \"\$(openssl sha512 -r %%REVISION%%.tar.gz)\" = \"\$PKGOSSCHECKSUM\" ]; then \
49+
echo \"pkg-oss tarball checksum verification succeeded!\"; \
50+
else \
51+
echo \"pkg-oss tarball checksum verification failed!\"; \
52+
exit 1; \
53+
fi \
54+
&& tar xzvf %%REVISION%%.tar.gz \
55+
&& cd pkg-oss-%%REVISION%% \
56+
&& cd alpine \
57+
&& make %%BUILDTARGET%% \
58+
&& apk index -o ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz ${tempDir}/packages/alpine/${apkArch}/*.apk \
59+
&& abuild-sign -k ${tempDir}/.abuild/abuild-key.rsa ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz \
60+
" \
61+
&& cp ${tempDir}/.abuild/abuild-key.rsa.pub /etc/apk/keys/ \
62+
&& apk del .build-deps \
63+
&& apk add -X ${tempDir}/packages/alpine/ --no-cache $nginxPackages \
64+
;; \
65+
esac \
66+
# remove checksum deps
67+
&& apk del .checksum-deps \
68+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
69+
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
70+
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
71+
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi

Dockerfile-alpine-slim.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ RUN set -x \
6161
&& tar xzvf %%REVISION%%.tar.gz \
6262
&& cd pkg-oss-%%REVISION%% \
6363
&& cd alpine \
64-
&& make base \
64+
&& make %%BUILDTARGET%% \
6565
&& apk index -o ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz ${tempDir}/packages/alpine/${apkArch}/*.apk \
6666
&& abuild-sign -k ${tempDir}/.abuild/abuild-key.rsa ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz \
6767
" \

Dockerfile-alpine.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ RUN set -x \
4141
libxslt-dev \
4242
gd-dev \
4343
geoip-dev \
44-
perl-dev \
4544
libedit-dev \
4645
bash \
4746
alpine-sdk \
@@ -60,7 +59,7 @@ RUN set -x \
6059
&& tar xzvf %%REVISION%%.tar.gz \
6160
&& cd pkg-oss-%%REVISION%% \
6261
&& cd alpine \
63-
&& make all \
62+
&& make %%BUILDTARGET%% \
6463
&& apk index -o ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz ${tempDir}/packages/alpine/${apkArch}/*.apk \
6564
&& abuild-sign -k ${tempDir}/.abuild/abuild-key.rsa ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz \
6665
" \

Dockerfile-debian-perl.template

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
FROM nginx:%%NGINX_VERSION%%
2+
3+
RUN set -x \
4+
&& apt-get update \
5+
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 ca-certificates \
6+
&& \
7+
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
8+
found=''; \
9+
for server in \
10+
hkp://keyserver.ubuntu.com:80 \
11+
pgp.mit.edu \
12+
; do \
13+
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
14+
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
15+
done; \
16+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
17+
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
18+
&& dpkgArch="$(dpkg --print-architecture)" \
19+
&& nginxPackages="%%PACKAGES%%
20+
" \
21+
&& case "$dpkgArch" in \
22+
amd64|arm64) \
23+
# arches officialy built by upstream
24+
echo "deb %%PACKAGEREPO%% %%DEBIAN_VERSION%% nginx" >> /etc/apt/sources.list.d/nginx.list \
25+
&& apt-get update \
26+
;; \
27+
*) \
28+
# we're on an architecture upstream doesn't officially build for
29+
# let's build binaries from the published source packages
30+
echo "deb-src %%PACKAGEREPO%% %%DEBIAN_VERSION%% nginx" >> /etc/apt/sources.list.d/nginx.list \
31+
\
32+
# new directory for storing sources and .deb files
33+
&& tempDir="$(mktemp -d)" \
34+
&& chmod 777 "$tempDir" \
35+
# (777 to ensure APT's "_apt" user can access it too)
36+
\
37+
# save list of currently-installed packages so build dependencies can be cleanly removed later
38+
&& savedAptMark="$(apt-mark showmanual)" \
39+
\
40+
# build .deb files from upstream's source packages (which are verified by apt-get)
41+
&& apt-get update \
42+
&& apt-get build-dep -y %%BUILDTARGET%% \
43+
&& ( \
44+
cd "$tempDir" \
45+
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
46+
apt-get source --compile %%BUILDTARGET%% \
47+
) \
48+
# we don't remove APT lists here because they get re-downloaded and removed later
49+
\
50+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
51+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
52+
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
53+
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
54+
\
55+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
56+
&& ls -lAFh "$tempDir" \
57+
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
58+
&& grep '^Package: ' "$tempDir/Packages" \
59+
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
60+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
61+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
62+
# ...
63+
# 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)
64+
&& apt-get -o Acquire::GzipIndexes=false update \
65+
;; \
66+
esac \
67+
\
68+
&& apt-get install --no-install-recommends --no-install-suggests -y \
69+
$nginxPackages \
70+
gettext-base \
71+
curl \
72+
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \
73+
\
74+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
75+
&& if [ -n "$tempDir" ]; then \
76+
apt-get purge -y --auto-remove \
77+
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
78+
fi

Dockerfile-debian.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ RUN set -x \
4848
\
4949
# build .deb files from upstream's source packages (which are verified by apt-get)
5050
&& apt-get update \
51-
&& apt-get build-dep -y $nginxPackages \
51+
&& apt-get build-dep -y %%BUILDTARGET%% \
5252
&& ( \
5353
cd "$tempDir" \
5454
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
55-
apt-get source --compile $nginxPackages \
55+
apt-get source --compile %%BUILDTARGET%% \
5656
) \
5757
# we don't remove APT lists here because they get re-downloaded and removed later
5858
\

update.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,27 @@ get_packagever() {
123123
echo ${pkg[$branch]}${suffix}
124124
}
125125

126+
get_buildtarget() {
127+
local distro="$1"
128+
case "$distro" in
129+
alpine-slim)
130+
echo base
131+
;;
132+
alpine-perl)
133+
echo module-perl
134+
;;
135+
alpine)
136+
echo module-geoip module-image-filter module-njs module-xslt
137+
;;
138+
debian)
139+
echo "\$nginxPackages"
140+
;;
141+
debian-perl)
142+
echo "nginx-module-perl=\${NGINX_VERSION}-\${PKG_RELEASE}"
143+
;;
144+
esac
145+
}
146+
126147
generated_warning() {
127148
cat <<__EOF__
128149
#
@@ -143,7 +164,7 @@ for branch in "${branches[@]}"; do
143164

144165
[ -d "$dir" ] || continue
145166

146-
template="Dockerfile-${variant%-perl}.template"
167+
template="Dockerfile-${variant}.template"
147168
{
148169
generated_warning
149170
cat "$template"
@@ -159,6 +180,7 @@ for branch in "${branches[@]}"; do
159180
packagerepo=$(get_packagerepo "$variant" "$branch")
160181
packages=$(get_packages "$variant" "$branch")
161182
packagever=$(get_packagever "$variant" "$branch")
183+
buildtarget=$(get_buildtarget "$variant")
162184

163185
sed -i.bak \
164186
-e 's,%%ALPINE_VERSION%%,'"$alpinever"',' \
@@ -170,13 +192,14 @@ for branch in "${branches[@]}"; do
170192
-e 's,%%PACKAGEREPO%%,'"$packagerepo"',' \
171193
-e 's,%%REVISION%%,'"$revver"',' \
172194
-e 's,%%PKGOSSCHECKSUM%%,'"$pkgosschecksumver"',' \
195+
-e 's,%%BUILDTARGET%%,'"$buildtarget"',' \
173196
"$dir/Dockerfile"
174197

175198
done
176199

177200
for variant in \
178201
alpine-slim \
179-
debian{,-perl}; do \
202+
debian; do \
180203
echo "$branch: $variant entrypoint scripts"
181204
dir="$branch/$variant"
182205
cp -a entrypoint/*.sh "$dir/"

0 commit comments

Comments
 (0)