From f0a6ce09ff731e7b317978a5e1cb1d8fa495c92e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 13 Apr 2026 17:48:17 +0000 Subject: [PATCH] feat(web): Dockerize web app, wire to deployed backend - Add web/Dockerfile (node:20 builder + nginx:alpine, port 3085) - Add web service to docker-compose.yml with VITE_ build args - Create web/.env and mobile/.env pointing to api.bytelyst.com - Backend port mapping: 4025:4018 (4018 reserved by actiontrail) Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 19 +++++++++++++++++++ web/Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 web/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 146d2b4..ecb8216 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,25 @@ services: - platform_net restart: unless-stopped + web: + build: + context: . + dockerfile: web/Dockerfile + args: + GITEA_NPM_TOKEN: ${GITEA_NPM_TOKEN} + VITE_PRODUCT_ID: invttrdg + VITE_PLATFORM_URL: https://api.bytelyst.com/platform/api + VITE_TRADING_API_URL: https://api.bytelyst.com/invttrdg/api + container_name: invttrdg-web + ports: + - '3085:3085' + networks: + - default + - platform_net + restart: unless-stopped + depends_on: + - backend + networks: default: {} platform_net: diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..d78d3ec --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,42 @@ +# Build context: learning_ai_invt_trdg/ (monorepo root) +# --- Stage 1: Build --- +FROM node:20-alpine AS builder + +RUN corepack enable && corepack prepare pnpm@10.6.5 --activate + +WORKDIR /app + +ARG GITEA_NPM_TOKEN +ENV GITEA_NPM_TOKEN=${GITEA_NPM_TOKEN} + +COPY .npmrc pnpm-workspace.yaml pnpm-lock.yaml* ./ +COPY package.json ./package.json +COPY web/package.json ./web/package.json + +RUN pnpm install --filter @bytelyst/trading-web + +COPY web/ ./web/ +COPY shared/ ./shared/ + +# Build-time env vars (baked into the static bundle) +ARG VITE_PRODUCT_ID=invttrdg +ARG VITE_PLATFORM_URL=https://api.bytelyst.com/platform/api +ARG VITE_TRADING_API_URL=https://api.bytelyst.com/invttrdg/api + +ENV VITE_PRODUCT_ID=${VITE_PRODUCT_ID} +ENV VITE_PLATFORM_URL=${VITE_PLATFORM_URL} +ENV VITE_TRADING_API_URL=${VITE_TRADING_API_URL} + +WORKDIR /app/web +RUN pnpm run build + +# --- Stage 2: Serve --- +FROM nginx:alpine + +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 + +EXPOSE 3085 +CMD ["nginx", "-g", "daemon off;"]