x-env_file: &env
  - path: ../.env
    required: true

x-restart: &default_restart
  restart: unless-stopped

name: siren
services:
  app:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    image: siren:${SIREN_VERSION:-latest}
    container_name: siren-app
    env_file: *env
    environment:
      DATABASE_HOST: siren-postgres
      DATABASE_PORT: 5432
      VALKEY_HOST: siren-valkey
      VALKEY_PORT: 6379
      DATA_DIR_PATH: /data
    volumes:
      - ${DATA_DIR_PATH:-../data}:/data
    depends_on:
      - postgres
    profiles:
      - app
    <<: *default_restart

  ui:
    build:
      context: ..
      dockerfile: docker/Dockerfile.ui
    image: siren-ui:${SIREN_VERSION:-latest}
    container_name: siren-ui
    ports:
      - ${UI_PORT:-80}:80
    depends_on:
      - app
    profiles:
      - ui
    <<: *default_restart

  postgres:
    image: postgres:18.0
    container_name: siren-postgres
    env_file: *env
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      PGDATA: /var/lib/postgresql/data
    volumes:
      - postgres:/var/lib/postgresql/data
      - postgres_logs:/var/log
    ports:
      - ${DATABASE_PORT:-5432}:5432
    <<: *default_restart

  valkey:
    image: valkey/valkey:9.0.0
    container_name: siren-valkey
    volumes:
      - valkey:/data
    ports:
      - ${VALKEY_PORT:-6379}:6379
    <<: *default_restart

volumes:
  postgres:
  postgres_logs:
  valkey:
