2026-09-05 21:10:18 +00:00
|
|
|
# ==========================================
|
|
|
|
|
# Stage 1: Build Frontend (Vite + React + TS)
|
|
|
|
|
# ==========================================
|
|
|
|
|
FROM node:22-alpine AS frontend-builder
|
|
|
|
|
|
|
|
|
|
WORKDIR /build/frontend
|
|
|
|
|
|
2026-09-10 00:32:22 +00:00
|
|
|
# Optional build argument to override version
|
|
|
|
|
ARG APP_VERSION
|
|
|
|
|
ENV VITE_APP_VERSION=$APP_VERSION
|
|
|
|
|
|
2026-09-05 21:10:18 +00:00
|
|
|
# Install dependencies
|
|
|
|
|
COPY frontend/package*.json ./
|
|
|
|
|
RUN npm ci || npm install
|
|
|
|
|
|
2026-09-10 00:32:22 +00:00
|
|
|
# Copy version.ini for compile-time version resolution
|
|
|
|
|
COPY version.ini /build/version.ini
|
|
|
|
|
|
2026-09-05 21:10:18 +00:00
|
|
|
# Build frontend production bundle
|
|
|
|
|
COPY frontend/ ./
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# ==========================================
|
|
|
|
|
# Stage 2: Python Backend (FastAPI + Uvicorn)
|
|
|
|
|
# ==========================================
|
|
|
|
|
FROM python:3.12-slim AS production
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
|
PYTHONPATH=/app/backend \
|
|
|
|
|
PORT=8000
|
|
|
|
|
|
|
|
|
|
# Install curl for container healthcheck
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Install backend Python dependencies
|
|
|
|
|
COPY backend/requirements.txt ./backend/requirements.txt
|
|
|
|
|
RUN pip install --no-cache-dir -r ./backend/requirements.txt
|
|
|
|
|
|
|
|
|
|
# Copy backend source code
|
|
|
|
|
COPY backend ./backend
|
|
|
|
|
|
|
|
|
|
# Copy compiled frontend from builder stage
|
|
|
|
|
COPY --from=frontend-builder /build/frontend/dist ./frontend/dist
|
|
|
|
|
|
|
|
|
|
# Expose FastAPI application port
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
# Container healthcheck
|
|
|
|
|
HEALTHCHECK --interval=20s --timeout=5s --start-period=5s --retries=3 \
|
|
|
|
|
CMD curl -f http://localhost:8000/api/health || exit 1
|
|
|
|
|
|
|
|
|
|
# Start FastAPI server via Uvicorn
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
2026-09-08 11:32:20 +00:00
|
|
|
#harbor.freshbrewed.science/library/botwebwars
|