Merge pull request #44 from Jellyfrog/feat/dockerfile

Optimize Dockerfile with multi-stage build
This commit is contained in:
Anton Roslund 2025-10-05 20:00:11 +02:00 committed by GitHub
commit 737eeb3120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,15 +1,29 @@
FROM node:lts-alpine
WORKDIR /app
FROM node:lts-alpine AS build
RUN apk add --no-cache openssl
WORKDIR /app
# Copy only package files and install deps
# This layer will be cached as long as package*.json don't change
COPY package*.json package-lock.json* ./
RUN npm ci
RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev
# Copy the rest of the source
# Copy the rest of your source
COPY . .
# Pre-generate prisma client
RUN node_modules/.bin/prisma generate
FROM node:lts-alpine
RUN apk add --no-cache openssl
USER node:node
WORKDIR /app
COPY --from=build --chown=node:node /app .
EXPOSE 8080