Skip to content

Instantly share code, notes, and snippets.

@LeopoldLabs
Last active October 6, 2024 12:03
Show Gist options
  • Save LeopoldLabs/ba18f80cf77b0b31f1d8ef7e244f0252 to your computer and use it in GitHub Desktop.
Save LeopoldLabs/ba18f80cf77b0b31f1d8ef7e244f0252 to your computer and use it in GitHub Desktop.
Sveltekit Dockerfile
FROM node:20-alpine AS base
FROM base AS dependencies
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm
RUN pnpm i --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 svelte
COPY --from=builder --chown=svelte:nodejs /app/static ./static
COPY --from=builder --chown=svelte:nodejs /app/build ./build
COPY --from=builder --chown=svelte:nodejs /app/package.json ./package.json
USER svelte
EXPOSE 3000
ENV PORT=3000
CMD ["node", "build"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment