services:
    mysql:
        container_name: "rfsim5g-mysql"
        image: mysql:8.0
        init: true
        volumes:
            - ../5g_rfsimulator/oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql
            - ../5g_rfsimulator/mysql-healthcheck.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"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 30
        networks:
            core_net:
                ipv4_address: 192.168.71.131
    oai-amf:
        container_name: "rfsim5g-oai-amf"
        image: oaisoftwarealliance/oai-amf:v2.1.10
        environment:
            - TZ=Europe/paris
        volumes:
            - ./mini_nonrf_config_3slices.yaml:/openair-amf/etc/config.yaml
        depends_on:
            - mysql
        networks:
            core_net:
                ipv4_address: 192.168.71.132
    oai-smf:
        container_name: "rfsim5g-oai-smf"
        image: oaisoftwarealliance/oai-smf:v2.1.10
        environment:
            - TZ=Europe/Paris
        volumes:
            - ./mini_nonrf_config_3slices.yaml:/openair-smf/etc/config.yaml
        depends_on:
            - oai-amf
        networks:
            core_net:
                ipv4_address: 192.168.71.133
    oai-upf:
        container_name: "rfsim5g-oai-upf"
        image: oaisoftwarealliance/oai-upf:v2.1.10
        init: true
        environment:
            - TZ=Europe/Paris
        volumes:
            - ./mini_nonrf_config_3slices.yaml:/openair-upf/etc/config.yaml
        depends_on:
            - oai-smf
        cap_add:
            - NET_ADMIN
            - SYS_ADMIN
        cap_drop:
            - ALL
        privileged: true
        networks:
            core_net:
                ipv4_address: 192.168.71.134
                interface_name: eth0
            traffic_net:
                ipv4_address: 192.168.72.134
                interface_name: eth1

    oai-cucp:
        image: ${REGISTRY-oaisoftwarealliance/}${GNB_IMG:-oai-gnb}:${TAG:-develop}
        container_name: rfsim5g-oai-cucp
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2
                                    --gNBs.[0].local_s_address 192.168.72.2
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-upf
        networks:
            core_net:
                ipv4_address: 192.168.71.150
            f1c_net:
                ipv4_address: 192.168.72.2
            e1_net:
                ipv4_address: 192.168.77.2
        volumes:
            - ../../conf_files/gnb-cucp.sa.f1.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-softmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-cuup:
        image: ${REGISTRY-oaisoftwarealliance/}${NRCUUP_IMG:-oai-nr-cuup}:${TAG:-develop}
        container_name: rfsim5g-oai-cuup
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.3
                                    --gNBs.[0].local_s_address 192.168.73.2
                                    --gNBs.[0].remote_s_address 127.0.0.1
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
        networks:
            core_net:
                ipv4_address: 192.168.71.161
            f1u_1_net:
                ipv4_address: 192.168.73.2
            e1_net:
                ipv4_address: 192.168.77.3
        volumes:
            - ../../conf_files/gnb-cuup.sa.f1.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-cuup"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-cuup2:
        image: ${REGISTRY-oaisoftwarealliance/}${NRCUUP_IMG:-oai-nr-cuup}:${TAG:-develop}
        container_name: rfsim5g-oai-cuup2
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].gNB_CU_UP_ID 0xe01
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.4
                                    --gNBs.[0].local_s_address 192.168.74.2
                                    --gNBs.[0].remote_s_address 127.0.0.1
                                    --gNBs.[0].NETWORK_INTERFACES.GNB_IPV4_ADDRESS_FOR_NGU 192.168.71.162
                                    --gNBs.[0].plmn_list.[0].snssaiList.[0].sst 2
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
        networks:
            core_net:
                ipv4_address: 192.168.71.162
            f1u_2_net:
                ipv4_address: 192.168.74.2
            e1_net:
                ipv4_address: 192.168.77.4
        volumes:
            - ../../conf_files/gnb-cuup.sa.f1.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-cuup"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-cuup3:
        image: ${REGISTRY-oaisoftwarealliance/}${NRCUUP_IMG:-oai-nr-cuup}:${TAG:-develop}
        container_name: rfsim5g-oai-cuup3
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].gNB_CU_UP_ID 0xe02
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2
                                    --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.5
                                    --gNBs.[0].local_s_address 192.168.76.2
                                    --gNBs.[0].remote_s_address 127.0.0.1
                                    --gNBs.[0].NETWORK_INTERFACES.GNB_IPV4_ADDRESS_FOR_NGU 192.168.71.163
                                    --gNBs.[0].plmn_list.[0].snssaiList.[0].sst 3
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
        networks:
            core_net:
                ipv4_address: 192.168.71.163
            f1u_3_net:
                ipv4_address: 192.168.76.2
            e1_net:
                ipv4_address: 192.168.77.5
        volumes:
            - ../../conf_files/gnb-cuup.sa.f1.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-cuup"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-du:
        image: ${REGISTRY-oaisoftwarealliance/}${GNB_IMG:-oai-gnb}:${TAG:-develop}
        container_name: rfsim5g-oai-du
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    --MACRLCs.[0].local_n_address 192.168.72.3
                                    --MACRLCs.[0].remote_n_address oai-cucp
                                    --MACRLCs.[0].local_n_address_f1u 192.168.73.3
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
            - oai-cuup
        networks:
            f1c_net:
                ipv4_address: 192.168.72.3
            f1u_1_net:
                ipv4_address: 192.168.73.3
            ue_net:
                ipv4_address: 192.168.78.2
        volumes:
            - ../../conf_files/gnb-du.sa.band78.106prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-softmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-du2:
        image: ${REGISTRY-oaisoftwarealliance/}${GNB_IMG:-oai-gnb}:${TAG:-develop}
        container_name: rfsim5g-oai-du2
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].gNB_DU_ID 0xe01
                                    --gNBs.[0].nr_cellid 87654321
                                    --gNBs.[0].servingCellConfigCommon.[0].physCellId 1
                                    --MACRLCs.[0].remote_n_address oai-cucp
                                    --MACRLCs.[0].local_n_address 192.168.72.4
                                    --MACRLCs.[0].local_n_address_f1u 192.168.74.3
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
            - oai-cuup2
        networks:
            f1c_net:
                ipv4_address: 192.168.72.4
            f1u_2_net:
                ipv4_address: 192.168.74.3
            ue_net:
                ipv4_address: 192.168.78.3
        volumes:
            - ../../conf_files/gnb-du.sa.band78.106prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-softmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-du3:
        image: ${REGISTRY-oaisoftwarealliance/}${GNB_IMG:-oai-gnb}:${TAG:-develop}
        container_name: rfsim5g-oai-du3
        cap_drop:
            - ALL
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    --gNBs.[0].gNB_DU_ID 0xe02
                                    --gNBs.[0].nr_cellid 11111111
                                    --gNBs.[0].servingCellConfigCommon.[0].physCellId 2
                                    --MACRLCs.[0].remote_n_address oai-cucp
                                    --MACRLCs.[0].local_n_address 192.168.72.5
                                    --MACRLCs.[0].local_n_address_f1u 192.168.76.3
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-cucp
            - oai-cuup3
        networks:
            f1c_net:
                ipv4_address: 192.168.72.5
            f1u_3_net:
                ipv4_address: 192.168.76.3
            ue_net:
                ipv4_address: 192.168.78.4
        volumes:
            - ../../conf_files/gnb-du.sa.band78.106prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-softmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-nr-ue:
        image: ${REGISTRY-oaisoftwarealliance/}${NRUE_IMG:-oai-nr-ue}:${TAG:-develop}
        container_name: rfsim5g-oai-nr-ue
        cap_drop:
            - ALL
        cap_add:
            - NET_ADMIN  # for interface bringup
            - NET_RAW    # for ping
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    -r 106 --numerology 1 -C 3619200000
                                    --uicc0.imsi 208990100001100
                                    --rfsimulator.[0].serveraddr oai-du
        depends_on:
            - oai-du
        networks:
            ue_net:
                ipv4_address: 192.168.78.5
        devices:
             - /dev/net/tun:/dev/net/tun
        volumes:
            - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-uesoftmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-nr-ue2:
        image: ${REGISTRY-oaisoftwarealliance/}${NRUE_IMG:-oai-nr-ue}:${TAG:-develop}
        container_name: rfsim5g-oai-nr-ue2
        cap_drop:
            - ALL
        cap_add:
            - NET_ADMIN  # for interface bringup
            - NET_RAW    # for ping
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    -r 106 --numerology 1 -C 3619200000
                                    --uicc0.imsi 208990100001101 --uicc0.pdu_sessions.[0].nssai_sst 2
                                    --rfsimulator.[0].serveraddr 192.168.78.3
        depends_on:
            - oai-du2
        networks:
            ue_net:
                ipv4_address: 192.168.78.6
        devices:
             - /dev/net/tun:/dev/net/tun
        volumes:
            - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-uesoftmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

    oai-nr-ue3:
        image: ${REGISTRY-oaisoftwarealliance/}${NRUE_IMG:-oai-nr-ue}:${TAG:-develop}
        container_name: rfsim5g-oai-nr-ue3
        cap_drop:
            - ALL
        cap_add:
            - NET_ADMIN  # for interface bringup
            - NET_RAW    # for ping
        environment:
            USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time
                                    -r 106 --numerology 1 -C 3619200000
                                    --uicc0.imsi 208990100001102 --uicc0.pdu_sessions.[0].nssai_sst 3
                                    --rfsimulator.[0].serveraddr 192.168.78.4
            ASAN_OPTIONS: detect_leaks=0
        depends_on:
            - oai-du3
        networks:
            ue_net:
                ipv4_address: 192.168.78.7
        devices:
             - /dev/net/tun:/dev/net/tun
        volumes:
            - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf
        healthcheck:
            test: /bin/bash -c "pgrep nr-uesoftmodem"
            start_period: 10s
            start_interval: 500ms
            interval: 10s
            timeout: 5s
            retries: 5

