Skip to content

Commit dbc1745

Browse files
Merge pull request #1923 from yehonatanz/remove-unused-openssl-headers
Remove unused openssl headers
2 parents 18b91b9 + 924180b commit dbc1745

File tree

7 files changed

+63
-49
lines changed

7 files changed

+63
-49
lines changed

18/bookworm-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 18.18.2
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

18/bullseye-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 18.18.2
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

18/buster-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 18.18.2
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

20/bookworm-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 20.9.0
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

20/bullseye-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 20.9.0
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

20/buster-slim/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 20.9.0
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -46,6 +46,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
4646
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
4747
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
4848
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
49+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
50+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
4951
&& apt-mark auto '.*' > /dev/null \
5052
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
5153
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

Dockerfile-slim.template

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ RUN groupadd --gid 1000 node \
55

66
ENV NODE_VERSION 0.0.0
77

8-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
8+
RUN ARCH= OPENSSL_ARCH= && dpkgArch="$(dpkg --print-architecture)" \
99
&& case "${dpkgArch##*-}" in \
10-
amd64) ARCH='x64';; \
11-
ppc64el) ARCH='ppc64le';; \
12-
s390x) ARCH='s390x';; \
13-
arm64) ARCH='arm64';; \
14-
armhf) ARCH='armv7l';; \
15-
i386) ARCH='x86';; \
10+
amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \
11+
ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \
12+
s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \
13+
arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \
14+
armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \
15+
i386) ARCH='x86' OPENSSL_ARCH='linux-elf';; \
1616
*) echo "unsupported architecture"; exit 1 ;; \
1717
esac \
1818
&& set -ex \
@@ -36,6 +36,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
3636
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3737
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
3838
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
39+
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
40+
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
3941
&& apt-mark auto '.*' > /dev/null \
4042
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
4143
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \

0 commit comments

Comments
 (0)