version: '3'

services:
  mysql:
    image: mariadb
    networks:
      - fic-net
    volumes:
      - mysql-data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=toto
      - MYSQL_DATABASE=fic
      - MYSQL_USER=fic
      - MYSQL_PASSWORD=fic

  admin:
    build:
      context: .
      dockerfile: Dockerfile-admin
    image: nemunaire/fic-admin:latest
    ports:
      - "8081:8081"
    links:
      - mysql
    networks:
      - fic-net
    volumes:
      - /mnt/fic:/mnt/fic
      - dashboard:/srv/DASHBOARD
      - files:/srv/FILES
      - generator:/srv/GENERATOR:ro
      - pki:/srv/PKI
      - settings:/srv/SETTINGS
      - settingsdist:/srv/SETTINGSDIST
      - submissions:/srv/submissions:ro
      - sync:/srv/SYNC
      - teams:/srv/TEAMS
    command: -baseurl /admin/ -localimport /mnt/fic -localimportsymlink
    depends_on:
      - mysql
    environment:
      - MYSQL_HOST=mysql
      - FICCA_PASS

  evdist:
    build:
      context: .
      dockerfile: Dockerfile-evdist
    image: nemunaire/fic-evdist:latest
    networks:
      - fic-net
    volumes:
      - settings:/srv/SETTINGS
      - settingsdist:/srv/SETTINGSDIST

  checker:
    build:
      context: .
      dockerfile: Dockerfile-checker
    image: nemunaire/fic-checker:latest
    links:
      - mysql
    networks:
      - fic-net
    volumes:
      - generator:/srv/GENERATOR:ro
      - teams:/srv/TEAMS:ro
      - settingsdist:/srv/SETTINGSDIST:ro
      - submissions:/srv/submissions
    depends_on:
      - mysql
      - generator
    environment:
      - MYSQL_HOST=mysql

  generator:
    build:
      context: .
      dockerfile: Dockerfile-generator
    image: nemunaire/fic-generator:latest
    links:
      - mysql
    networks:
      - fic-net
    volumes:
      - generator:/srv/GENERATOR
      - teams:/srv/TEAMS
      - settingsdist:/srv/SETTINGSDIST:ro
    depends_on:
      - mysql
    environment:
      - MYSQL_HOST=mysql

  qa:
    build:
      context: .
      dockerfile: Dockerfile-qa
    image: nemunaire/fic-qa:latest
    ports:
      - "8083:8083"
    links:
      - mysql
    networks:
      - fic-net
    volumes:
      - teams:/srv/TEAMS
      - settingsdist:/srv/SETTINGSDIST
    command: -baseurl /qa/
    depends_on:
      - mysql
    environment:
      - MYSQL_HOST=mysql

  receiver:
    build:
      context: .
      dockerfile: Dockerfile-receiver
    image: nemunaire/fic-receiver:latest
    command: "-startedFile /srv/startingblock/started -bind :8080"
    ports:
      - "8080:8080"
    networks:
      - fic-net
    volumes:
      - htdocs:/srv/htdocs-frontend:ro
      - files:/srv/FILES:ro
      - teams:/srv/TEAMS:ro
      - settingsdist:/srv/SETTINGSDIST:ro
      - submissions:/srv/submissions
      - startingblock:/srv/startingblock

  dashboard:
    build:
      context: .
      dockerfile: Dockerfile-dashboard
    image: nemunaire/fic-dashboard:latest
    command: "-baseurl /dashboard/"
    ports:
      - "8082:8082"
    networks:
      - fic-net
    volumes:
      - dashboard:/srv/DASHBOARD
      - teams:/srv/TEAMS:ro
      - settingsdist:/srv/SETTINGSDIST:ro

  front:
    build:
      context: .
      dockerfile: Dockerfile-nginx
    image: nemunaire/fic-nginx:latest
    ports:
      - "8042:80"
    networks:
      - fic-net
    volumes:
      - ./configs/nginx/get-team/team-1.conf:/etc/nginx/fic-get-team.conf:ro
      - /mnt/fic:/mnt/fic:ro
      - files:/srv/FILES:ro
      - settingsdist:/srv/SETTINGSDIST:ro
      - sync:/srv/SYNC:ro
      - teams:/srv/TEAMS:ro
      - startingblock:/srv/STARTINGBLOCK:ro
    depends_on:
      - qa
      - receiver
      - dashboard
      - checker
      - admin

volumes:
  mysql-data:
  dashboard:
  files:
  htdocs:
  generator:
  pki:
  settings:
  settingsdist:
  startingblock:
    driver_opts:
      type: tmpfs
      device: tmpfs
  submissions:
  sync:
  teams:

networks:
  fic-net:
