solar/docker-compose.yml

162 lines
5.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Solar production forecast Belgium (1 location)
# Project name: degelas | Domain: degelas.be (routed by fullstack_degelas nginx)
# Backend: Python 3.12 + FastAPI | DB: PostgreSQL | Frontend: Vite + React
# Frontend and backend join network fullstack_degelas_proxy so degelas_nginx can route degelas.be to this stack.
name: degelas
services:
postgres:
image: postgres:16-alpine
container_name: degelas-postgres
restart: unless-stopped
cpus: 1.0
mem_limit: 1g
environment:
POSTGRES_USER: degelas
POSTGRES_PASSWORD: degelas
POSTGRES_DB: degelas
ports:
- "5445:5432"
volumes:
- degelas_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U degelas -d degelas"]
interval: 3s
timeout: 3s
retries: 5
networks:
- degelas
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: degelas-backend
restart: unless-stopped
cpus: 2.0
mem_limit: 2g
expose:
- "8000"
env_file:
- .env
volumes:
- ./backend:/app
- ./version.json:/app/version.json
- ./history_EU:/app/history_EU
environment:
- PYTHONUNBUFFERED=1
- DATABASE_URL=postgresql+asyncpg://degelas:degelas@postgres:5432/degelas
# Solar production estimate: panel count × Wp per panel → kWp; optional performance ratio (0.750.85)
- SOLAR_PANEL_COUNT=4
- SOLAR_PANEL_WP=250
- SOLAR_PERFORMANCE_RATIO=0.8
- BATTERY_CAPACITY_KWH=10
- BATTERY_POWER_KW=5
- BATTERY_EFFICIENCY=0.9
- BROWSER_CDP_URL=http://degelas-chrome:9222
# PR frontend (pr.degelas.be): JWT auth set in .env (PR_USER, PR_PASSWORD, PR_JWT_SECRET)
- PR_AUTH_ENABLED=${PR_AUTH_ENABLED:-0}
- PR_USER=${PR_USER:-}
- PR_PASSWORD=${PR_PASSWORD:-}
- PR_JWT_SECRET=${PR_JWT_SECRET:-}
# Public dashboard auth (email + JWT) set AUTH_JWT_SECRET in .env for login/register
- AUTH_JWT_SECRET=${AUTH_JWT_SECRET:-}
- AUTH_JWT_EXPIRY_SECONDS=${AUTH_JWT_EXPIRY_SECONDS:-604800}
- AUTH_REGISTER_OPEN=${AUTH_REGISTER_OPEN:-1}
- ADMIN_SECRET=${ADMIN_SECRET:-}
# Optional: bootstrap admin user on startup (set in .env only; remove password after first deploy if desired)
# Omit SEED_ADMIN_TIER to default that user to tier admin; or set free|pro|admin explicitly.
- SEED_ADMIN_EMAIL=${SEED_ADMIN_EMAIL:-}
- SEED_ADMIN_PASSWORD=${SEED_ADMIN_PASSWORD:-}
- SEED_ADMIN_TIER=${SEED_ADMIN_TIER:-}
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
depends_on:
postgres:
condition: service_healthy
networks:
- degelas
- proxy
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: degelas-frontend
restart: unless-stopped
cpus: 1.0
mem_limit: 1g
expose:
- "5173"
volumes:
- ./frontend:/app
- /app/node_modules # prevent host node_modules overwriting container
environment:
# Use /api when served via nginx at degelas.be; override for local dev (e.g. http://localhost:8000)
- VITE_API_URL=/api
command: npm run dev -- --host 0.0.0.0
depends_on:
- backend
networks:
- degelas
- proxy
# PR frontend (pr.degelas.be): manage campaigns and scheduled posts. Login-protected; API via same backend.
# Source mounted for live reload; rebuild image only when package.json / deps change.
pr:
build:
context: ./pr-frontend
dockerfile: Dockerfile
image: degelas-pr:local
container_name: degelas-pr
profiles:
- pr
expose:
- "5174"
volumes:
- ./pr-frontend:/app
- /app/node_modules
environment:
- VITE_API_URL=/api
command: npm run dev -- --host 0.0.0.0
networks:
- proxy
# Kasm Chrome: browser session for posting to X/Instagram etc. noVNC on 6901; CDP on 9222 (internal only).
# Custom image uses socat so CDP is reachable from backend (Chrome binds to 127.0.0.1 only).
chrome:
build:
context: ./docker-chrome
dockerfile: Dockerfile
image: degelas-chrome:local
container_name: degelas-chrome
profiles:
- browser
shm_size: "512m"
env_file:
- .env
ports:
- "6901:6901" # noVNC open in browser to log into X/Instagram
expose:
- "9222" # CDP backend uses this for automation (not published to host)
volumes:
# Persist Chrome profile (cookies, logins for X/Instagram) in project folder
- ./chrome-profile:/data/chrome-profile
environment:
VNC_PW: "${CHROME_VNC_PW:-degelas}"
# Chrome profile on persistent volume so logins survive restart/rebuild
APP_ARGS: "--remote-debugging-port=9223 --remote-allow-origins=* --user-data-dir=/data/chrome-profile --no-first-run --restore-last-session --hide-crash-restore-bubble"
networks:
- degelas
- proxy
networks:
degelas:
driver: bridge
proxy:
name: fullstack_degelas_proxy
external: true
volumes:
degelas_pgdata: