version: '3.4'
services:

  artemis:
    container_name: anartemis
    image: apache/activemq-artemis:2.30.0
    restart: always
    profiles: ["dev", "prod"]
    ports:
    - 8161:8161
    - 61616:61616
    - 61613:61613
    volumes:
    -  /var/log/activemq:/var/log/activemq
    networks:
    -  back
      
  nginx:
    container_name: anginx
    image: nginx
    restart: always
    profiles: ["dev", "prod"]
    ports:
    - 80:80
    - 443:443
    volumes:
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    - ./nginx/certificates:/etc/nginx/certificates
    - ../../org.etsi.osl.portal.web/src:/webstatic/nfvportal
    - ../../org.etsi.osl.tmf.web/dist/org.etsi.osl.tmf.web:/webstatic/services
    networks:
    - front
    
  mysql-portal:
    container_name: amysql
    restart: always
    image: mysql:5.7.43
    profiles: ["dev", "prod"]
    environment:
      MYSQL_ROOT_PASSWORD: letmein
#      MYSQL_DATABASE: osdb
#      MYSQL_USER: portaluser
#      MYSQL_PASSWORD: 12345
      MYSQL_ROOT_HOST: "%"
    ports:
    -  "13306:3306"
    volumes:
    -  ~/mysql/data:/var/lib/mysql
    - ./mysql-init:/docker-entrypoint-initdb.d
    networks:
    -  back

  keycloak:
      container_name: keycloak
      image: jboss/keycloak:16.1.1
      restart: always
      profiles: ["dev", "prod"]
      environment:
        DB_VENDOR: MYSQL
        DB_ADDR: amysql
        DB_DATABASE: keycloak
        DB_USER: keycloak
        DB_PASSWORD: password
        KEYCLOAK_USER: admin
        KEYCLOAK_PASSWORD: Pa55w0rd
        JDBC_PARAMS: "useSSL=false"
        JAVA_OPTS: "-server -Xms512m -Xmx2048m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+UseAdaptiveSizePolicy -XX:MaxMetaspaceSize=1024m -Djava.net.preferIPv4Stack=true -Djboss.as.management.blocking.timeout=3600"
        KEYCLOAK_IMPORT: /tmp/realm-export.json
        PROXY_ADDRESS_FORWARDING: "true"
      volumes:
      - ./keycloak-init:/tmp
      ports:
        - 8080:8080
        - 8443:8443
      depends_on:
        - mysql-portal
      networks:
        - front
        - back

     
  osportalapi:
    container_name: openslice-portalapi
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.portal.api/
        dockerfile: Dockerfile        
    image: org.etsi.osl.portal.api:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "origins": "http://localhost",
        "spring.datasource.url": "jdbc:mysql://amysql/osdb?createDatabaseIfNotExist=true",
        "spring.datasource.username":"root",
        "spring.datasource.password":"letmein",
        "spring-addons.issuers[0].uri": "http://keycloak:8080/auth/realms/openslice",
        "spring-addons.issuers[0].username-json-path":"$.preferred_username",
        "spring-addons.issuers[0].claims[0].jsonPath":"$.realm_access.roles",
        "spring-addons.issuers[0].claims[1].jsonPath":"$.resource_access.*.roles",
        "spring.security.oauth2.resourceserver.jwt.issuer-uri": "http://keycloak:8080/auth/realms/openslice",
        "springdoc.oAuthFlow.authorizationUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/auth",
        "springdoc.oAuthFlow.tokenUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/token",        
        "springdoc.oauth.client-id" : "osapiWebClientId",
        "springdoc.oauth.clientsecret" : "secret",
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO",
        "spring.portal.main.domain": "http://localhost",
        "spring.portal.portal.title": "Openslice",
        "server.forward-headers-strategy":"FRAMEWORK"
      }'
    logging:
      driver: "json-file"
      options:
        max-size: "1g"
        max-file: "3"
    volumes:
    - ./repo:/root
    ports:
    - 13000:13000
    networks:
    - front
    - back
    depends_on:
    - mysql-portal


  manoclient:
    container_name: manoclient
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.mano/
        dockerfile: Dockerfile        
    image: org.etsi.osl.mano:latest
    environment:
       SPRING_APPLICATION_JSON: '{
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO"
      }'
    logging:
      driver: "json-file"
      options:
        max-size: "1g"
        max-file: "3"      
    ports:
    - 13011:13011
    networks:
    - back
    

  bugzilla:
    container_name: abugzilla
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.bugzilla/
        dockerfile: Dockerfile        
    image: org.etsi.osl.bugzilla:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "bugzillaurl":"",
        "bugzillakey":"",
        "main_operations_product":""
      }'
    ports:
    - 13010:13010
    networks:
    - front
    - back
  
 
  
 
  osscapi:
    container_name: openslice-scapi
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.tmf.api/
        dockerfile: Dockerfile      
    image: org.etsi.osl.tmf.api:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "origins": "http://localhost",
        "spring.datasource.url": "jdbc:mysql://amysql/ostmfdb?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC",
        "spring.datasource.username":"root",
        "spring.datasource.password":"letmein",
        "spring-addons.issuers[0].uri": "http://keycloak:8080/auth/realms/openslice",
        "spring-addons.issuers[0].username-json-path":"$.preferred_username",
        "spring-addons.issuers[0].claims[0].jsonPath":"$.realm_access.roles",
        "spring-addons.issuers[0].claims[1].jsonPath":"$.resource_access.*.roles",
        "spring.security.oauth2.resourceserver.jwt.issuer-uri": "http://keycloak:8080/auth/realms/openslice",
        "springdoc.oAuthFlow.authorizationUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/auth",
        "springdoc.oAuthFlow.tokenUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/token",        
        "springdoc.oauth.client-id" : "osapiWebClientId",
        "springdoc.oauth.clientsecret" : "secret",
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO",      
        "kroki.serverurl" : "http://localhost/kroki",
        "server.forward-headers-strategy":"FRAMEWORK"  
      }'
    volumes:
    - ./repo:/root
    ports:
    - 13082:13082
    networks:
    - front
    - back
    depends_on:
    - mysql-portal   


  osom:
    container_name: openslice-osom
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.osom/
        dockerfile: Dockerfile      
    image: org.etsi.osl.osom:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO"        
      }'
    volumes:
    - ./repo:/root
    ports:
    - 13100:13100
    networks:
    - front
    - back
    depends_on:
    - mysql-portal


  oasapi:
    container_name: openslice-oasapi
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.oas/
        dockerfile: Dockerfile      
    image: org.etsi.osl.oas:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "origins": "http://localhost",
        "spring.datasource.url": "jdbc:mysql://amysql/ostmfdb?createDatabaseIfNotExist=true&useUnicode=true&nullCatalogMeansCurrent=true&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC",
        "spring.datasource.username":"root",
        "spring.datasource.password":"letmein",
        "spring-addons.issuers[0].uri": "http://keycloak:8080/auth/realms/openslice",
        "spring-addons.issuers[0].username-json-path":"$.preferred_username",
        "spring-addons.issuers[0].claims[0].jsonPath":"$.realm_access.roles",
        "spring-addons.issuers[0].claims[1].jsonPath":"$.resource_access.*.roles",
        "spring.security.oauth2.resourceserver.jwt.issuer-uri": "http://keycloak:8080/auth/realms/openslice",
        "springdoc.oAuthFlow.authorizationUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/auth",
        "springdoc.oAuthFlow.tokenUrl": "http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/token",        
        "springdoc.oauth.client-id" : "osapiWebClientId",
        "springdoc.oauth.clientsecret" : "secret",
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO",
        "server.forward-headers-strategy":"FRAMEWORK"        
      }'
    volumes:
    - ./repo:/root
    ports:
    - 13101:13101
    networks:
    - front
    - back

  cridge:
    container_name: openslice-cridge
    restart: always
    profiles: [ "prod"]
    build:
        context:  ../../org.etsi.osl.cridge/
        dockerfile: Dockerfile      
    image: org.etsi.osl.cridge:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "logging.level.org.springframework" : "INFO",
        "org.etsi.osl.cridge" : "DEBUG"          
      }'
    networks:
    - front
    - back
    volumes:
    - ./kubedir/:/root/.kube
    depends_on:
    - osscapi


    
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:2.18.4
    restart: always
    profiles: ["dev", "prod"]
    networks:
      - front
    ports:
    - 9000:9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

  centrallog:
    container_name: centrallog
    restart: always
    profiles: ["prod"]
    build:
        context:  ../../org.etsi.osl.centrallog.service/
        dockerfile: Dockerfile        
    image: org.etsi.osl.centrallog.service:latest
    environment:
      SPRING_APPLICATION_JSON: '{
        "spring.activemq.brokerUrl": "tcp://anartemis:61616?jms.watchTopicAdvisories=false",
        "spring.activemq.user": "artemis",
        "spring.activemq.password": "artemis",
        "centrallogurl":"http://elk_ip:elk_port/index_name/_doc",
        "logging.level.org.springframework" : "INFO"
      }'
    ports:
    - 13013:13013
    networks:
    - back
      
  kroki:
    container_name: kroki
    restart: always
    image: yuzutech/kroki:0.18.0
    profiles: ["dev", "prod"]
    depends_on:
      - blockdiag
    environment:
      - KROKI_BLOCKDIAG_HOST=blockdiag
    ports:
      - "8000:8000"
    networks:
    - front
    - back


  blockdiag:
    image: yuzutech/kroki-blockdiag:0.18.0
    restart: always
    profiles: ["dev", "prod"]
    expose:
      - "8001"
    networks:
    - front
    - back

      
networks:
  front:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1450
  back:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1450


volumes:
  portainer_data:
  
