services:
  db:
    image: postgres:15
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${DB_NAME:-trafoking}
      POSTGRES_USER: ${DB_USER:-postgres}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
    volumes:
      #- ./pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  trafokingweb:
    build: .
    command: ["gunicorn", "trafoking.wsgi:application", "--bind", "0.0.0.0:8000"]
    volumes:
      - ./:/app
    ports:
      - "9090:8000"
    depends_on:
      db:
        condition: service_healthy

volumes:
  pgdata:
