version: '3.8'
services:
    cicd_mysql:
        container_name: cicd-mysql-svr
        image: mysql:5.7
        ports:
             - 3306
        command: --init-file /docker-entrypoint-initdb.d/oai_db.sql
        volumes:
            - ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql:rw
        environment:
            - TZ=Europe/Paris
            - MYSQL_DATABASE=oai_db
            - MYSQL_USER=test
            - MYSQL_PASSWORD=test
            - MYSQL_ROOT_PASSWORD=linux
        healthcheck:
            test: "/usr/bin/mysql --user=root --password=linux -e 'show databases;'"
            interval: 10s
            timeout: 5s
            retries: 5
        networks:
            cicd_public_net:
                ipv4_address: 192.168.61.194

    cicd_oai_amf:
        container_name: cicd-oai-amf
        image: oai-amf:AMF_IMAGE_TAG
        ports:
             - 38412
             - 80
        command: >
            bash -c "nohup tshark -i eth0 -w /tmp/amf.pcap 2>&1 > /dev/null &
            /openair-amf/bin/oai_amf -c /openair-amf/etc/amf.conf -o | tee /tmp/amf.log 2>&1
            "
        cap_add:
            - NET_ADMIN
        environment:
            - INSTANCE=1
            - PID_DIRECTORY=/var/run
            - MCC=208
            - MNC=95
            - REGION_ID=128
            - AMF_SET_ID=1
            - SERVED_GUAMI_MCC_0=208
            - SERVED_GUAMI_MNC_0=95
            - 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=208
            - PLMN_SUPPORT_MNC=95
            - PLMN_SUPPORT_TAC=0xa000
            - SST_0=222
            - SD_0=123
            - SST_1=1
            - SD_1=12
            - AMF_INTERFACE_NAME_FOR_NGAP=eth0
            - AMF_INTERFACE_NAME_FOR_N11=eth0
            - SMF_INSTANCE_ID_0=1
            - SMF_FQDN_0=localhost
            - SMF_IPV4_ADDR_0=192.168.18.184
            - SMF_HTTP_VERSION_0=v1
            - SELECTED_0=true
            - SMF_INSTANCE_ID_1=2
            - SMF_FQDN_1=localhost
            - SMF_IPV4_ADDR_1=0.0.0.0
            - SMF_HTTP_VERSION_1=v1
            - SELECTED_1=false
            - MYSQL_SERVER=cicd-mysql-svr
            - MYSQL_USER=root
            - MYSQL_PASS=linux
            - MYSQL_DB=oai_db
            - OPERATOR_KEY=63bfa50ee6523365ff14c1f45f88737d
            - NRF_IPV4_ADDRESS=0.0.0.0
            - NRF_PORT=80
            - NF_REGISTRATION=no
            - SMF_SELECTION=no
            - USE_FQDN_DNS=no
            - NRF_API_VERSION=v1
            - NRF_FQDN=localhost
            - AUSF_IPV4_ADDRESS=0.0.0.0
            - AUSF_PORT=80
            - AUSF_API_VERSION=v1
            - AUSF_FQDN=localhost
            - NSSF_IPV4_ADDRESS=0.0.0.0
            - NSSF_PORT=80
            - NSSF_API_VERSION=v1
            - NSSF_FQDN=localhost
        depends_on:
            - cicd_mysql
        networks:
            cicd_public_net:
                ipv4_address: 192.168.61.196
        volumes:
            - ./amf-healthy-check.sh:/openair-amf/bin/amf-healthy-check.sh
        healthcheck:
            test: /bin/bash -c "/openair-amf/bin/amf-healthy-check.sh"
            interval: 10s
            timeout: 5s
            retries: 5

networks:
    cicd_public_net:
        name: cicd-oai-public-net
        driver: bridge
        ipam:
            config:
                - subnet: 192.168.61.192/26


