# THE QS HUB — production image (React SPA + FastAPI in one container). # build: docker build -f Dockerfile.web -t qshub-web . # run: docker run -p 8000:8000 --env-file .env qshub-web # The SPA is compiled in stage 1 and served by FastAPI (api/main.py) at "/". # ---- Stage 1: build the React frontend ---- FROM node:20-slim AS frontend WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm ci COPY frontend/ ./ RUN npm run build # ---- Stage 2: Python API that also serves the built SPA ---- FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential libgl1 libglib2.0-0 curl \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --upgrade pip && pip install -r requirements.txt # App source (node_modules / dist excluded via .dockerignore) COPY . . # Overlay the freshly compiled SPA from stage 1 COPY --from=frontend /app/frontend/dist ./frontend/dist EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD curl -f http://localhost:8000/api/health || exit 1 CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]