diff --git a/.npmrc b/.npmrc index e69de29..eccf7d8 100644 --- a/.npmrc +++ b/.npmrc @@ -0,0 +1 @@ +inject-workspace-packages=true diff --git a/apps/watcher/Dockerfile b/apps/watcher/Dockerfile index b7e2571..202f483 100644 --- a/apps/watcher/Dockerfile +++ b/apps/watcher/Dockerfile @@ -1,27 +1,34 @@ -FROM node:22-slim +FROM node:22-slim AS build WORKDIR /app -# Copy built artifacts from monorepo build -# These should be built before docker build with: pnpm build +# Copy monorepo root files +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./ + +# Copy workspace package manifests +COPY apps/watcher/package.json ./apps/watcher/ +COPY packages/shared/package.json ./packages/shared/ +COPY packages/backend/package.json ./packages/backend/ -# Watcher -COPY apps/watcher/dist/ ./dist/ +# Install pnpm and fetch dependencies +RUN corepack enable && corepack prepare pnpm@latest --activate +RUN pnpm install --frozen-lockfile -# Shared package (squadhub client) -COPY packages/shared/package.json ./node_modules/@clawe/shared/package.json -COPY packages/shared/dist/ ./node_modules/@clawe/shared/dist/ +# Copy source and build +COPY packages/shared/ ./packages/shared/ +COPY packages/backend/ ./packages/backend/ +COPY apps/watcher/ ./apps/watcher/ +RUN pnpm build --filter=@clawe/watcher -# Backend (Convex API types) -COPY packages/backend/package.json ./node_modules/@clawe/backend/package.json -COPY packages/backend/convex/_generated/ ./node_modules/@clawe/backend/convex/_generated/ -COPY packages/backend/convex/*.ts ./node_modules/@clawe/backend/convex/ +# Deploy: extract watcher with all production deps into /app/deploy +RUN pnpm --filter=@clawe/watcher --prod deploy deploy -# Create a clean package.json without workspace:* references (npm doesn't support them) -RUN echo '{"name":"@clawe/watcher","private":true,"type":"module"}' > package.json +# --- Production image --- +FROM node:22-slim + +WORKDIR /app -# Install production dependencies -RUN npm install convex axios ws moment-timezone --omit=dev +COPY --from=build /app/deploy . ENV NODE_ENV=production diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index ece76af..f69409e 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -4,9 +4,8 @@ WORKDIR /app # Prune monorepo to only web's dependencies FROM base AS pruner -RUN npm install -g turbo@2 COPY . . -RUN turbo prune @clawe/web --docker +RUN pnpm dlx turbo prune @clawe/web --docker # Install dependencies (cached unless package.json/lockfile changes) FROM base AS deps diff --git a/scripts/convex-deploy.sh b/scripts/convex-deploy.sh index 621a776..8b4b1c6 100755 --- a/scripts/convex-deploy.sh +++ b/scripts/convex-deploy.sh @@ -41,6 +41,6 @@ if [ -n "$WATCHER_TOKEN" ]; then fi # Deploy Convex functions and schema -pnpm --filter @clawe/backend deploy +pnpm --filter @clawe/backend run deploy echo "==> Convex deployment complete"