version: "3.3"
services:
  ui:
    image: jokeswar/vmchecker_ui:master
    restart: always
    depends_on:
      - database-ui
      - backend
      - openldap
    environment:
      VMCK_BACKEND_URL: "http://backend:8000/api/v1/"
      DATABASE_ENGINE: "django.db.backends.postgresql"
      DATABASE_NAME: "ui"
      DATABASE_USER: "root"
      DATABASE_PASSWORD: "${DATABASE_PASSWORD_UI}"
      DATABASE_HOST: "database-ui"
      DATABASE_PORT: "5432"
      SECRET_KEY: "${SECRET_KEY_UI}"
      LDAP_SERVER_URI: "${LDAP_SERVER_URI}"
      LDAP_BIND_DN: "${LDAP_BIND_DN}"
      LDAP_BIND_PASSWORD: "${LDAP_BIND_PASSWORD}"
      LDAP_USER_TREE: "${LDAP_USER_TREE}"
      LDAP_USER_FILTER: "${LDAP_USER_FILTER}"
    ports:
      - "7000:7000"
    networks:
      - database-ui-network
      - backend-network

  database-ui:
    image: postgres:12.0-alpine
    restart: always
    environment:
      POSTGRES_DB: "ui"
      POSTGRES_USER: "root"
      POSTGRES_PASSWORD: "${DATABASE_PASSWORD_UI}"
    volumes:
      - db-data-ui:/var/lib/postgresql/data
    networks:
      - database-ui-network

  backend:
    image: jokeswar/vmchecker_api:master
    restart: always
    depends_on:
      - database-backend
      - storage-backend
    environment:
      GITLAB_URL: "${GITLAB_URL}"
      SUBMISSION_STORAGE_TYPE: "MINIO"
      MINIO_ADDRESS: "storage-backend:9000"
      MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY}"
      MINIO_SECRET_KEY: "${MINIO_SECRET_KEY}"
      DATABASE_NAME: "backend"
      DATABASE_USER: "root"
      DATABASE_PASSWORD: "${DATABASE_PASSWORD_BACKEND}"
      DATABASE_HOST: "database-backend"
      DATABASE_PORT: "5432"
      SECRET_KEY: "${SECRET_KEY_BACKEND}"
      UWSGI_PROCESS_COUNT: "2"
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
    networks:
      - database-backend-network
      - storage-backend-network
      - backend-network

  database-backend:
    image: postgres:12.0-alpine
    restart: always
    environment:
      POSTGRES_DB: "backend"
      POSTGRES_USER: "root"
      POSTGRES_PASSWORD: "${DATABASE_PASSWORD_BACKEND}"
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      - database-backend-network

  storage-backend:
    image: minio/minio:RELEASE.2022-10-24T18-35-07Z
    restart: always
    command: [ "server", "/data" ]
    environment:
      MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY}"
      MINIO_SECRET_KEY: "${MINIO_SECRET_KEY}"
    volumes:
      - storage-data:/data
    networks:
      - storage-backend-network

  runner:
    image: gitlab/gitlab-runner:latest
    restart: always
    privileged: true
    networks:
      - runner-network
    volumes:
      - 'runner_volume:/etc/gitlab-runner'
      - '/var/run/docker.sock:/var/run/docker.sock'

  openldap:
    image: bitnami/openldap:2
    ports:
      - '1389:1389'
      - '1636:1636'
    environment:
      LDAP_ADMIN_USERNAME: "admin"
      LDAP_ADMIN_PASSWORD: "adminpassword"
      LDAP_USERS: "reader,user01,user02"
      LDAP_PASSWORDS: "readerpassword,password1,password2"
      LDAP_ROOT: "dc=school,dc=com"
    networks:
      - backend-network
    volumes:
      - 'openldap_data:/bitnami/openldap'

volumes:
  db-data-ui:
  storage-data:
  db-data:
  openldap_data:
  runner_volume:


networks:
  database-ui-network:
  database-backend-network:
  storage-backend-network:
  backend-network:
  runner-network:
