version: '3.8'

services:
  db:
    image: postgres:16-alpine
    container_name: timetracker-db
    restart: always
    environment:
      POSTGRES_USER: timetracker_user
      POSTGRES_PASSWORD: SecretPassword123
      POSTGRES_DB: timetracker
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  timetracker:
    build:
      context: .
      dockerfile: timetracker.Server/Dockerfile
    container_name: timetracker-app
    restart: always
    ports:
      - "8090:8080" 
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_HTTP_PORTS=8080
      - DB_PROVIDER=PostgreSQL
      - ConnectionStrings__DefaultConnection=Host=db;Database=timetracker;Username=timetracker_user;Password=SecretPassword123;
      - EnableHttpsRedirect=false
      - TIMETRACKER_LOG_DIR=/app/logs
      - TenantSettings__BaseDomain=timetracker.marc-wieland.de
    volumes:
      - dpkeys:/home/app/.aspnet/DataProtection-Keys
      - applogs:/app/logs
    depends_on:
      - db

  logshell:
    image: alpine:3.22
    container_name: timetracker-logshell
    restart: unless-stopped
    command: ["sh", "-c", "tail -f /dev/null"]
    volumes:
      - applogs:/logs:ro

volumes:
  pgdata:
    name: timetracker_pgdata_fresh
  dpkeys:
    name: timetracker_dpkeys
  applogs:
    name: timetracker_logs