services:
  log:
    image: amir20/dozzle:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8080"
    environment:
      DOZZLE_BASE: /log
    stop_grace_period: 5s
    healthcheck:
      test: ["CMD", "/dozzle", "healthcheck"]
      interval: 3s
      timeout: 30s
      retries: 5
      start_period: 30s

  postgres:
    image: postgres:latest
    restart: unless-stopped
    stop_grace_period: 10s
    env_file:
       - '.variables.env'
    volumes:
      - ./data:/var/lib/postgresql/data

  app:
    restart: unless-stopped
    stop_grace_period: 5s
    environment:
      PUBLIC_KERNEL_ORIGIN: http://kernel:8000
      PG_CONNECTION_STRING: postgres://user:password@postgres:5432/spectral_db
    build:
      context: ./app
      dockerfile: Dockerfile.prod
    image: knyazer/spectral-app
    expose:
      - "5173"
    depends_on:
      - kernel
      - postgres

  nginx:
    image: nginx:latest
    restart: unless-stopped
    stop_grace_period: 2s
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.prod.conf:/etc/nginx/nginx.conf:ro
      - /certs:/certs:ro
    depends_on:
      - app

  kernel:
    restart: unless-stopped
    stop_grace_period: 5s
    build:
      context: ./kernel
      dockerfile: Dockerfile.prod
    image: knyazer/spectral-kernel
    expose:
      - "8000"
    depends_on:
      - postgres
    env_file:
       - '.variables.env'
       - '.apikeys.env'

networks:
  default:
    external: false
