50 lines
1.1 KiB
Docker
50 lines
1.1 KiB
Docker
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy root configs
|
|
COPY package*.json ./
|
|
COPY tsconfig.json ./
|
|
COPY tsconfig.base.json ./
|
|
|
|
# Copy packages
|
|
COPY apps/api/package*.json ./apps/api/
|
|
COPY shared/package*.json ./shared/
|
|
|
|
# Install dependencies (using npm ci for better builds)
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY apps/api ./apps/api
|
|
COPY shared ./shared
|
|
|
|
# Generate Prisma client
|
|
WORKDIR /app/apps/api
|
|
COPY apps/api/prisma.config.ts ./
|
|
RUN npx prisma generate
|
|
|
|
# Build the app
|
|
RUN npm run build
|
|
|
|
# ---
|
|
FROM node:20-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy build artifacts and necessary files
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/apps/api/dist ./apps/api/dist
|
|
COPY --from=builder /app/apps/api/package.json ./apps/api/package.json
|
|
COPY --from=builder /app/apps/api/prisma ./apps/api/prisma
|
|
COPY --from=builder /app/apps/api/prisma.config.ts ./apps/api/prisma.config.ts
|
|
COPY --from=builder /app/shared/dist ./shared/dist
|
|
COPY --from=builder /app/shared/package.json ./shared/package.json
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /app/apps/api
|
|
CMD npx prisma migrate deploy && node dist/main
|