From f4a70ffe1dae95570a7901b7e804513356435ccb Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Thu, 1 Oct 2026 01:41:52 -0500 Subject: [PATCH] feat(infra): add multi-stage Dockerfile, split Traefik routing, and appctl manifest. - Implement multi-stage Dockerfile compiling React with Node 20 and serving via uv/FastAPI - Configure docker-compose.yml with split Traefik routers (public 10, admin Authelia 20) - Add appctl manifest apptaml targeting demos.roadtotech.me on proxy-net - Add .dockerignore for clean build context - Update roadmap reflecting completion of Phase 5 infrastructure tasks. --- .dockerignore | 13 +++++++++++++ Dockerfile | 17 +++++++++++++++++ ROADMAP.md | 10 +++++----- app.yaml | 18 ++++++++++++++++++ docker-compose.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 app.yaml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a6466a6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +node_modules/ +frontend/node_modules/ +frontend/dist/ +.venv/ +backend/.venv/ +.pytest_cache/ +__pycache__/ +*.pyc +data/ +backend/data/ +.git/ +.direnv/ +.env* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0cb28f3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Stage 1: Build React frontend +FROM node:20-alpine AS frontend-build +WORKDIR /build +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +# Stage 2: Python runtime +FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim +WORKDIR /app +ENV UV_COMPILE_BYTECODE=1 +COPY backend/pyproject.toml backend/uv.lock* ./ +RUN uv sync --frozen --no-install-project --no-dev +COPY backend/ . +COPY --from=frontend-build /build/dist ./static +CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/ROADMAP.md b/ROADMAP.md index 2af862b..d748a53 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -61,11 +61,11 @@ ## Phase 5 — Infrastructure & Deployment -- [ ] Dockerfile (multi-stage build) -- [ ] `docker-compose.yml` with split Traefik routing -- [ ] `app.yaml` manifest for `appctl` -- [ ] `.gitignore` finalized -- [ ] Local Docker build verification +- [x] Dockerfile (multi-stage build) +- [x] `docker-compose.yml` with split Traefik routing +- [x] `app.yaml` manifest for `appctl` +- [x] `.gitignore` finalized +- [x] Local Docker build verification - [ ] Deployment to `demos.roadtotech.me` - [ ] Post-deployment verification - [ ] Authelia admin route verification diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000..8cc16b1 --- /dev/null +++ b/app.yaml @@ -0,0 +1,18 @@ +name: "bdinvite" +aliases: + - "birthday" + - "invite" +domain: "demos.roadtotech.me" +description: "Interactive Digital Birthday Invitation with RSVP" +visible: true +auth: false +networks: + - proxy-net +env: + BASE_PATH: "/birthday" +homepage: + title: "Birthday Invite" + group: "Applications" + icon: "party.png" + container: "bdinvite" + weight: 30 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8d05266 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +services: + bdinvite: + build: . + container_name: bdinvite + restart: unless-stopped + volumes: + - ./data:/app/data + environment: + - BASE_PATH=/birthday + networks: + - proxy-net + labels: + - "diun.enable=false" + - "traefik.enable=true" + + # Public router (invitation + public API) + - "traefik.http.routers.bdinvite-public.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday`)" + - "traefik.http.routers.bdinvite-public.entrypoints=websecure" + - "traefik.http.routers.bdinvite-public.tls=true" + - "traefik.http.routers.bdinvite-public.priority=10" + - "traefik.http.routers.bdinvite-public.service=bdinvite-svc" + + # Admin router (Authelia-protected) + - "traefik.http.routers.bdinvite-admin.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday/admin`)" + - "traefik.http.routers.bdinvite-admin.entrypoints=websecure" + - "traefik.http.routers.bdinvite-admin.tls=true" + - "traefik.http.routers.bdinvite-admin.priority=20" + - "traefik.http.routers.bdinvite-admin.middlewares=authelia-auth@docker" + - "traefik.http.routers.bdinvite-admin.service=bdinvite-svc" + + # HTTP to HTTPS redirect + - "traefik.http.routers.bdinvite-red.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday`)" + - "traefik.http.routers.bdinvite-red.entrypoints=web" + - "traefik.http.routers.bdinvite-red.middlewares=https-redirect@docker" + + # Service target + - "traefik.http.services.bdinvite-svc.loadbalancer.server.port=8000" + +networks: + proxy-net: + external: true