version: '3.8'
services:
    mysql:
        container_name: "mysql"
        image: mysql:5.7
        volumes:
            - ./database/oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql
            - ./healthscripts/mysql-healthcheck2.sh:/tmp/mysql-healthcheck.sh
        environment:
            - TZ=Europe/Paris
            - MYSQL_DATABASE=oai_db
            - MYSQL_USER=test
            - MYSQL_PASSWORD=test
            - MYSQL_ROOT_PASSWORD=linux
        healthcheck:
            test: /bin/bash -c "/tmp/mysql-healthcheck.sh"
            interval: 10s
            timeout: 5s
            retries: 5
        networks:
            public_net:
                ipv4_address: 192.168.70.131
    oai-udr:
        container_name: "oai-udr"
        image: oai-udr:v1.5.0
        environment:
            - TZ=Europe/Paris
            - INSTANCE=0
            - PID_DIRECTORY=/var/run
            - UDR_NAME=OAI_UDR
            - UDR_INTERFACE_NAME_FOR_NUDR=eth0
            - UDR_INTERFACE_PORT_FOR_NUDR=80
            - UDR_INTERFACE_HTTP2_PORT_FOR_NUDR=8080
            - USE_HTTP2=no
            - UDR_API_VERSION=v1
            - MYSQL_IPV4_ADDRESS=192.168.70.131
            - MYSQL_USER=test
            - MYSQL_PASS=test
            - DB_CONNECTION_TIMEOUT=300 # Reset the connection to the DB after expiring the timeout (in second) currently can't be changed
            - MYSQL_DB=oai_db
            - WAIT_MYSQL=120
            - USE_FQDN_DNS=yes
            - REGISTER_NRF=yes
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - NRF_API_VERSION=v1
            - NRF_FQDN=oai-nrf
        depends_on:
            - mysql
            - oai-nrf
        networks:
            public_net:
                ipv4_address: 192.168.70.136
    oai-udm:
        container_name: "oai-udm"
        image: oai-udm:v1.5.0
        environment:
            - TZ=Europe/Paris
            - INSTANCE=0
            - PID_DIRECTORY=/var/run
            - UDM_NAME=OAI_UDM
            - SBI_IF_NAME=eth0
            - SBI_PORT=80
            - SBI_HTTP2_PORT=8080
            - USE_HTTP2=no
            - UDM_VERSION_NB=v1
            - USE_FQDN_DNS=yes
            - UDR_IP_ADDRESS=192.168.70.136
            - UDR_PORT=80
            - UDR_VERSION_NB=v1
            - UDR_FQDN=oai-udr
            - REGISTER_NRF=yes
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - NRF_API_VERSION=v1
            - NRF_FQDN=oai-nrf
        depends_on:
            - oai-udr
        networks:
            public_net:
                ipv4_address: 192.168.70.137
    oai-ausf:
        container_name: "oai-ausf"
        image: oai-ausf:v1.5.0
        environment:
            - TZ=Europe/Paris
            - INSTANCE_ID=0
            - PID_DIR=/var/run
            - AUSF_NAME=OAI_AUSF
            - SBI_IF_NAME=eth0
            - SBI_PORT=80
            - USE_HTTP2=no
            - SBI_HTTP2_PORT=8080
            - USE_FQDN_DNS=yes
            - UDM_IP_ADDRESS=192.168.70.137
            - UDM_PORT=80
            - UDM_VERSION_NB=v1
            - UDM_FQDN=oai-udm
            - REGISTER_NRF=yes
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - NRF_API_VERSION=v1
            - NRF_FQDN=oai-nrf
        depends_on:
            - oai-udm
        networks:
            public_net:
                ipv4_address: 192.168.70.138
    oai-nrf:
        container_name: "oai-nrf"
        image: oai-nrf:v1.5.0
        environment:
            - TZ=Europe/Paris
            - NRF_INTERFACE_NAME_FOR_SBI=eth0
            - NRF_INTERFACE_PORT_FOR_SBI=80
            - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=8080
            - NRF_API_VERSION=v1
            - INSTANCE=0
            - PID_DIRECTORY=/var/run
        networks:
            public_net:
                ipv4_address: 192.168.70.130
    oai-amf:
        container_name: "oai-amf"
        image: oai-amf:v1.5.0
        environment:
            - TZ=Europe/paris
            - INSTANCE=0
            - PID_DIRECTORY=/var/run
            - MCC=001
            - MNC=01
            - REGION_ID=128
            - AMF_SET_ID=1
            - SERVED_GUAMI_MCC_0=001
            - SERVED_GUAMI_MNC_0=01
            - SERVED_GUAMI_REGION_ID_0=128
            - SERVED_GUAMI_AMF_SET_ID_0=1
            - SERVED_GUAMI_MCC_1=460
            - SERVED_GUAMI_MNC_1=11
            - SERVED_GUAMI_REGION_ID_1=10
            - SERVED_GUAMI_AMF_SET_ID_1=1
            - PLMN_SUPPORT_MCC=001
            - PLMN_SUPPORT_MNC=01
            - PLMN_SUPPORT_TAC=0x0001
            - SST_0=1
            - SD_0=0x1
            - SST_1=1
            - SD_1=0x2
            - SST_2=1
            - SD_2=0x3
            - AMF_INTERFACE_NAME_FOR_NGAP=eth0
            - AMF_INTERFACE_NAME_FOR_N11=eth0
            - SMF_INSTANCE_ID_0=1
            - SMF_FQDN_0=oai-smf
            - SMF_IPV4_ADDR_0=192.168.70.133
            - SMF_HTTP_VERSION_0=v1
            - SELECTED_0=true
            - SMF_INSTANCE_ID_1=2
            - SMF_FQDN_1=oai-smf
            - SMF_IPV4_ADDR_1=0.0.0.0
            - SMF_HTTP_VERSION_1=v1
            - SELECTED_1=false
            - MYSQL_SERVER=192.168.70.131
            - MYSQL_USER=root
            - MYSQL_PASS=linux
            - MYSQL_DB=oai_db
            - OPERATOR_KEY=1006020f0a478bf6b699f15c062e42b3
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - EXTERNAL_NRF=no
            - NF_REGISTRATION=yes
            - SMF_SELECTION=yes
            - USE_FQDN_DNS=yes
            - EXTERNAL_AUSF=yes
            - EXTERNAL_UDM=no
            - EXTERNAL_NSSF=no
            - USE_HTTP2=no
            - NRF_API_VERSION=v1
            - NRF_FQDN=oai-nrf
            - AUSF_IPV4_ADDRESS=192.168.70.138
            - AUSF_PORT=80
            - AUSF_API_VERSION=v1
            - AUSF_FQDN=oai-ausf
            - UDM_IPV4_ADDRESS=192.168.70.137
            - UDM_PORT=80
            - UDM_API_VERSION=v2
            - UDM_FQDN=oai-udm
            - INT_ALGO_LIST=["NIA1", "NIA2"]
            - CIPH_ALGO_LIST=["NEA0", "NEA2"]
        depends_on:
            - mysql
            - oai-nrf
            - oai-ausf
        networks:
            public_net:
                ipv4_address: 192.168.70.132
    oai-smf:
        container_name: "oai-smf"
        image: oai-smf:v1.5.0
        environment:
            - TZ=Europe/Paris
            - INSTANCE=0
            - PID_DIRECTORY=/var/run
            - SMF_INTERFACE_NAME_FOR_N4=eth0
            - SMF_INTERFACE_NAME_FOR_SBI=eth0
            - SMF_INTERFACE_PORT_FOR_SBI=80
            - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
            - SMF_API_VERSION=v1
            - DEFAULT_DNS_IPV4_ADDRESS=8.8.8.8
            - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4
            - AMF_IPV4_ADDRESS=192.168.70.132
            - AMF_PORT=80
            - AMF_API_VERSION=v1
            - AMF_FQDN=oai-amf
            - UDM_IPV4_ADDRESS=192.168.70.137
            - UDM_PORT=80
            - UDM_API_VERSION=v2
            - UDM_FQDN=oai-udm
            - UPF_IPV4_ADDRESS=192.168.70.134
            - UPF_FQDN_0=oai-spgwu
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - NRF_API_VERSION=v1
            - USE_LOCAL_SUBSCRIPTION_INFO=yes  #Set to yes if SMF uses local subscription information instead of from an UDM
            - USE_NETWORK_INSTANCE=no  #Set yes if network instance is to be used for given UPF
            - NRF_FQDN=oai-nrf
            - REGISTER_NRF=yes
            - DISCOVER_UPF=yes
            - USE_FQDN_DNS=yes
            - HTTP_VERSION=1        # Default: 1
            - UE_MTU=1500
            - DNN_NI0=oai
            - TYPE0=IPv4
            - DNN_RANGE0=12.1.1.2 - 12.1.1.253
            - NSSAI_SST0=1
            - NSSAI_SD0=0x1
            - SESSION_AMBR_UL0=10000Mbps
            - SESSION_AMBR_DL0=10000Mbps
            - DNN_NI1=oai2
            - TYPE1=IPv4
            - DNN_RANGE1=12.1.2.2 - 12.1.2.253
            - NSSAI_SST1=1
            - NSSAI_SD1=0x2
            - SESSION_AMBR_UL1=10000Mbps
            - SESSION_AMBR_DL1=10000Mbps
            - DNN_NI2=oai3
            - TYPE2=IPv4
            - DNN_RANGE2=12.1.3.2 - 12.1.3.253
            - NSSAI_SST2=1
            - NSSAI_SD2=0x3
            - SESSION_AMBR_UL2=10000Mbps
            - SESSION_AMBR_DL2=10000Mbps
            - DNN_NI3=ims
            - TYPE3=IPv4v6
            - DNN_RANGE3=14.1.1.2 - 14.1.1.253
            - DEFAULT_CSCF_IPV4_ADDRESS=127.0.0.1  # only needed when ims is being used
            - ENABLE_USAGE_REPORTING=no # Set yes if UE USAGE REPORTING is to be done at UPF
        depends_on:
            - oai-nrf
            - oai-amf
        networks:
            public_net:
                ipv4_address: 192.168.70.133
    oai-spgwu:
        container_name: "oai-spgwu"
        image: oai-spgwu-tiny:v1.5.0
        environment:
            - TZ=Europe/Paris
            - PID_DIRECTORY=/var/run
            - SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0
            - SGW_INTERFACE_NAME_FOR_SX=eth0
            - PGW_INTERFACE_NAME_FOR_SGI=eth0
            - NETWORK_UE_NAT_OPTION=yes
            - NETWORK_UE_IP=12.1.1.0/24
            - SPGWC0_IP_ADDRESS=192.168.70.133
            - BYPASS_UL_PFCP_RULES=no
            - MCC=001
            - MNC=01
            - MNC03=001
            - TAC=1
            - GW_ID=1
            - THREAD_S1U_PRIO=80
            - S1U_THREADS=8
            - THREAD_SX_PRIO=81
            - SX_THREADS=1
            - THREAD_SGI_PRIO=80
            - SGI_THREADS=8
            - REALM=openairinterface.org
            - ENABLE_5G_FEATURES=yes
            - REGISTER_NRF=yes
            - USE_FQDN_NRF=yes
            - UPF_FQDN_5G=oai-spgwu
            - NRF_IPV4_ADDRESS=192.168.70.130
            - NRF_PORT=80
            - NRF_API_VERSION=v1
            - NRF_FQDN=oai-nrf
            - NSSAI_SST_0=1
            - NSSAI_SD_0=0x1
            - DNN_0=oai
            - NSSAI_SST_1=1
            - NSSAI_SD_1=0x2
            - DNN_1=oai2
            - NSSAI_SST_2=1
            - NSSAI_SD_2=0x3
            - DNN_2=oai3
        depends_on:
            - oai-nrf
            - oai-smf
        cap_add:
            - NET_ADMIN
            - SYS_ADMIN
        cap_drop:
            - ALL
        privileged: true
        networks:
            public_net:
                ipv4_address: 192.168.70.134
    oai-ext-dn:
        image: trf-gen-cn5g:latest
        privileged: true
        container_name: oai-ext-dn
        entrypoint: /bin/bash -c \
              "ip route add 12.1.1.0/24 via 192.168.70.134 dev eth0; sleep infinity"
        depends_on:
            - oai-spgwu
        healthcheck:
            test: /bin/bash -c "ip r | grep 12.1.1"
            interval: 10s
            timeout: 5s
            retries: 5
        networks:
            public_net:
                ipv4_address: 192.168.70.135
networks:
    # public_net:
    #     external:
    #         name: demo-oai-public-net
    public_net:
        driver: bridge
        name: demo-oai-public-net
        ipam:
            config:
                - subnet: 192.168.70.128/26
        driver_opts:
            com.docker.network.bridge.name: "demo-oai"
