36 lines
1.1 KiB
Docker
36 lines
1.1 KiB
Docker
# --- STAGE 1: Base & Dependencies ---
|
|
FROM node:20-alpine AS base
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
WORKDIR /app
|
|
|
|
# Copy lockfiles and workspace configs
|
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json turbo.json ./
|
|
# Copy all package.jsons to allow pnpm to link workspaces
|
|
COPY apps/api/package.json ./apps/api/
|
|
COPY apps/web/package.json ./apps/web/
|
|
COPY packages/shared/package.json ./packages/shared/
|
|
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# --- STAGE 2: Build ---
|
|
FROM base AS build
|
|
COPY . .
|
|
# This runs 'turbo run build' which should create 'dist' in both apps
|
|
RUN pnpm turbo run build
|
|
|
|
# --- STAGE 3: Runner (The tiny production image) ---
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# IMPORTANT: We copy from 'build' stage, not 'base'
|
|
# We check if the folders exist before copying to avoid the error you saw
|
|
COPY --from=build /app/apps/api/dist ./api
|
|
COPY --from=build /app/apps/web/dist ./web-dist
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/packages/shared ./packages/shared
|
|
|
|
EXPOSE 3000
|
|
# Update this path to wherever your compiled Fastify entry point is
|
|
CMD ["node", "api/index.js"] |