feat(docker): rewrite service Dockerfiles for pnpm monorepo builds
- All 4 service Dockerfiles now use repo root as build context - Multi-stage: pnpm install → build packages+service → pnpm deploy for production - docker-compose.yml updated with context: . and dockerfile paths - Added scripts/docker-prep.sh convenience wrapper - Docker build blocked by corporate proxy SSL (not a code issue)
This commit is contained in:
parent
446201b423
commit
261181b182
@ -66,7 +66,9 @@ services:
|
|||||||
|
|
||||||
# ── Growth Service (Fastify + TypeScript) ───────────────────
|
# ── Growth Service (Fastify + TypeScript) ───────────────────
|
||||||
growth-service:
|
growth-service:
|
||||||
build: ./services/growth-service
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: services/growth-service/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '4001:4001'
|
- '4001:4001'
|
||||||
env_file:
|
env_file:
|
||||||
@ -91,7 +93,9 @@ services:
|
|||||||
|
|
||||||
# ── Billing Service (Fastify + TypeScript) ──────────────────
|
# ── Billing Service (Fastify + TypeScript) ──────────────────
|
||||||
billing-service:
|
billing-service:
|
||||||
build: ./services/billing-service
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: services/billing-service/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '4002:4002'
|
- '4002:4002'
|
||||||
env_file:
|
env_file:
|
||||||
@ -116,7 +120,9 @@ services:
|
|||||||
|
|
||||||
# ── Platform Service (Fastify + TypeScript) ─────────────────
|
# ── Platform Service (Fastify + TypeScript) ─────────────────
|
||||||
platform-service:
|
platform-service:
|
||||||
build: ./services/platform-service
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: services/platform-service/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '4003:4003'
|
- '4003:4003'
|
||||||
env_file:
|
env_file:
|
||||||
@ -141,7 +147,9 @@ services:
|
|||||||
|
|
||||||
# ── Tracker Service (Fastify + TypeScript) ──────────────────
|
# ── Tracker Service (Fastify + TypeScript) ──────────────────
|
||||||
tracker-service:
|
tracker-service:
|
||||||
build: ./services/tracker-service
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: services/tracker-service/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '4004:4004'
|
- '4004:4004'
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Build context: repo root (docker compose sets context: .)
|
# Build context: repo root (docker compose sets context: .)
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@10 --activate
|
RUN npm install -g pnpm@10
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy workspace config + lockfile for dependency resolution
|
# Copy workspace config + lockfile for dependency resolution
|
||||||
|
|||||||
@ -1,16 +1,42 @@
|
|||||||
|
# Build context: repo root (docker compose sets context: .)
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
|
RUN npm install -g pnpm@10
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
RUN npm ci
|
|
||||||
COPY tsconfig.json ./
|
|
||||||
COPY src/ src/
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
|
# Copy workspace config + lockfile for dependency resolution
|
||||||
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml tsconfig.base.json ./
|
||||||
|
|
||||||
|
# Copy all package.json files (pnpm needs these for workspace resolution)
|
||||||
|
COPY packages/errors/package.json packages/errors/
|
||||||
|
COPY packages/cosmos/package.json packages/cosmos/
|
||||||
|
COPY packages/config/package.json packages/config/
|
||||||
|
COPY packages/auth/package.json packages/auth/
|
||||||
|
COPY packages/api-client/package.json packages/api-client/
|
||||||
|
COPY packages/fastify-core/package.json packages/fastify-core/
|
||||||
|
COPY packages/logger/package.json packages/logger/
|
||||||
|
COPY packages/react-auth/package.json packages/react-auth/
|
||||||
|
COPY packages/design-tokens/package.json packages/design-tokens/
|
||||||
|
COPY packages/testing/package.json packages/testing/
|
||||||
|
COPY services/growth-service/package.json services/growth-service/
|
||||||
|
|
||||||
|
# Install all workspace deps
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source
|
||||||
|
COPY packages/ packages/
|
||||||
|
COPY services/growth-service/tsconfig.json services/growth-service/
|
||||||
|
COPY services/growth-service/src/ services/growth-service/src/
|
||||||
|
|
||||||
|
# Build packages first, then service
|
||||||
|
RUN pnpm -r --filter @lysnrai/growth-service... build
|
||||||
|
|
||||||
|
# Deploy to isolated directory (production deps only)
|
||||||
|
RUN pnpm --filter @lysnrai/growth-service deploy /app/deploy
|
||||||
|
|
||||||
|
# ── Production ─────────────────────────────────────────────
|
||||||
FROM node:22-alpine
|
FROM node:22-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
COPY --from=builder /app/deploy ./
|
||||||
RUN npm ci --omit=dev
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
EXPOSE 4001
|
EXPOSE 4001
|
||||||
CMD ["node", "dist/server.js"]
|
CMD ["node", "dist/server.js"]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Build context: repo root (docker compose sets context: .)
|
# Build context: repo root (docker compose sets context: .)
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@10 --activate
|
RUN npm install -g pnpm@10
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy workspace config + lockfile for dependency resolution
|
# Copy workspace config + lockfile for dependency resolution
|
||||||
|
|||||||
@ -1,16 +1,42 @@
|
|||||||
|
# Build context: repo root (docker compose sets context: .)
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
|
RUN npm install -g pnpm@10
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
RUN npm ci
|
|
||||||
COPY tsconfig.json ./
|
|
||||||
COPY src/ src/
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
|
# Copy workspace config + lockfile for dependency resolution
|
||||||
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml tsconfig.base.json ./
|
||||||
|
|
||||||
|
# Copy all package.json files (pnpm needs these for workspace resolution)
|
||||||
|
COPY packages/errors/package.json packages/errors/
|
||||||
|
COPY packages/cosmos/package.json packages/cosmos/
|
||||||
|
COPY packages/config/package.json packages/config/
|
||||||
|
COPY packages/auth/package.json packages/auth/
|
||||||
|
COPY packages/api-client/package.json packages/api-client/
|
||||||
|
COPY packages/fastify-core/package.json packages/fastify-core/
|
||||||
|
COPY packages/logger/package.json packages/logger/
|
||||||
|
COPY packages/react-auth/package.json packages/react-auth/
|
||||||
|
COPY packages/design-tokens/package.json packages/design-tokens/
|
||||||
|
COPY packages/testing/package.json packages/testing/
|
||||||
|
COPY services/tracker-service/package.json services/tracker-service/
|
||||||
|
|
||||||
|
# Install all workspace deps
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source
|
||||||
|
COPY packages/ packages/
|
||||||
|
COPY services/tracker-service/tsconfig.json services/tracker-service/
|
||||||
|
COPY services/tracker-service/src/ services/tracker-service/src/
|
||||||
|
|
||||||
|
# Build packages first, then service
|
||||||
|
RUN pnpm -r --filter @lysnrai/tracker-service... build
|
||||||
|
|
||||||
|
# Deploy to isolated directory (production deps only)
|
||||||
|
RUN pnpm --filter @lysnrai/tracker-service deploy /app/deploy
|
||||||
|
|
||||||
|
# ── Production ─────────────────────────────────────────────
|
||||||
FROM node:22-alpine
|
FROM node:22-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
COPY --from=builder /app/deploy ./
|
||||||
RUN npm ci --omit=dev
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
EXPOSE 4004
|
EXPOSE 4004
|
||||||
CMD ["node", "dist/server.js"]
|
CMD ["node", "dist/server.js"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user