Skip to content

Commit 5e1d851

Browse files
chore: remove unused npm and clean up ctags build artifacts in Docker image (#1119)
The Node.js base image bundles npm with transitive dependencies (minimatch, tar, picomatch) that Trivy flags as vulnerable. Since we use Yarn exclusively, npm is never invoked at runtime. Removing it eliminates these false positives and reduces image size. Also clean up the ctags source tree left in /tmp after the install script runs (~109MB of build artifacts). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 02becc4 commit 5e1d851

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ ENV SOURCEBOT_LOG_LEVEL=info
183183
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget supervisor uuidgen curl perl jq redis postgresql16 postgresql16-contrib openssl util-linux unzip && \
184184
apk upgrade --no-cache
185185

186+
# Remove npm (unused — we use Yarn). The Node.js base image bundles npm
187+
# with its own transitive dependencies (minimatch, tar, picomatch, etc.)
188+
# that Trivy flags as vulnerable. Since npm is never invoked at runtime,
189+
# removing it eliminates these false positives and reduces image size.
190+
RUN rm -rf /usr/local/lib/node_modules/npm && \
191+
rm -rf /usr/local/bin/npm && \
192+
rm -rf /usr/local/bin/npx && \
193+
rm -rf /root/.npm && \
194+
rm -rf /root/.node-gyp
195+
186196
ARG UID=1500
187197
ARG GID=1500
188198

@@ -202,7 +212,9 @@ COPY .yarn ./.yarn
202212

203213
# Configure zoekt
204214
COPY vendor/zoekt/install-ctags-alpine.sh .
205-
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh
215+
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh && \
216+
# Clean up ctags build artifacts
217+
rm -rf /tmp/*
206218
RUN mkdir -p ${DATA_CACHE_DIR}
207219
COPY --from=zoekt-builder \
208220
/cmd/zoekt-git-index \

0 commit comments

Comments
 (0)