version: "3.5"
services:
  gitlab:
    build: sendmail
    image: 'gitlab_sendmail:1.0'
    container_name: sharing_gitlab
    restart: always
    hostname: $GITLAB_HOSTNAME
    networks:
      - frontend
      - backend

    environment:
      GITLAB_HOME: $GITLAB_HOME
      EXTERNAL_URL: $EXTERNAL_URL
      GITLAB_HOSTNAME: $GITLAB_HOSTNAME
      GITLAB_API_ROOT_ACCESS_TOKEN: $GITLAB_API_ROOT_ACCESS_TOKEN
      MAIL_USERNAME: $MAIL_USERNAME
      MAIL_PASSWORD: $MAIL_PASSWORD
      FILEHOOKS_CONFIG_FILE: $FILEHOOKS_CONFIG_FILE
      GITLAB_OMNIBUS_CONFIG: |
        external_url '$EXTERNAL_URL'
        registry_external_url '$EXTERNAL_URL:5051'
        gitlab_rails['gitlab_email_enabled'] = true
        gitlab_rails['gitlab_email_from'] = 'notifications@sharing-codeability.uibk.ac.at'
        gitlab_rails['gitlab_email_display_name'] = 'GitLab'
        gitlab_rails['gitlab_email_reply_to'] = 'noreply@sharing-codeability.uibk.ac.at'
        gitlab_rails['gitlab_email_subject_suffix'] = ''
        letsencrypt['enable'] = false
        nginx['enable'] = true
        nginx['client_max_body_size'] = '250m'
        nginx['redirect_http_to_https'] = false
        nginx['ssl_ciphers'] = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256"
        nginx['ssl_protocols'] = "TLSv1.2 TLSv1.3"
        nginx['ssl_session_cache'] = "builtin:1000  shared:SSL:10m"
        nginx['referrer_policy'] = 'same-origin'
        nginx['http2_enabled'] = true
        nginx['custom_gitlab_server_config'] = "location /-/plantuml/ { \n    proxy_cache off; \n    proxy_pass  http://plantuml:8080/; \n}\n"
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = "smtp.uibk.ac.at"
        gitlab_rails['smtp_port'] = 587
        gitlab_rails['smtp_user_name'] = '$MAIL_USERNAME'
        gitlab_rails['smtp_password'] = '$MAIL_PASSWORD'
        gitlab_rails['smtp_domain'] = "smtp.uibk.ac.at"
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
    ports:
      - '10082:80'
      - '10083:443'
      - '5051:5051'
      - '22:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
      - '$GITLAB_HOME/file-hooks-src:/file-hooks-src'
      - '$GITLAB_HOME/file_hooks:/opt/gitlab/embedded/service/gitlab-rails/file_hooks'
      - '$GITLAB_HOME/data/backups/secrets:/secret/gitlab/backups'
    depends_on:
      - elasticsearch
      - plantuml
  elasticsearch:
    image: 'docker.elastic.co/elasticsearch/elasticsearch:8.8.1'
    container_name: sharing_elasticsearch
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - node.name=es01
      - cluster.name=sharing_elasticsearch
      - discovery.type=single-node
      - xpack.security.enabled=false
    volumes:
      - '$ES_HOME/data:/usr/share/elasticsearch/data'
    ports:  # add this for your local testing setup
        - '9200:9200' # add this for your local testing setup
        - '9300:9300' # add this for your local testing setup
    networks:
       - backend
#      - frontend # add this for your local testing setup

  plantuml:
    image: 'plantuml/plantuml-server:tomcat-v1.2023.1'
    container_name: sharing_plantuml
    restart: always
    networks:
      - backend

networks:
  frontend:
    name: sharing_frontend
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.22.1.0/24
  backend:
    name: sharing_backend
    driver: bridge
    internal: true
    ipam:
      driver: default
      config:
        - subnet: 172.22.2.0/24
