Two issues from the first server cutover:
1. SPA loaded white-on-black blank because import.meta.env.VITE_AZURE_TENANT_ID
and VITE_AZURE_CLIENT_ID were undefined at runtime. Vite reads VITE_* at
*build time* and inlines them into the bundle; passing them only as
runtime container env vars is too late.
- Dockerfile.v2: declare ARG VITE_AZURE_TENANT_ID, VITE_AZURE_CLIENT_ID,
VITE_BASE; export as ENV before `npm run build`.
- docker-compose.v2.yml: forward AZURE_TENANT_ID / AZURE_CLIENT_ID /
VITE_BASE through `build.args` so the cutover .env values reach Vite.
2. cutover-in-place.sh stopped V1 with `-p social-listening`, but V1's actual
compose project name was `social-reporting` (parent dir). Old V1 containers
were left running. Now we try both project names AND sweep by container
name pattern (anything matching social-listening or social-reporting-db-1
that isn't a V2 container).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
2.5 KiB
YAML
64 lines
2.5 KiB
YAML
# Per CLAUDE.md compose-name policy: every compose file MUST pin a unique top-level `name:`.
|
|
# This keeps V2 from colliding with V1 (project name `social-listening`) on shared hosts.
|
|
name: social-reporting-v2
|
|
|
|
services:
|
|
db-v2:
|
|
image: postgres:16-alpine
|
|
# No host port binding by default — app-v2 reaches db-v2 over the docker network at
|
|
# `db-v2:5432`. For host-side psql access during local dev, layer in
|
|
# docker-compose.v2.dev.yml (which exposes ${DB_V2_PORT:-5437} on 127.0.0.1).
|
|
# Per CLAUDE.md: avoid binding host ports we don't need so we can't clash on shared hosts.
|
|
environment:
|
|
POSTGRES_DB: social_reporting_v2
|
|
POSTGRES_USER: srv2_user
|
|
POSTGRES_PASSWORD: ${DB_V2_PASSWORD:-change-me-please}
|
|
volumes:
|
|
- pgdata-v2:/var/lib/postgresql/data
|
|
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U srv2_user -d social_reporting_v2"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
app-v2:
|
|
build:
|
|
context: ..
|
|
dockerfile: v2/Dockerfile.v2
|
|
# VITE_* are baked into the SPA bundle at build time — they MUST be passed here
|
|
# (passing them only as runtime env vars on the container is too late; Vite has
|
|
# already finished compiling).
|
|
args:
|
|
VITE_AZURE_TENANT_ID: ${AZURE_TENANT_ID:-}
|
|
VITE_AZURE_CLIENT_ID: ${AZURE_CLIENT_ID:-}
|
|
VITE_BASE: ${VITE_BASE:-/social-reports/}
|
|
ports:
|
|
- "127.0.0.1:${APP_V2_PORT:-3457}:3457"
|
|
env_file:
|
|
- .env
|
|
depends_on:
|
|
db-v2:
|
|
condition: service_healthy
|
|
volumes:
|
|
# Pipeline outputs land here; shared with the host so we can inspect/back up.
|
|
- ../briefs:/app/briefs
|
|
environment:
|
|
- PORT=3457
|
|
- NODE_ENV=${NODE_ENV:-development}
|
|
- DATABASE_URL=postgresql://srv2_user:${DB_V2_PASSWORD:-change-me-please}@db-v2:5432/social_reporting_v2
|
|
- SESSION_SECRET=${SESSION_SECRET:-}
|
|
- ALLOWED_ORIGIN=${ALLOWED_ORIGIN:-}
|
|
- AZURE_TENANT_ID=${AZURE_TENANT_ID:-}
|
|
- AZURE_CLIENT_ID=${AZURE_CLIENT_ID:-}
|
|
- ALLOW_PASSWORD_FALLBACK=${ALLOW_PASSWORD_FALLBACK:-false}
|
|
- DASH_USER=${DASH_USER:-admin}
|
|
- DASH_PASS=${DASH_PASS:-}
|
|
- BOOTSTRAP_SUPER_ADMIN_EMAIL=${BOOTSTRAP_SUPER_ADMIN_EMAIL:-}
|
|
- APIFY_TOKEN=${APIFY_TOKEN:-}
|
|
- APIFY_LIVE_APPROVED=${APIFY_LIVE_APPROVED:-false}
|
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
|
- COMPOSE_PROJECT_NAME=social-reporting-v2
|
|
|
|
volumes:
|
|
pgdata-v2:
|