New top-level portal/ project, peer to console/ and firmware/. Delivers a .NET 10 + React 18 + TimescaleDB + Grafana stack, one container set per customer behind Traefik. Built in 12 phases per FrontEndPrompt spec; no changes to existing console or firmware. Backend (src/Tau.Acuvim.Portal/): - .NET 10 minimal API, Serilog, ASP.NET Identity (cookie auth, lockout). - Single AppDbContext with identity / app / monitoring schemas. - MigrateAsync + TimescaleBootstrapper (idempotent hypertable creation) + IdentityBootstrapper (seeded admin + branding) on startup. - Pure CostCalculator + DB-backed RateService for tariffs (effective-dated, TOU periods, VAT, fixed charges, per-municipality timezone). - BrandingService with logo upload to mounted volume. - Time-series ingest + bucketed query services (time_bucket aggregates, ON CONFLICT for idempotent re-delivery). - ConfigOverviewService with redaction-by-construction (passwords never in payload). - DataProtection keys persisted to /data/keys volume for cookie survival across container restarts. Frontend (frontend/): - React 18 + TypeScript + Vite + Ant Design 5 + TanStack Query. - BrandingProvider + ThemedRoot for live re-themed white-labelling. - RequireAuth / RequireRole guards. - Pages: Login, Dashboard, Dashboards (embedded Grafana), Sites (admin), Settings tabs (Branding / Rates / Users / Grafana / App config). Infra: - Dev (docker-compose.yml) and prod (docker-compose.prod.yml) compose files. Three services per customer; Traefik subdomain + same-origin /grafana path-prefix routing wired with labels. - Grafana 11 with provisioned timescaledb datasource (uid pinned) and starter power-overview.json dashboard with device template variable. - Compose project name documented as lowercase (Compose v2 requirement). Tests (tests/Tau.Acuvim.Portal.Tests/): - xUnit, 40 tests. Covers CostCalculator (period match, TZ, overlap, VAT, fixed), ConnectionStringResolver (all 4 precedence branches incl. Production refusal), TariffValidator, DayOfWeekFlag. - All passing locally against .NET 10. Docs: - README.md (onboarding + 11 spec sections), OPERATIONS.md (per-customer provisioning, secret rotation, backup, troubleshooting), TESTING.md (manual integration scenarios, frontend test scaffolding recipe). Production safety guards: - Refuses to start if Authentication:DefaultAdminPassword is unchanged default in Production. - Refuses to start if Database:AutoProvisionLocalTimescaleDb=true in Production. - Prod Grafana ships with anonymous off and auth mode unset (three options documented in README Security) so iframe refuses to load until a deliberate prod auth choice is made. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
71 lines
2.7 KiB
YAML
71 lines
2.7 KiB
YAML
# Local development stack.
|
|
# For production, see docker-compose.prod.yml (Traefik labels, no host ports, no anon Grafana).
|
|
services:
|
|
portal:
|
|
build: .
|
|
container_name: ${COMPOSE_PROJECT_NAME:-portal-dev}_portal
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
- ASPNETCORE_ENVIRONMENT=${ASPNETCORE_ENVIRONMENT:-Development}
|
|
- Database__ConnectionString=Host=timescaledb;Port=5432;Database=${POSTGRES_DB:-power_monitoring};Username=${POSTGRES_USER:-power_user};Password=${POSTGRES_PASSWORD:-change_me_for_local_only}
|
|
- Database__AutoProvisionLocalTimescaleDb=false
|
|
# In the container the writable volume is /data/branding (Dockerfile chowns it).
|
|
# The appsettings.Development.json override of LogoStoragePath is for local `dotnet run`, not Docker.
|
|
- WhiteLabel__LogoStoragePath=/data/branding
|
|
- Authentication__DefaultAdminEmail=${Authentication__DefaultAdminEmail:-admin@example.com}
|
|
- Authentication__DefaultAdminPassword=${Authentication__DefaultAdminPassword:-ChangeMe123!}
|
|
- Grafana__BaseUrl=http://localhost:3001
|
|
- Grafana__InternalUrl=http://grafana:3000
|
|
depends_on:
|
|
timescaledb:
|
|
condition: service_healthy
|
|
volumes:
|
|
- portal-keys:/data/keys
|
|
- portal-branding:/data/branding
|
|
|
|
timescaledb:
|
|
image: timescale/timescaledb:2.17.2-pg16
|
|
container_name: ${COMPOSE_PROJECT_NAME:-portal-dev}_timescale
|
|
ports:
|
|
- "5433:5432"
|
|
environment:
|
|
- POSTGRES_DB=${POSTGRES_DB:-power_monitoring}
|
|
- POSTGRES_USER=${POSTGRES_USER:-power_user}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-change_me_for_local_only}
|
|
volumes:
|
|
- timescale-data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-power_user} -d ${POSTGRES_DB:-power_monitoring}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
grafana:
|
|
image: grafana/grafana:11.4.0
|
|
container_name: ${COMPOSE_PROJECT_NAME:-portal-dev}_grafana
|
|
ports:
|
|
- "3001:3000"
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
|
|
- GF_SECURITY_ALLOW_EMBEDDING=true
|
|
- GF_AUTH_ANONYMOUS_ENABLED=true
|
|
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
- POSTGRES_DB=${POSTGRES_DB:-power_monitoring}
|
|
- POSTGRES_USER=${POSTGRES_USER:-power_user}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-change_me_for_local_only}
|
|
volumes:
|
|
- grafana-data:/var/lib/grafana
|
|
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
depends_on:
|
|
timescaledb:
|
|
condition: service_healthy
|
|
|
|
volumes:
|
|
portal-keys:
|
|
portal-branding:
|
|
timescale-data:
|
|
grafana-data:
|