From 127be5755c9e540a339387d38a251aac8f69f1d4 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 10 May 2026 00:55:54 +0000 Subject: [PATCH] revert(docker): revert to vendor approach for trading repo The base image approach was reverted for notes and clock due to workspace complexity. The trading repo was still using the base image approach which is causing build failures. Reverting to the vendor approach which works reliably for the monorepo structure. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- backend/Dockerfile | 44 +++++++++++++++++++++++++------------------- web/Dockerfile | 19 +++++++++---------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 289da98..f2f7ce1 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,47 +1,53 @@ # Build context: learning_ai_invt_trdg/ (monorepo root) # --- Stage 1: Build --- -FROM bytelyst-common-base-backend:latest AS builder +FROM node:20-alpine AS builder + +RUN corepack enable && corepack prepare pnpm@10.6.5 --activate WORKDIR /app -# Copy workspace root files -COPY .npmrc pnpm-workspace.yaml pnpm-lock.yaml* ./ +ARG BYTELYST_PACKAGE_SOURCE=vendor +ENV BYTELYST_PACKAGE_SOURCE=${BYTELYST_PACKAGE_SOURCE} + +# Copy workspace root files first (layer cache) +COPY .npmrc .pnpmfile.cjs pnpm-workspace.yaml pnpm-lock.yaml* ./ COPY package.json ./package.json COPY backend/package.json ./backend/package.json +COPY web/package.json ./web/package.json +COPY mobile/package.json ./mobile/package.json -# Install all dependencies (including devDependencies for building) -RUN pnpm install --filter @bytelyst/trading-backend --ignore-scripts +# Vendor packages — @bytelyst/* are file: references that must be present before pnpm install +COPY vendor/ ./vendor/ -# Copy source +# Install the workspace graph so shared/ files resolve the same way they do locally. +RUN pnpm install -r + +# Copy source (backend + shared types used by tsconfig rootDir "..") COPY backend/ ./backend/ COPY shared/ ./shared/ WORKDIR /app/backend RUN pnpm run build # --- Stage 2: Production --- -FROM bytelyst-common-base-backend:latest +FROM node:20-alpine + +RUN corepack enable && corepack prepare pnpm@10.6.5 --activate WORKDIR /app -# Copy workspace root files -COPY .npmrc pnpm-workspace.yaml pnpm-lock.yaml* ./ +ARG BYTELYST_PACKAGE_SOURCE=vendor +ENV BYTELYST_PACKAGE_SOURCE=${BYTELYST_PACKAGE_SOURCE} + +COPY .npmrc .pnpmfile.cjs pnpm-workspace.yaml pnpm-lock.yaml* ./ COPY package.json ./package.json COPY backend/package.json ./backend/package.json +COPY vendor/ ./vendor/ -# Install production dependencies only -RUN pnpm install --filter @bytelyst/trading-backend --prod --ignore-scripts +RUN pnpm install --filter @bytelyst/trading-backend --prod RUN mkdir -p /app/node_modules && ln -s /app/backend/node_modules/@bytelyst /app/node_modules/@bytelyst -# Copy built artifacts COPY --from=builder /app/backend/dist ./backend/dist -# Environment -ENV NODE_ENV=production - -# Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ - CMD node -e "require('http').get('http://localhost:4018/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" - RUN chown -R node:node /app USER node diff --git a/web/Dockerfile b/web/Dockerfile index 6c54cb1..4a7a08d 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,18 +1,21 @@ # Build context: learning_ai_invt_trdg/ (monorepo root) # --- Stage 1: Build --- -FROM bytelyst-common-base-web:latest AS builder +FROM node:20-alpine AS builder + +RUN corepack enable && corepack prepare pnpm@10.6.5 --activate WORKDIR /app -# Copy workspace root files -COPY .npmrc pnpm-workspace.yaml pnpm-lock.yaml* ./ +ARG BYTELYST_PACKAGE_SOURCE=vendor +ENV BYTELYST_PACKAGE_SOURCE=${BYTELYST_PACKAGE_SOURCE} + +COPY .npmrc .pnpmfile.cjs pnpm-workspace.yaml pnpm-lock.yaml* ./ COPY package.json ./package.json COPY web/package.json ./web/package.json +COPY vendor/ ./vendor/ -# Install all dependencies (including devDependencies for building) -RUN pnpm install --filter @bytelyst/trading-web --ignore-scripts +RUN pnpm install --filter @bytelyst/trading-web -# Copy source COPY web/ ./web/ COPY shared/ ./shared/ @@ -36,9 +39,5 @@ COPY --from=builder /app/web/dist /usr/share/nginx/html # SPA fallback: all routes serve index.html RUN printf 'server {\n listen 3085;\n root /usr/share/nginx/html;\n index index.html;\n location / {\n try_files $uri $uri/ /index.html;\n }\n gzip on;\n gzip_types text/plain text/css application/javascript application/json;\n}\n' > /etc/nginx/conf.d/default.conf -# Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD wget --quiet --tries=1 --spider http://localhost:3085 || exit 1 - EXPOSE 3085 CMD ["nginx", "-g", "daemon off;"]