services:
  dependency-track-apiserver:
    image: dependencytrack/apiserver
    container_name: dependency-track-apiserver
    profiles:
      - dependency-track
    depends_on:
      dependency-track-postgres:
        condition: service_healthy
    env_file:
      - ./env/dependency-track.env
    restart: on-failure:7
    networks:
      - caddy-web
      - dependency-track-internal
    volumes:
    - 'dtrack-data:/data'

  dependency-track-frontend:
    image: dependencytrack/frontend
    container_name: dependency-track-frontend
    profiles:
      - dependency-track
    restart: on-failure:7
    networks:
      - caddy-web
      - dependency-track-internal
    depends_on:
      dependency-track-apiserver:
        condition: service_healthy
      caddy:
        condition: service_healthy
    security_opt:
      - no-new-privileges:true
    env_file:
      - ./env/dependency-track.env

  dependency-track-postgres:
    image: postgres:17-alpine
    container_name: dependency-track-postgres
    profiles:
      - dependency-track
    env_file:
      - ./env/postgres.env
    restart: on-failure:7
    networks:
      - dependency-track-internal
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
      interval: 5s
      timeout: 3s
      retries: 5
    volumes:
    - "dtrack-postgres-data:/var/lib/postgresql/data"

volumes:
  dtrack-data:
    name: dtrack-data
  dtrack-postgres-data:
    name: dtrack-postgres-data

networks:
  caddy-web:
    driver: bridge
    name: caddy-web
  dependency-track-internal:
    driver: bridge
    name: dependency-track-internal
