Dockerize Svelte with Prisma

Hi! Is there any example or recommendation on how to create a Dockerfile for a Svelte 5 app using Prisma for Supabase? I keep getting the error: /app/node_modules/.pnpm/@[email protected]/node_modules/.prisma/client/default.js:43 throw new Error('@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.'); Mi current Dockerfile is: FROM node:22-alpine AS builder WORKDIR /app COPY package*.json . RUN npm install -g pnpm RUN pnpm install COPY . . RUN pnpx prisma generate RUN pnpm run build RUN pnpm prune --prod FROM node:22-alpine WORKDIR /app COPY --from=builder /app/build build/ COPY --from=builder /app/node_modules node_modules/ COPY --from=builder /app/prisma prisma/ COPY package.json . EXPOSE 3000 ENV NODE_ENV=production CMD [ "node", "build" ]
1 Reply
Nurul
Nurul2w ago
Hi @Juanma 🐼 👋 Can you try including prisma generate command in your production step?
# Stage 1: Builder
FROM node:22-alpine AS builder
WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install -g pnpm
RUN pnpm install

# Copy project files
COPY . .

# Generate Prisma client
RUN pnpx prisma generate

# Build Svelte app
RUN pnpm run build

# Prune dev dependencies to reduce final image size
RUN pnpm prune --prod

# Stage 2: Production
FROM node:22-alpine
WORKDIR /app

# Copy necessary files and folders from the builder
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY --from=builder /app/prisma prisma/
COPY package.json .

# Generate Prisma client in production environment
RUN pnpx prisma generate

# Set environment variables and expose port
EXPOSE 3000
ENV NODE_ENV=production

# Run the application
CMD ["node", "build"]
# Stage 1: Builder
FROM node:22-alpine AS builder
WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install -g pnpm
RUN pnpm install

# Copy project files
COPY . .

# Generate Prisma client
RUN pnpx prisma generate

# Build Svelte app
RUN pnpm run build

# Prune dev dependencies to reduce final image size
RUN pnpm prune --prod

# Stage 2: Production
FROM node:22-alpine
WORKDIR /app

# Copy necessary files and folders from the builder
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY --from=builder /app/prisma prisma/
COPY package.json .

# Generate Prisma client in production environment
RUN pnpx prisma generate

# Set environment variables and expose port
EXPOSE 3000
ENV NODE_ENV=production

# Run the application
CMD ["node", "build"]
Want results from more Discord servers?
Add your server