# Fuellhorn - Lebensmittelvorrats-Verwaltung
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Docker Compose Setup for Local Development
# Builds from source using Dockerfile.dev
#
# Usage:
#   docker compose -f docker-compose.local.yml up
#
# Features:
#   - Builds from source (Dockerfile.dev)
#   - Volume mount for live code changes
#   - Default development secrets (change for any real usage!)

services:
  db:
    image: postgres:17-alpine
    container_name: fuellhorn-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-fuellhorn}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-fuellhorn}
      POSTGRES_DB: ${POSTGRES_DB:-fuellhorn}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-fuellhorn} -d ${POSTGRES_DB:-fuellhorn}"]
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
    networks:
      - fuellhorn-network

  app:
    build:
      context: .
      dockerfile: Dockerfile.dev
    container_name: fuellhorn-app
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    environment:
      # Database Configuration
      DB_TYPE: postgresql
      DATABASE_URL: postgresql://${POSTGRES_USER:-fuellhorn}:${POSTGRES_PASSWORD:-fuellhorn}@db:5432/${POSTGRES_DB:-fuellhorn}
      # Security (development defaults - change for real usage!)
      SECRET_KEY: ${SECRET_KEY:-dev-secret-key-min-32-chars-long!!}
      FUELLHORN_SECRET: ${FUELLHORN_SECRET:-dev-fuellhorn-secret-32-chars!!}
      # App Configuration
      DEBUG: ${DEBUG:-true}
      HOST: 0.0.0.0
      PORT: 8080
    volumes:
      - ./app:/app/app:ro
    ports:
      - "${APP_PORT:-8080}:8080"
    networks:
      - fuellhorn-network

volumes:
  postgres_data:
    name: fuellhorn-postgres-data-local

networks:
  fuellhorn-network:
    name: fuellhorn-network-local
