From 584049dd9db91dad752e306d9dcd441e342e5512 Mon Sep 17 00:00:00 2001 From: scambier Date: Thu, 12 Dec 2024 13:22:26 +0100 Subject: [PATCH] Add Dofckerfile sveltekit node.md --- Dofckerfile sveltekit node.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Dofckerfile sveltekit node.md diff --git a/Dofckerfile sveltekit node.md b/Dofckerfile sveltekit node.md new file mode 100644 index 0000000..df5584e --- /dev/null +++ b/Dofckerfile sveltekit node.md @@ -0,0 +1,32 @@ +This Dockerfile maximizes layer caching through `pnpm fetch` and multi-step dependencies installation. + +See https://pnpm.io/docker#example-3-build-on-cicd + +```dockerfile +FROM node:22-alpine AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +WORKDIR /app + +# Fetch dependencies +FROM base AS install +COPY pnpm-lock.yaml ./ +RUN pnpm fetch + +COPY . . +# Install production dependencies +RUN pnpm install -r --offline --prod --frozen-lockfile + +# Install dev dependencies (needed for the build step) +RUN pnpm install -r --offline --frozen-lockfile + +# Build +ENV NODE_ENV=production +RUN pnpm build + +ENTRYPOINT ["node", "build"] +EXPOSE 3000 +``` + +You can safely clean with `docker builder prune --f` after that. It won't touch the cache. \ No newline at end of file