Skip to content

Commit 21f851a

Browse files
nbudinclaude
andcommitted
Remove xz-utils from production image
Install it temporarily alongside the other apt packages, extract the node tarball, then purge it in the same layer so it doesn't persist. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent edf4444 commit 21f851a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,21 @@ ENV REVISION ${REVISION}
6565

6666
USER root
6767
# iproute2, curl: generally useful network utilities that don't take much space
68-
# xz-utils: needed to extract node tarball
6968
# libvips43, poppler-utils: activestorage dependencies
7069
# libjemalloc2: more efficient memory allocation in Ruby and Node
7170
# shared-mime-info: Rails dependency
7271
# libpq5: pg gem dependency
73-
RUN apt-get update && apt-get install -y --no-install-recommends iproute2 curl libvips42 poppler-utils xz-utils libjemalloc2 shared-mime-info libpq5 gosu && rm -rf /var/lib/apt/lists/*
72+
# xz-utils: installed temporarily to extract the node tarball, then removed
73+
RUN apt-get update \
74+
&& apt-get install -y --no-install-recommends iproute2 curl libvips42 poppler-utils xz-utils libjemalloc2 shared-mime-info libpq5 gosu \
75+
&& mkdir /opt/node \
76+
&& cd /opt/node \
77+
&& curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-$(echo ${TARGETARCH} | sed 's/amd64/x64/').tar.xz | tar xJ --strip-components=1 \
78+
&& rm -rf /opt/node/include /opt/node/lib/node_modules \
79+
&& apt-get purge -y xz-utils \
80+
&& apt-get autoremove -y \
81+
&& rm -rf /var/lib/apt/lists/*
7482
RUN useradd -ms $(which bash) www
75-
RUN mkdir /opt/node && \
76-
cd /opt/node && \
77-
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-$(echo ${TARGETARCH} | sed 's/amd64/x64/').tar.xz | tar xJ --strip-components=1 && \
78-
rm -rf /opt/node/include /opt/node/lib/node_modules
7983
ENV PATH="/opt/node/bin:$PATH"
8084

8185
# Set up chamber for SSM-based secrets management

0 commit comments

Comments
 (0)