services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: timetracker
      POSTGRES_PASSWORD: timetracker_password
      POSTGRES_DB: timetracker
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U timetracker" ]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    environment:
      DATABASE_URL: "postgresql://timetracker:timetracker_password@db:5432/timetracker"
      OIDC_ISSUER_URL: ${OIDC_ISSUER_URL}
      OIDC_CLIENT_ID: ${OIDC_CLIENT_ID}
      OIDC_REDIRECT_URI: "${API_URL}/auth/callback"
      OIDC_IOS_REDIRECT_URI: ${OIDC_IOS_REDIRECT_URI:-timetracker://oauth/callback}
      SESSION_SECRET: ${SESSION_SECRET}
      JWT_SECRET: ${JWT_SECRET:-}
      PORT: 3001
      NODE_ENV: development
      APP_URL: "${APP_URL}"
    ports:
      - "3001:3001"
    depends_on:
      db:
        condition: service_healthy

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      args:
        - VITE_API_URL=${API_URL}
    ports:
      - "5173:8080"
    depends_on:
      - backend

volumes:
  postgres_data:

