Skip to content

Commit

Permalink
build: multistage docker
Browse files Browse the repository at this point in the history
  • Loading branch information
acifani committed Sep 20, 2024
1 parent d412e62 commit 558cb8d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
FROM node:20-slim
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

WORKDIR /usr/src/app
COPY . /usr/src/app
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

RUN corepack enable && pnpm install && pnpm build && pnpm prune --prod
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

CMD ["pnpm", "start:docker"]
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist

CMD [ "pnpm", "start:docker" ]

0 comments on commit 558cb8d

Please sign in to comment.