networks:
    core_net:
        driver: bridge
        name: rfsim5g-oai-core-net
        ipam:
            config:
                - subnet: 192.168.71.128/26
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-core"
    traffic_net:
        driver: bridge
        name: rfsim5g-oai-traffic-net
        ipam:
            config:
                - subnet: 192.168.72.128/26
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-traffic"
    f1c_net:
        driver: bridge
        name: rfsim5g-oai-f1c-net
        ipam:
            config:
                - subnet: 192.168.72.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-f1c"
    f1u_1_net:
        driver: bridge
        name: rfsim5g-oai-f1u-1-net
        ipam:
            config:
                - subnet: 192.168.73.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-f1u_1"
    f1u_2_net:
        driver: bridge
        name: rfsim5g-oai-f1u-2-net
        ipam:
            config:
                - subnet: 192.168.74.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-f1u_2"
    f1u_3_net:
        driver: bridge
        name: rfsim5g-oai-f1u-3-net
        ipam:
            config:
                - subnet: 192.168.76.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-f1u_3"
    e1_net:
        driver: bridge
        name: rfsim5g-oai-e1-net
        ipam:
            config:
                - subnet: 192.168.77.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-e1"
    ue_net:
        driver: bridge
        name: rfsim5g-oai-ue-net
        ipam:
            config:
                - subnet: 192.168.78.0/28
        driver_opts:
            com.docker.network.bridge.name: "rfsim5g-ue"
