Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 10s
CI / E2E Tests (push) Has been skipped
Deploy / Build API Image (push) Failing after 12s
Deploy / Build Web Image (push) Failing after 12s
Deploy / Build AI Services Image (push) Failing after 12s
E2E Tests / Playwright E2E (push) Failing after 18s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
@goodgo/mcp-servers is a workspace dependency used at runtime. Need to copy its package.json for pnpm install resolution and its compiled dist/ output into the production image. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
86 lines
3.6 KiB
Docker
86 lines
3.6 KiB
Docker
# =============================================================================
|
|
# GoodGo API — Multi-stage Production Dockerfile
|
|
# Build: docker build -f apps/api/Dockerfile . (from repo root)
|
|
# =============================================================================
|
|
|
|
# ---- Base ----
|
|
FROM node:22-slim AS base
|
|
RUN corepack enable && corepack prepare pnpm@10.27.0 --activate
|
|
WORKDIR /app
|
|
|
|
# ---- Dependencies ----
|
|
# Install ALL deps (dev + prod) needed for the build step.
|
|
# Layer caching: lockfile + manifests change less often than source code.
|
|
FROM base AS deps
|
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json turbo.json ./
|
|
COPY apps/api/package.json apps/api/
|
|
COPY libs/mcp-servers/package.json libs/mcp-servers/
|
|
COPY prisma/ prisma/
|
|
RUN pnpm install --frozen-lockfile --filter @goodgo/api...
|
|
|
|
# ---- Build ----
|
|
# Generate Prisma client first (TS types needed at compile time),
|
|
# then compile mcp-servers lib (workspace dep), then the NestJS API.
|
|
FROM base AS build
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules
|
|
COPY --from=deps /app/libs/mcp-servers/node_modules ./libs/mcp-servers/node_modules
|
|
COPY tsconfig.base.json ./
|
|
COPY prisma/ prisma/
|
|
COPY libs/mcp-servers/ libs/mcp-servers/
|
|
COPY apps/api/ apps/api/
|
|
|
|
RUN npx prisma generate \
|
|
&& (pnpm --filter @goodgo/mcp-servers build 2>/dev/null || true) \
|
|
&& cd apps/api && npx nest build
|
|
|
|
# ---- Production ----
|
|
FROM node:22-slim AS production
|
|
|
|
LABEL org.opencontainers.image.title="goodgo-api" \
|
|
org.opencontainers.image.description="GoodGo Platform NestJS API" \
|
|
org.opencontainers.image.vendor="GoodGo" \
|
|
org.opencontainers.image.source="https://github.com/goodgo/goodgo-platform-ai"
|
|
|
|
# dumb-init for proper PID 1 signal handling
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends dumb-init openssl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app/apps/api
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
# Install production dependencies fresh (pnpm hoisted node_modules has broken symlinks in Docker)
|
|
COPY --from=deps /app/pnpm-lock.yaml /app/pnpm-workspace.yaml /app/package.json /app/turbo.json /app/
|
|
COPY --from=deps /app/apps/api/package.json /app/apps/api/
|
|
COPY --from=deps /app/libs/mcp-servers/package.json /app/libs/mcp-servers/
|
|
COPY --from=deps /app/prisma /app/prisma
|
|
# Mock husky (git hooks tool) so postinstall scripts run without git
|
|
RUN corepack enable && corepack prepare pnpm@10.27.0 --activate \
|
|
&& printf '#!/bin/sh\nexit 0' > /usr/local/bin/husky && chmod +x /usr/local/bin/husky \
|
|
&& cd /app && pnpm install --frozen-lockfile --filter @goodgo/api... --prod \
|
|
&& npx prisma generate
|
|
# Copy compiled application
|
|
COPY --from=build --chown=node:node /app/apps/api/dist ./dist
|
|
# Copy compiled workspace lib (runtime dependency)
|
|
COPY --from=build --chown=node:node /app/libs/mcp-servers/dist /app/libs/mcp-servers/dist
|
|
COPY --from=build --chown=node:node /app/libs/mcp-servers/package.json /app/libs/mcp-servers/package.json
|
|
# Prisma schema
|
|
COPY --from=build --chown=node:node /app/prisma /app/prisma
|
|
# Package metadata
|
|
COPY --from=build --chown=node:node /app/apps/api/package.json ./package.json
|
|
# Entrypoint script
|
|
COPY --chown=node:node apps/api/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
EXPOSE 3001
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
CMD node -e "fetch('http://localhost:3001/health').then(r => { if (!r.ok) throw 1 }).catch(() => process.exit(1))"
|
|
|
|
USER node
|
|
|
|
ENTRYPOINT ["dumb-init", "--", "docker-entrypoint.sh"]
|
|
CMD ["node", "dist/main"]
|