fix docker setup

This commit is contained in:
2025-12-25 15:24:54 +01:00
parent 3ceb837e15
commit f1c01b73ad
18 changed files with 419 additions and 132 deletions

View File

@@ -2,20 +2,21 @@ FROM node:20-alpine AS builder
WORKDIR /app
# Copy root package.json and install dependencies (for monorepo)
# Copy package manifests and install dependencies (incl. workspaces)
COPY package.json package-lock.json ./
RUN npm ci
COPY apps/api/package.json apps/api/package.json
RUN npm ci --workspaces --include-workspace-root
# Copy apps/api and packages for building
# Copy sources for building (monorepo)
COPY apps/api apps/api/
COPY packages core/
COPY core core/
COPY adapters adapters/
COPY apps/api/tsconfig.json apps/api/
COPY tsconfig.base.json ./
# Build the NestJS application (ensuring correct workspace context)
# Run from the root workspace context
# RUN node ./node_modules/@nestjs/cli/bin/nest.js build --workspace=api # Not needed, npm run handles it
RUN npm run build --workspace=api
# Build shared libs + API (so runtime imports resolve)
RUN npx tsc -b core/tsconfig.json adapters/tsconfig.json
RUN npm run build --workspace=@gridpilot/api
# Production stage: slim image with only production dependencies
@@ -34,8 +35,9 @@ RUN npm ci --omit=dev
# Copy built application from builder stage
COPY --from=builder /app/apps/api/dist ./apps/api/dist
# Copy packages (needed for runtime dependencies)
COPY --from=builder /app/packages ./packages
# Provide runtime module resolution for @core/* and @adapters/*
COPY --from=builder /app/dist/core /app/node_modules/@core
COPY --from=builder /app/dist/adapters /app/node_modules/@adapters
EXPOSE 3000