feat(platform-service): update Dockerfile for pnpm workspace support
- Add proper workspace dependency resolution - Build packages before service - Use pnpm deploy for production - Add docker-prep.sh script for helper commands
This commit is contained in:
parent
99cbdf582c
commit
446201b423
22
scripts/docker-prep.sh
Executable file
22
scripts/docker-prep.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# docker-prep.sh — Build all packages before Docker builds.
|
||||
# Docker builds use the monorepo root as context and need compiled packages.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/docker-prep.sh # build all packages
|
||||
# ./scripts/docker-prep.sh --check # verify builds are fresh
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
echo "🔨 Building all packages for Docker..."
|
||||
pnpm -r --filter './packages/*' build
|
||||
|
||||
echo ""
|
||||
echo "✅ All packages built. Ready for docker compose build."
|
||||
echo ""
|
||||
echo "Verify with:"
|
||||
echo " docker compose build"
|
||||
echo " docker compose up -d"
|
||||
echo " docker compose ps"
|
||||
@ -1,16 +1,42 @@
|
||||
# Build context: repo root (docker compose sets context: .)
|
||||
FROM node:22-alpine AS builder
|
||||
RUN corepack enable && corepack prepare pnpm@10 --activate
|
||||
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/billing-service/package.json services/billing-service/
|
||||
|
||||
# Install all workspace deps
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source
|
||||
COPY packages/ packages/
|
||||
COPY services/billing-service/tsconfig.json services/billing-service/
|
||||
COPY services/billing-service/src/ services/billing-service/src/
|
||||
|
||||
# Build packages first, then service
|
||||
RUN pnpm -r --filter @lysnrai/billing-service... build
|
||||
|
||||
# Deploy to isolated directory (production deps only)
|
||||
RUN pnpm --filter @lysnrai/billing-service deploy /app/deploy
|
||||
|
||||
# ── Production ─────────────────────────────────────────────
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci --omit=dev
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/deploy ./
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 4002
|
||||
CMD ["node", "dist/server.js"]
|
||||
|
||||
@ -1,16 +1,42 @@
|
||||
# Build context: repo root (docker compose sets context: .)
|
||||
FROM node:22-alpine AS builder
|
||||
RUN corepack enable && corepack prepare pnpm@10 --activate
|
||||
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/platform-service/package.json services/platform-service/
|
||||
|
||||
# Install all workspace deps
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source
|
||||
COPY packages/ packages/
|
||||
COPY services/platform-service/tsconfig.json services/platform-service/
|
||||
COPY services/platform-service/src/ services/platform-service/src/
|
||||
|
||||
# Build packages first, then service
|
||||
RUN pnpm -r --filter @lysnrai/platform-service... build
|
||||
|
||||
# Deploy to isolated directory (production deps only)
|
||||
RUN pnpm --filter @lysnrai/platform-service deploy /app/deploy
|
||||
|
||||
# ── Production ─────────────────────────────────────────────
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci --omit=dev
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/deploy ./
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 4003
|
||||
CMD ["node", "dist/server.js"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user