Skip to content

Instantly share code, notes, and snippets.

@geekygeeky
Created May 31, 2025 05:24
Show Gist options
  • Select an option

  • Save geekygeeky/d6e41362ff3c863ab243e3450eb453f1 to your computer and use it in GitHub Desktop.

Select an option

Save geekygeeky/d6e41362ff3c863ab243e3450eb453f1 to your computer and use it in GitHub Desktop.
PNPM docker file
# Stage 1: Build Stage
FROM node:23 AS builder
WORKDIR /app
# Install pnpm globally
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy package files and install dependencies
COPY pnpm-lock.yaml package.json ./
RUN pnpm install
# Copy the rest of your application source code
COPY . .
# Compile TypeScript to JavaScript
RUN pnpm run build
# Generate Prisma client (optional if you're using Prisma)
# RUN pnpm prisma generate
# Prune devDependencies
RUN pnpm prune --prod
# Stage 2: Production Stage
FROM node:23-alpine AS runner
WORKDIR /app
# Install pnpm globally
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy production files
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "dist/app.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment