services:
  db:
    image: postgres:17-alpine
    container_name: krisenvorrat-db
    restart: unless-stopped
    environment:
      POSTGRES_DB: krisenvorrat
      POSTGRES_USER: krisenvorrat
      POSTGRES_PASSWORD: krisenvorrat
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data

  krisenvorrat:
    build: .
    container_name: krisenvorrat-server
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      - KRISENVORRAT_JWT_SECRET=sRKnyOBAgwkoDYptqixc9I26SlUWFhGXL5jaTM1vPbe78Q0r
      - KRISENVORRAT_DB_URL=jdbc:postgresql://db:5432/krisenvorrat
      - KRISENVORRAT_DB_USER=krisenvorrat
      - KRISENVORRAT_DB_PASSWORD=krisenvorrat
    depends_on:
      - db

  backup:
    build: ./backup
    container_name: krisenvorrat-backup
    restart: unless-stopped
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB=krisenvorrat
      - POSTGRES_USER=krisenvorrat
      - POSTGRES_PASSWORD=krisenvorrat
    volumes:
      - backup_data:/backups
    depends_on:
      - db

volumes:
  pgdata:
  backup_data:
