services:
  db:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: aufmass
      POSTGRES_PASSWORD: aufmass_secret
      POSTGRES_DB: aufmassweb
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U aufmass -d aufmassweb"]
      interval: 5s
      timeout: 5s
      retries: 10

  web:
    build: .
    restart: unless-stopped
    ports:
      - "5000:5000"
    environment:
      DATABASE_URL: postgresql://aufmass:aufmass_secret@db:5432/aufmassweb
      FLASK_ENV: development
      SECRET_KEY: aufmass-dev-key-change-in-production
    volumes:
      - .:/app
      - ../daten:/daten
      - uploads:/app/data/uploads
    depends_on:
      db:
        condition: service_healthy

volumes:
  pgdata:
  uploads:
