Skip to content

Commit 48c743a

Browse files
committed
fixup! chore: switch to official release-keys repo to verify Node.js
1 parent 0222008 commit 48c743a

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

Dockerfile-alpine.template

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ RUN addgroup -g 1000 node \
3737
make \
3838
python3 \
3939
py-setuptools \
40-
&& export PUBRING="$(mktemp)" \
41-
&& curl -fsSLo "$PUBRING" --compressed https://github.com/nodejs/release-keys/raw/HEAD/gpg-only-active-keys/pubring.kbx \
40+
&& export GNUPGHOME="$(mktemp -d)" \
41+
&& (cd "$GNUPGHOME" && curl -fsSLO --compressed "${NODEJS_KEYRING_URL}" && echo "${NODEJS_KEYRING_HASH}" | sha256sum -c) \
4242
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
4343
&& curl -fsSL --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
44-
| gpgv --keyring="$PUBRING" --output - \
44+
| gpgv --keyring="$GNUPGHOME/pubring.kbx" --output - \
4545
| grep " node-v$NODE_VERSION.tar.xz\$"
4646
| sha256sum -c - \
47+
&& rm -rf "$GNUPGHOME" \
4748
&& tar -xJf "node-v$NODE_VERSION.tar.xz" \
4849
&& cd "node-v$NODE_VERSION" \
4950
&& ./configure \
@@ -52,7 +53,7 @@ RUN addgroup -g 1000 node \
5253
&& apk del .build-deps-full \
5354
&& cd .. \
5455
&& rm -Rf "node-v$NODE_VERSION" \
55-
&& rm "$PUBRING" "node-v$NODE_VERSION.tar.xz"; \
56+
&& rm "node-v$NODE_VERSION.tar.xz"; \
5657
fi \
5758
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
5859
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451

Dockerfile-debian.template

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
1515
i386) ARCH='x86';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
18-
&& export PUBRING="$(mktemp)" \
18+
&& export GNUPGHOME="$(mktemp -d)" \
1919
&& set -exo pipefail \
20-
&& curl -fsSLo "$PUBRING" --compressed https://github.com/nodejs/release-keys/raw/HEAD/gpg-only-active-keys/pubring.kbx \
20+
&& (cd "$GNUPGHOME" && curl -fsSLO --compressed "${NODEJS_KEYRING_URL}" && echo "${NODEJS_KEYRING_HASH}" | sha256sum -c) \
2121
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
2222
&& curl -fsSL --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
23-
| gpgv --keyring="$PUBRING" --output - \
23+
| gpgv --keyring="$GNUPGHOME/pubring.kbx" --output - \
2424
| grep " node-v$NODE_VERSION.tar.xz\$"
2525
| sha256sum -c - \
26+
&& rm -rf "$GNUPGHOME" \
2627
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
27-
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" "$PUBRING" \
28+
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
2829
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
2930
# smoke tests
3031
&& node --version \

Dockerfile-slim.template

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
1919
# libatomic1 for arm
2020
&& apt-get update && apt-get install -y ca-certificates curl wget gpgv dirmngr xz-utils libatomic1 --no-install-recommends \
2121
&& rm -rf /var/lib/apt/lists/* \
22-
&& export PUBRING="$(mktemp)" \
22+
&& export GNUPGHOME="$(mktemp -d)" \
2323
&& set -exo pipefail \
24-
&& curl -fsSLo "$PUBRING" --compressed https://github.com/nodejs/release-keys/raw/HEAD/gpg-only-active-keys/pubring.kbx \
24+
&& (cd "$GNUPGHOME" && curl -fsSLO --compressed "${NODEJS_KEYRING_URL}" && echo "${NODEJS_KEYRING_HASH}" | sha256sum -c) \
2525
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
2626
&& curl -fsSL --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
27-
| gpgv --keyring="$PUBRING" --output - \
27+
| gpgv --keyring="$GNUPGHOME/pubring.kbx" --output - \
2828
| grep " node-v$NODE_VERSION.tar.xz\$"
2929
| sha256sum -c - \
30+
&& rm -rf "$GNUPGHOME" \
3031
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
31-
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" "$PUBRING" \
32+
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
3233
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
3334
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
3435
&& apt-mark auto '.*' > /dev/null \

update-keys.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh -ex
2+
3+
KEYRING_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/nodejs/release-keys/raw/HEAD/gpg-only-active-keys/pubring.kbx)
4+
TMP_DIR=$(mktemp -d)
5+
(cd "$TMP_DIR" && curl -fsSO "$KEYRING_URL" && sha256sum pubring.kbx) > keys/nodejs.shasum
6+
echo "$KEYRING_URL" > keys/nodejs.url
7+
rm -r "$TMP_DIR"

update.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ function update_node_version() {
139139
'
140140

141141
# Add GPG keys
142-
for key_type in "yarn"; do
143-
while read -r line; do
144-
pattern='"\$\{'$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')'_KEYS\[@\]\}"'
145-
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}-tmp"
146-
done < "keys/${key_type}.keys"
147-
sed -Ei -e "/${pattern}/d" "${dockerfile}-tmp"
148-
done
142+
key_type="yarn"
143+
while read -r line; do
144+
pattern='"\$\{'$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')'_KEYS\[@\]\}"'
145+
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}-tmp"
146+
done < "keys/${key_type}.keys"
147+
sed -Ei -e "/${pattern}/d" "${dockerfile}-tmp"
148+
149+
# Add Node.js keyring URL and hash
150+
sed -i -e "s#\${NODEJS_KEYRING_URL}#$(< keys/nodejs.url)#" -e "s/\${NODEJS_KEYRING_HASH}/$(< keys/nodejs.shasum)/" "${dockerfile}-tmp"
149151

150152
if is_alpine "${variant}"; then
151153
alpine_version="${variant#*alpine}"

0 commit comments

Comments
 (0)