Add Dockerfile SvelteKit Node.md
This commit is contained in:
parent
559d10c561
commit
a3e418a575
32
Dockerfile SvelteKit Node.md
Normal file
32
Dockerfile SvelteKit Node.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
This Dockerfile maximizes layer caching usage for SvelteKit apps (node adapter).
|
||||||
|
|
||||||
|
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 --offline --prod --frozen-lockfile
|
||||||
|
|
||||||
|
# Install dev dependencies (needed for the build step)
|
||||||
|
RUN pnpm install --offline --frozen-lockfile
|
||||||
|
|
||||||
|
# Build the app
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
ENTRYPOINT ["node", "build"]
|
||||||
|
EXPOSE 3000
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then safely execute `docker builder --prune -f` to clean without destroying the cache.
|
Loading…
Reference in New Issue
Block a user