-
Notifications
You must be signed in to change notification settings - Fork 2
Revert "build(docker): Switch to Docker Hardened Images (DHI)" #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,38 @@ | ||
| FROM us-docker.pkg.dev/sentryio/dhi/node:24-debian13-dev AS builder | ||
| FROM node:24.14.0 AS builder | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| COPY package.json yarn.lock ./ | ||
| COPY package.json yarn.lock . | ||
| RUN yarn install --frozen-lockfile | ||
|
|
||
| COPY tsconfig.json . | ||
| COPY src src | ||
| RUN yarn build | ||
|
|
||
| # Drop devDependencies from node_modules for the runtime image | ||
| RUN yarn install --frozen-lockfile --production | ||
| FROM node:24.14.0-slim | ||
|
|
||
| # canvas 3.x bundles its graphics libs (libcairo, libpango, etc.) but its | ||
| # bundled librsvg/glib still need a few basic system libs absent from the | ||
| # minimal runtime image. Collect them here to copy in without pulling the | ||
| # entire -dev system into the runtime. | ||
| RUN mkdir -p /canvas-sys-libs && \ | ||
| find /lib /usr/lib -maxdepth 3 \( \ | ||
| -name "libz.so.1*" -o \ | ||
| -name "libexpat.so.1*" -o \ | ||
| -name "libuuid.so.1*" -o \ | ||
| -name "liblzma.so.5*" \ | ||
| \) -exec cp -P --parents {} /canvas-sys-libs/ \; | ||
| ENV NODE_ENV=production | ||
|
|
||
| RUN npm install -g npm@latest \ | ||
| && npm cache clean --force | ||
|
|
||
| FROM us-docker.pkg.dev/sentryio/dhi/node:24-debian13 | ||
|
|
||
| ENV NODE_ENV=production | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| libcairo2-dev \ | ||
| libpango1.0-dev \ | ||
| libjpeg-dev \ | ||
| libgif-dev \ | ||
| librsvg2-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /usr/src/app | ||
|
|
||
| COPY package.json ./ | ||
| COPY package.json yarn.lock ./ | ||
| RUN yarn install --frozen-lockfile \ | ||
| && yarn cache clean | ||
|
|
||
| COPY fonts fonts | ||
| COPY --from=builder /build/node_modules node_modules | ||
| COPY --from=builder /build/lib lib | ||
| COPY --from=builder /canvas-sys-libs/ / | ||
| COPY --from=builder lib lib | ||
|
|
||
| RUN ["node", "lib/index.js", "--help"] | ||
| RUN node lib/index.js --help | ||
|
|
||
| EXPOSE 9090/tcp | ||
| CMD ["node", "./lib/index.js", "server", "9090"] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing WORKDIR causes massive image bloat via symlink
Medium Severity
The builder stage has no
WORKDIR, so the default/is used. Thetscbuild outputs to./lib, which resolves to/lib— a symlink to/usr/libon Debian bookworm (usrmerge). Docker'sCOPY --from=builder lib libfollows symlinks, so it copies the entire/usr/libdirectory (system libraries + build output) into the runtime image. The removed DHI version hadWORKDIR /buildto avoid this. Adding aWORKDIRto the builder stage would prevent copying hundreds of megabytes of unnecessary system libraries.Additional Locations (1)
Dockerfile#L32-L33