services:
  keywarden-db:
    image: postgres:17-alpine
    container_name: keywarden-db
    environment:
      POSTGRES_PASSWORD: ${KEYWARDEN_POSTGRES_PASSWORD:-postgres}
      POSTGRES_DB: ${KEYWARDEN_POSTGRES_DB:-keywarden}
      POSTGRES_USER: ${KEYWARDEN_POSTGRES_USER:-keywarden}
      POSTGRES_PORT: ${KEYWARDEN_POSTGRES_PORT:-5432}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U keywarden -d keywarden"]
      interval: 5s
      timeout: 5s
      retries: 20
    volumes:
      - "pgdata:/var/lib/postgresql/data"

  keywarden:
    build: .
    container_name: keywarden
    volumes:
      - ./app:/app
      - ./nginx/certs:/etc/nginx/certs
      - ./nginx/logs:/var/log/nginx
    ports:
      - "443:443"
    depends_on:
      - keywarden-db
    environment:
      - DJANGO_SETTINGS_MODULE=keywarden.settings.dev
      - PYTHONPATH=/app
    env_file:
      - .env

volumes:
  pgdata:
