Open
Description
I was looking a bit into https://pnpm.io/docker and was wondering if not the image could be made smaller by leaving out the app code.
The first docker-file would be changed as following:
diff --git forkSrcPrefix/backend/Dockerfile forkDstPrefix/backend/Dockerfile
index b04e176fef6ca3f709e2db8149f867d003a5c4db..a1ce67142ccf1a33ae1cffc1b5b6a891da449730 100644
--- forkSrcPrefix/backend/Dockerfile
+++ forkDstPrefix/backend/Dockerfile
@@ -1,6 +1,4 @@
-ARG NODE_VERSION=UNDEFINED
-
-FROM node:${NODE_VERSION}-slim AS base
+FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
@@ -14,8 +12,8 @@ FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
-FROM node:${NODE_VERSION}-slim
+FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 8000
-CMD [ "npm", "start" ]
+CMD [ "pnpm", "start" ]
The reason for this is that you do not get things that come along with running corepack
, the app code, and for the start-command likely can be run via npm
.
Metadata
Assignees
Labels
No labels
Activity