Skip to content

Commit 0c5911c

Browse files
authored
Update distroless image (#474)
* move esbuild plugin to dev dependency * update Dockerfile now moves 'node_modules' installed with only runtime deps to the final image
1 parent 3178e47 commit 0c5911c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ RUN apk add pnpm
44

55
COPY . .
66

7-
RUN pnpm install && pnpm run build
8-
RUN pnpm install --ignore-scripts vite-express
7+
RUN pnpm install
8+
RUN pnpm run build
9+
# Delete node_modules that contain dev deps and only install runtime deps
10+
# in the version that is copied to the final output
11+
RUN rm -rf node_modules/
12+
RUN pnpm install -P --ignore-scripts
913

1014
FROM gcr.io/distroless/nodejs20-debian12:debug-nonroot
1115

1216
COPY --from=builder --chown=nonroot:nonroot --chmod=777 /usr/local/app/dist /app/dist/
1317
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /usr/local/app/node_modules /app/node_modules
14-
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /usr/local/app/package*.json /usr/local/app/server.js /app/
18+
COPY --from=builder --chown=nonroot:nonroot --chmod=444 /usr/local/app/package*.json /app/
19+
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /usr/local/app/server.js /app/
1520

1621
WORKDIR /app
1722
ENV NODE_ENV=production

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"@effect/platform": "^0.70.7",
2020
"@emotion/react": "^11.14.0",
2121
"@emotion/styled": "^11.14.0",
22-
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
2322
"@mui/material": "^5.17.1",
2423
"@statisticsnorway/ssb-component-library": "^2.4.9",
2524
"body-parser": "^1.20.3",
@@ -45,6 +44,7 @@
4544
"zustand": "^5.0.3"
4645
},
4746
"devDependencies": {
47+
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
4848
"@eslint/compat": "^1.2.8",
4949
"@eslint/eslintrc": "^3.3.1",
5050
"@eslint/js": "^9.25.1",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)