Files
eCommerce-backend/Dockerfile

37 lines
861 B
Docker

# Use node-alpine but add necessary build tools
FROM node:20-alpine AS builder
# 1. Install openssl and libc6-compat (required for Prisma on Alpine)
RUN apk add --no-cache openssl libc6-compat
WORKDIR /app
COPY package*.json ./
# 2. Install dependencies (make sure prisma is in your package.json)
RUN npm ci
COPY . .
# 3. Generate Prisma Client during build time
# This bakes the engine into the image so 'npx' doesn't try to download it later
RUN npx prisma generate
RUN npm run build
# --- Runner Stage ---
FROM node:20-alpine AS runner
# 4. Must also install openssl in the runner stage!
RUN apk add --no-cache openssl libc6-compat
WORKDIR /app
# Copy everything from builder
COPY --from=builder /app /app
EXPOSE 3000
# This is the command that the migration service or backend will use
CMD ["npm", "start"]