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>
This commit is contained in:
parent
34ed7813ee
commit
127be5755c
@ -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
|
||||
|
||||
|
||||
@ -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;"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user