version: '3.5'
services:
  gitsearch-app:
    image: sharing-codeability.uibk.ac.at:5051/sharing/codeability-sharing-platform/gitsearch/$GITBRANCH
    container_name: sharing_search
    hostname: sharing_search
    environment:
      - _JAVA_OPTIONS=-Xmx512m -Xms256m
      - SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}
      - MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
      - SPRING_DATASOURCE_URL=jdbc:mysql://sharing_mysql:3306/gitsearch?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
      - JHIPSTER_SLEEP=5 # gives a small time for other services to boot before the application
      - SPRING_DATA_JEST_URI=http://sharing_elasticsearch:9200
      - SPRING_ELASTICSEARCH_REST_URIS=http://sharing_elasticsearch:9200
      # see https://stackoverflow.com/questions/62676762/how-can-a-variable-set-in-the-docker-env-file-be-used-in-application-yml
      - JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET=${JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET}
      - SECURITY_OAUTH2_CLIENT_PROVIDER_GITLABOIDC_ISSUERURI=${SECURITY_OAUTH2_CLIENT_PROVIDER_GITLABOIDC_ISSUERURI}
      - SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLABOIDC_CLIENTID=${SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLABOIDC_CLIENTID}
      - SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLABOIDC_CLIENTSECRET=${SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLABOIDC_CLIENTSECRET}
      - APPLICATION_GITLAB_GENERALACCESSTOKEN=${APPLICATION_GITLAB_GENERALACCESSTOKEN}
      - APPLICATION_GITLAB_ADMINACCESSTOKEN=${APPLICATION_GITLAB_ADMINACCESSTOKEN}
      - CONNECTOR_ARTEMIS_TOKEN=${CONNECTOR_ARTEMIS_TOKEN}
      - gitBranch=${GIT_BRANCH}
      - gitCommitId=${COMMIT_ID}
      - gitCommitDate=${COMMIT_DATE}
      #KEYCLOAK
      # - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=http://keycloak:9080/auth/realms/jhipster
      # - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=web_app
      # - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=web_app

    restart: always
    ports:
      - 10084:8080
    networks:
      - backend
      - frontend
  sharing_mysql:
    image: mysql:8.0.20
    container_name: sharing_mysql
    hostname: sharing_mysql
    volumes:
      - '$MYSQL_HOME:/var/lib/mysql/'
    environment:
      - MYSQL_USER=root
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_DATABASE=gitsearch
    command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
    restart: always
    networks:
      - backend
  # keycloak:
  #   image: jboss/keycloak:16.1.0
  #   command:
  #     [
  #       '-b',
  #       '0.0.0.0',
  #       '-Dkeycloak.migration.action=import',
  #       '-Dkeycloak.migration.provider=dir',
  #       '-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config',
  #       '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING',
  #       '-Djboss.socket.binding.port-offset=1000',
  #       '-Dkeycloak.profile.feature.upload_scripts=enabled',
  #     ]
  #   volumes:
  #     - ./realm-config:/opt/jboss/keycloak/realm-config
  #   environment:
  #     - KEYCLOAK_USER=admin
  #     - KEYCLOAK_PASSWORD=admin
  #     - DB_VENDOR=h2
  #   # If you want to expose these ports outside your dev PC,
  #   # remove the "127.0.0.1:" prefix
  #   ports:
  #     - 127.0.0.1:9080:9080
  #     - 127.0.0.1:9443:9443
  #     - 127.0.0.1:10990:10990
  #   networks:
  #     - backend
  #     - frontend
networks:
  frontend:
    name: sharing_frontend
    driver: bridge
  backend:
    name: sharing_backend
    driver: bridge
    internal: true
