learning_ai_invt_trdg/web/Dockerfile
root f0a6ce09ff 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 <noreply@anthropic.com>
2026-04-13 17:48:17 +00:00

43 lines
1.3 KiB
Docker

# 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;"]