Skip to content

Commit 0453a07

Browse files
committed
Iterate over multiple GPG servers to try and fetch the GPG key.
1 parent bec2d21 commit 0453a07

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

mainline/alpine/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,18 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
7070
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
7171
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \
7272
&& export GNUPGHOME="$(mktemp -d)" \
73-
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEYS" \
74-
&& gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
73+
&& found=''; \
74+
for server in \
75+
ha.pool.sks-keyservers.net \
76+
hkp://keyserver.ubuntu.com:80 \
77+
hkp://p80.pool.sks-keyservers.net:80 \
78+
pgp.mit.edu \
79+
; do \
80+
echo "Fetching GPG key $GPG_KEYS from $server"; \
81+
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \
82+
done; \
83+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \
84+
gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
7585
&& rm -r "$GNUPGHOME" nginx.tar.gz.asc \
7686
&& mkdir -p /usr/src \
7787
&& tar -zxC /usr/src -f nginx.tar.gz \

mainline/jessie/Dockerfile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@ MAINTAINER NGINX Docker Maintainers "[email protected]"
44

55
ENV NGINX_VERSION 1.11.11-1~jessie
66

7-
RUN apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
8-
&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
7+
RUN set -e; \
8+
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
9+
found=''; \
10+
for server in \
11+
ha.pool.sks-keyservers.net \
12+
hkp://keyserver.ubuntu.com:80 \
13+
hkp://p80.pool.sks-keyservers.net:80 \
14+
pgp.mit.edu \
15+
; do \
16+
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
17+
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
18+
done; \
19+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
20+
exit 0
21+
22+
RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
923
&& apt-get update \
1024
&& apt-get install --no-install-recommends --no-install-suggests -y \
1125
ca-certificates \

stable/alpine/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,18 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
6767
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
6868
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \
6969
&& export GNUPGHOME="$(mktemp -d)" \
70-
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEYS" \
71-
&& gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
70+
&& found=''; \
71+
for server in \
72+
ha.pool.sks-keyservers.net \
73+
hkp://keyserver.ubuntu.com:80 \
74+
hkp://p80.pool.sks-keyservers.net:80 \
75+
pgp.mit.edu \
76+
; do \
77+
echo "Fetching GPG key $GPG_KEYS from $server"; \
78+
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \
79+
done; \
80+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \
81+
gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
7282
&& rm -r "$GNUPGHOME" nginx.tar.gz.asc \
7383
&& mkdir -p /usr/src \
7484
&& tar -zxC /usr/src -f nginx.tar.gz \

stable/jessie/Dockerfile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@ MAINTAINER NGINX Docker Maintainers "[email protected]"
44

55
ENV NGINX_VERSION 1.10.3-1~jessie
66

7-
RUN apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
8-
&& echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list \
7+
RUN set -e; \
8+
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
9+
found=''; \
10+
for server in \
11+
ha.pool.sks-keyservers.net \
12+
hkp://keyserver.ubuntu.com:80 \
13+
hkp://p80.pool.sks-keyservers.net:80 \
14+
pgp.mit.edu \
15+
; do \
16+
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
17+
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
18+
done; \
19+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
20+
exit 0
21+
22+
RUN echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list \
923
&& apt-get update \
1024
&& apt-get install --no-install-recommends --no-install-suggests -y \
1125
ca-certificates \

0 commit comments

Comments
 (0)