version: "3.9"

services:
  ldap:
    image: ubccr/hpcts:ldap-${HPCTS_VERSION}
    build:
      context: ./ldap
    hostname: ldap
    container_name: ldap
    environment:
      - CONTAINER_LOG_LEVEL=debug
      - LDAP_RFC2307BIS_SCHEMA=true
      - LDAP_REMOVE_CONFIG_AFTER_SETUP=false
      - LDAP_TLS_VERIFY_CLIENT=never
    networks:
      - compute

  base:
    image: ubccr/hpcts:base-${HPCTS_VERSION}
    build:
      context: ./base
    networks:
      - compute
    depends_on:
      - ldap

  mongodb:
    image: mongo:${MONGODB_VERSION}
    hostname: mongodb
    container_name: mongodb
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=hBbeOfpFLfFT5ZO
    networks:
      - compute
    volumes:
      - ./mongodb:/docker-entrypoint-initdb.d 
      - data_db:/data/db
    expose:
      - "27017"
  mysql:
    image: mariadb:${MARIADB_VERSION}
    hostname: mysql
    container_name: mysql
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
    networks:
      - compute
    volumes:
      - ./database:/docker-entrypoint-initdb.d
      - ./database:/etc/mysql/conf.d
      - ./slurm/slurmdbd.conf:/etc/slurm/slurmdbd.conf
      - var_lib_mysql:/var/lib/mysql
    expose:
      - "3306"

  slurmdbd:
    image: ubccr/hpcts:slurm-${HPCTS_VERSION}
    build:
      context: ./slurm
      args:
        SLURM_VERSION: $SLURM_VERSION
        HPCTS_VERSION: $HPCTS_VERSION
    command: ["slurmdbd"]
    container_name: slurmdbd
    hostname: slurmdbd
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
    expose:
      - "22"
      - "6819"
    depends_on:
      - base
      - ldap
      - mysql

  slurmctld:
    image: ubccr/hpcts:slurm-${HPCTS_VERSION}
    command: ["slurmctld"]
    container_name: slurmctld
    hostname: slurmctld
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    expose:
      - "22"
      - "6817"
    depends_on:
      - ldap
      - slurmdbd

  cpn01:
    init: true
    image: ubccr/hpcts:slurm-${HPCTS_VERSION}
    command: ["slurmd"]
    hostname: cpn01
    container_name: cpn01
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    expose:
      - "22"
      - "6818"
    depends_on:
      - ldap
      - slurmctld

  cpn02:
    init: true
    image: ubccr/hpcts:slurm-${HPCTS_VERSION}
    command: ["slurmd"]
    hostname: cpn02
    container_name: cpn02
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    expose:
      - "22"
      - "6818"
    depends_on:
      - ldap
      - slurmctld

  frontend:
    image: ubccr/hpcts:slurm-${HPCTS_VERSION}
    command: ["frontend"]
    hostname: frontend
    container_name: frontend
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    ports:
      - "127.0.0.1:6222:22"
    depends_on:
      - ldap
      - slurmctld

  coldfront:
    image: ubccr/hpcts:coldfront-${HPCTS_VERSION}
    build:
      context: ./coldfront
      args:
        HPCTS_VERSION: $HPCTS_VERSION
    command: ["serve"]
    hostname: coldfront
    container_name: coldfront
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
      - srv_www:/srv/www
    expose:
      - "22"
    ports:
      - "127.0.0.1:2443:443"
    depends_on:
      - ldap
      - mysql
      - frontend

  ondemand:
    image: ubccr/hpcts:ondemand-${HPCTS_VERSION}
    build:
      context: ./ondemand
      args:
        HPCTS_VERSION: $HPCTS_VERSION
    command: ["serve"]
    hostname: ondemand
    container_name: ondemand
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    expose:
      - "22"
    ports:
      - "127.0.0.1:3443:3443"
      - "127.0.0.1:5554:5554"
    depends_on:
      - ldap
      - frontend

  xdmod:
    image: ubccr/hpcts:xdmod-${HPCTS_VERSION}
    build:
      context: ./xdmod
      args:
        HPCTS_VERSION: $HPCTS_VERSION
    command: ["serve"]
    hostname: xdmod
    container_name: xdmod
    networks:
      - compute
    volumes:
      - etc_munge:/etc/munge
      - etc_slurm:/etc/slurm
      - home:/home
    expose:
      - "22"
    ports:
      - "127.0.0.1:4443:443"
    depends_on:
      - mongodb
      - ldap
      - mysql
      - frontend

volumes:
  etc_munge:
  etc_slurm:
  home:
  var_lib_mysql:
  data_db:
  srv_www:

networks:
  compute: