services:
  mongo:
    image: mongo
    labels:
      komodo.skip:
    command: --quiet --wiredTigerCacheSizeGB 0.25
    restart: unless-stopped
    logging:
      driver: ${COMPOSE_LOGGING_DRIVER:-local}
    networks:
      - default
    volumes:
      - mongo-data:/data/db
      - mongo-config:/data/configdb
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${DB_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${DB_PASSWORD}
    env_file:
      - path: ./core.env
      - path: ./.env
  core:
    image: ghcr.io/mbecker20/komodo:${COMPOSE_KOMODO_IMAGE_TAG:-latest}
    restart: unless-stopped
    depends_on:
      - mongo
    logging:
      driver: ${COMPOSE_LOGGING_DRIVER:-local}
    networks:
      - default
    ports:
      - 9120:9120
    env_file:
      - path: ./core.env
      - path: ./.env
    environment:
      KOMODO_DATABASE_ADDRESS: mongo:27017
      KOMODO_DATABASE_USERNAME: ${DB_USERNAME}
      KOMODO_DATABASE_PASSWORD: ${DB_PASSWORD}
    volumes:
      - repo-cache:/repo-cache
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.komodo.entryPoints=websecure"
      - "traefik.http.routers.komodo.rule=Host(`deploy.net.enpls.org`)"
      - "traefik.http.routers.komodo.tls=true"
      - "traefik.http.routers.komodo.tls.certresolver=defaultacme"
      - "traefik.http.routers.komodo.middlewares=proxyHeader@file,proxyError@file"
      - "komodo.skip:"

  periphery:
    image: ghcr.io/mbecker20/periphery:${COMPOSE_KOMODO_IMAGE_TAG:-latest}
    labels:
      komodo.skip: # Prevent Komodo from stopping with StopAllContainers
    restart: unless-stopped
    logging:
      driver: ${COMPOSE_LOGGING_DRIVER:-local}
    networks:
      - default
    env_file:
      - path: ./core.env
      - path: ./.env
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /proc:/proc
      - ssl-certs:/etc/komodo/ssl
      - repos:/etc/komodo/repos
      - stacks:/etc/komodo/stacks

volumes:
  # Mongo
  mongo-data:
  mongo-config:
  # Core
  repo-cache:
  # Periphery
  ssl-certs:
  repos:
  stacks:

networks:
  default: {}