version: '3'

networks:
  longship_network:
    external: true

services:
  wireguard:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/wireguard:2022.14.1.0
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - PEERS=${PEERS}
      - SERVERURL=${SERVERURL} #optional
      - SERVERPORT=${SERVERPORT} #optional
      - PEERDNS=${PEERDNS} #optional
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp   # Wireguard (External)
    expose:    
      - 22   # SSH (Internal)
      - 123  # NTP Service (Internal)
    command: bash startssh 
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: always
    networks:
      longship_network:
        ipv4_address: 172.24.0.2
  db:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/timescale:13.2.0.0
    container_name: timescale
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    expose:
      - 5432 # Postgres (Internal)
    command: postgres -c 'max_connections=300'
    environment:
      - TS_TUNE_MEMORY=3GB
      - TS_TUNE_MAX_BG_WORKERS=2
      - TS_TUNE_NUM_CPUS=1
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    volumes:
      - /opt/inseego/db/postgres-data:/var/lib/postgresql/data
    networks:
      longship_network:
        ipv4_address: 172.24.0.3
  zabbix:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/zabbix:2023.4.1.0
    container_name: zabbix
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    expose:
      - 10051   # ZABBIX Active (Internal)
      - 10050   # ZABBIX Passive (Internal)
    environment:
      - DB_SERVER_HOST=${DB_SERVER_HOST}
      - DB_SERVER_PORT=${DB_SERVER_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - ZBX_DEBUGLEVEL=${ZBX_DEBUGLEVEL}
      - ZBX_CACHESIZE=${ZBX_CACHESIZE}
      - ZBX_STARTTRAPPERS=${ZBX_STARTTRAPPERS}
      - ZBX_HISTORYCACHESIZE=${ZBX_HISTORYCACHESIZE}
      - ZBX_TRENDCACHESIZE=${ZBX_TRENDCACHESIZE}
      - ZBX_HISTORYINDEXCACHESIZE=${ZBX_HISTORYINDEXCACHESIZE}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - db
    links:
      - db
    networks:
      longship_network:
        ipv4_address: 172.24.0.4
  zabbix_ui:
    image: zabbix/zabbix-web-nginx-pgsql:ubuntu-5.4-latest
    container_name: zabbixUI
    restart: always
    environment:
      - DB_SERVER_HOST=${DB_SERVER_HOST}
      - DB_SERVER_PORT=${DB_SERVER_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - ZBX_SERVER_HOST=${ZBX_SERVER_HOST}
      - ZBX_SERVER_PORT=${ZBX_SERVER_PORT}
      - PHP_TZ=${PHP_TZ}
      - ZBX_MEMORYLIMIT=${ZBX_MEMORYLIMIT}
      - ZBX_UPLOADMAXFILESIZE=${ZBX_UPLOADMAXFILESIZE}
      - ZBX_POSTMAXSIZE=${ZBX_POSTMAXSIZE}
      - ZBX_STARTTRAPPERS=${ZBX_STARTTRAPPERS}
      - ZBX_HISTORYCACHESIZE=${ZBX_HISTORYCACHESIZE}
      - ZBX_TRENDCACHESIZE=${ZBX_TRENDCACHESIZE}
      - ZBX_HISTORYINDEXCACHESIZE=${ZBX_HISTORYINDEXCACHESIZE}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - db
      - zabbix
    links:
      - db
      - zabbix
    expose:
      - 8080    # Zabbix UI (Internal)
    networks:
      longship_network:
        ipv4_address: 172.24.0.5       
  back_device:
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE    
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    container_name: backend_device_service
    restart: always
    command: bash -c "service rsyslog restart && chown -Rv _apt:root /app/sdwan_device_service/media  && mkdir -p /app/sdwan_device_service/media/Logs/DeviceSnapshot && mkdir -p /app/sdwan_device_service/media/devicelog  && mkdir -p /app/sdwan_device_service/media/sync-collection  && mkdir -p /app/sdwan_device_service/media/sync-firmware && cd /app/sdwan_device_service && python3.9 manage.py makemigrations && python3.9 manage.py setup_sdwan && cd /app && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0  &&  uwsgi --ini uwsgi.ini"
    expose:
      - 8000    # Backend Device Service Internal
      - 514
      - 514/udp
    depends_on:
      - db
      - zabbix_ui
      - back_user
    links:
      - db
      - zabbix_ui
      - back_user
      - broker
    environment:
      - DB_HOST=${DB_HOST}  # Postgres Host Name
      - DB_PORT=${DB_PORT}  # Postgres Port
      - DB_USER=${DB_USER}  # Postgres User (admin)
      - DB_PASS=${DB_PASS}  # Postgres Password
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}  
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}        
      - BASE_URL=${BASE_URL}  # EM IP or Domain
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}    # Redis (Internal)
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}    # License server public key
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP} 
      - WG_SERVER_IP=${WG_SERVER_IP} 
      - WG_SERVER_USER=${WG_SERVER_USER} 
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD} 
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER} 
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    stdin_open: true
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/srv/nginx-static:/app/sdwan_device_service/static 
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/rsyslog-data:/var/log
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
      - /opt/inseego/srv/ztpfile:/app/ztpkey
      - /opt/inseego/upgrade/migrations:/app/sdwan_device_service/devices/migrations
    networks:
      longship_network:
        ipv4_address: 172.24.0.6   
    tty: true
  broker:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/redis:2022.12.1.0
    container_name: cache
    restart: always
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    volumes:
      - /opt/inseego/db/redis-data:/data    
    expose:
      - 6379    # Redis Port (Internal)
    networks:
      longship_network:
        ipv4_address: 172.24.0.11
  front:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/frontend:${EM_VERSION}
    container_name: frontend
    restart: always
    command: bash -c "npm run start-dev"
    expose:
      - 3000    # React APP (FE port internal)
    environment:
      - NODE_ENV=${NODE_ENV}
      - REACT_APP_API_URL=${REACT_APP_API_URL}
      - REACT_APP_GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - REACT_APP_GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - REACT_APP_GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - REACT_APP_LOGIN_URL=${REACT_APP_LOGIN_URL}
      - REACT_APP_SHOW_SHELL_ACCESS_UI=${REACT_APP_SHOW_SHELL_ACCESS_UI}
      - REACT_APP_IS_ESXI_DEPLOYMENT=${REACT_APP_IS_ESXI_DEPLOYMENT}
      - REACT_APP_TOP_COUNT=20
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    networks:
      longship_network:
        ipv4_address: 172.24.0.7
    depends_on:
      - db
      - zabbix
      - zabbix_ui
    links:
      - db
      - zabbix
      - back_user
      - back_device
  back_user:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    container_name: backend_user_service
    restart: always
    command: bash -c " cd /app/sdwan_user_service && python3.9 manage.py makemigrations users && python3.9 manage.py user_service_setup && cd /app && uwsgi --ini uwsgi_user.ini"
    expose:
      - 8001    # User Service (Internal)
    depends_on:
      - db
      - broker
      - zabbix_ui
    links:
      - db
      - zabbix
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}        
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP} 
      - WG_SERVER_IP=${WG_SERVER_IP} 
      - WG_SERVER_USER=${WG_SERVER_USER} 
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD} 
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT} 
      - ZABBIX_USER=${ZABBIX_USER} 
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    volumes:
      - /opt/inseego/upgrade/migrations1:/app/sdwan_user_service/users/migrations
      - /opt/inseego/srv/ztpfile:/app/ztpkey
    stdin_open: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.8
    tty: true  
  celery_scheduler:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    container_name: celery_beat
    command: bash -c "mkdir -p /app/sdwan_device_service/media/devicelog/ && cd /app/sdwan_device_service && celery -A sdwan_device_service beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}        
      - BASE_URL=${BASE_URL}  
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP} 
      - WG_SERVER_IP=${WG_SERVER_IP} 
      - WG_SERVER_USER=${WG_SERVER_USER} 
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD} 
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT} 
      - ZABBIX_USER=${ZABBIX_USER} 
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - broker
    links:
      - broker
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.10    
  celery_worker:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE    
    container_name: celery_w
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 && cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=gevent --autoscale=4,1 --loglevel=DEBUG"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}        
      - BASE_URL=${BASE_URL}  
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP} 
      - WG_SERVER_IP=${WG_SERVER_IP} 
      - WG_SERVER_USER=${WG_SERVER_USER} 
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD} 
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT} 
      - ZABBIX_USER=${ZABBIX_USER} 
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.12
  celery_worker_wireguard:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_wireguard
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 && cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=solo --concurrency=1 --prefetch-multiplier=1 --loglevel=${LOGGING_LEVEL} --queues=wireguard_config"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.19
  celery_worker_zabbix:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_zabbix
    command:  bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 &&  cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=gevent --autoscale=3,1 --prefetch-multiplier=20 --loglevel=${LOGGING_LEVEL} --queues=zabbix_data"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}        
      - BASE_URL=${BASE_URL}  
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP} 
      - WG_SERVER_IP=${WG_SERVER_IP} 
      - WG_SERVER_USER=${WG_SERVER_USER} 
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD} 
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT} 
      - ZABBIX_USER=${ZABBIX_USER} 
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.13
  celery_worker_qos:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_qos
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 &&  cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=gevent --autoscale=2,1 --prefetch-multiplier=20 --loglevel=${LOGGING_LEVEL} --queues=zabbix_qos"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.16
  celery_worker_device_status:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_device_status
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 &&  cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=gevent --autoscale=2,1 --prefetch-multiplier=20 --loglevel=${LOGGING_LEVEL} --queues=zabbix_device_status"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.17
  celery_worker_tunnel:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_tunnel
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 &&  cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=gevent --autoscale=3,1 --prefetch-multiplier=20 --loglevel=${LOGGING_LEVEL} --queues=zabbix_tunnel"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.18
  nginx:
    container_name: nginx
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/nginx:13.2.0.0
    restart: always
    ports:
      - 7001:7001   # Device Service (Backend User Service/ Device Service External)
      - 443:443   # React APP (FE UI External)
      - 80:80     #ssl renewal
    depends_on:
      - back_user
      - back_device
      - front
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    volumes:
      - /opt/inseego/srv/nginx-static:/app/sdwan_device_service/static
      - /opt/inseego/srv/ztpfile:/app/ztpkey  
      - /opt/inseego/srv/default.conf:/etc/nginx/conf.d/default.conf
      - /ssl/certs:/tmp
      - /letsencrypt:/letsencrypt
      - /letsencrypt/certs:/etc/letsencrypt 
    links:
      - back_device
      - back_user
    networks:
      longship_network:
        ipv4_address: 172.24.0.9
  shell_access:
    container_name: shell_access
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/shell_access:2022.22.1.1
    restart: always
    user: root
    environment:
      - REACT_APP_SHOW_SHELL_ACCESS_UI=${REACT_APP_SHOW_SHELL_ACCESS_UI}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "1"
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    expose:
      - 8080
    volumes:
      - /opt/inseego/etc/guacamole-data/config:/config
    links:
      - front
    networks:
       longship_network:
            ipv4_address: 172.24.0.14
  celery_worker_mail_sending:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_mail_sending
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 && cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=solo --concurrency=1 --prefetch-multiplier=1 --loglevel=${LOGGING_LEVEL} --queues=mail_sending"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.15

  celery_worker_data_usage:
    image: 836891784212.dkr.ecr.us-west-2.amazonaws.com/backend:${EM_VERSION}
    restart: always
    user: root
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    container_name: celery_w_data_usage
    command: bash -c "chown -Rv _apt:root /app/sdwan_device_service/media && ip route add ${INTERNAL_SUBNET}/16 via ${WG_SERVER_IP} dev eth0 && cd /app/sdwan_device_service && celery -A sdwan_device_service worker --pool=solo --concurrency=1 --prefetch-multiplier=1 --loglevel=DEBUG --queues=data_usage"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - POSTGRES_USER=${POSTGRES_USER}   # Postgres User (Super Admin)
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}  # Postgres Password (Super Admin)
      - IS_HTTPS_ENABLE=${IS_HTTPS_ENABLE}
      - DEVICE_SERVICE_PORT_NO=${DEVICE_SERVICE_PORT_NO}
      - SDWAN_ADMIN_USERNAME=${SDWAN_ADMIN_USERNAME}
      - SDWAN_ADMIN_PASSWORD=${SDWAN_ADMIN_PASSWORD}
      - SDWAN_ADMIN_FIRSTNAME=${SDWAN_ADMIN_FIRSTNAME}
      - SDWAN_ADMIN_LASTNAME=${SDWAN_ADMIN_LASTNAME}
      - MA_ADMIN_FIRSTNAME=${MA_ADMIN_FIRSTNAME}
      - MA_ADMIN_LASTNAME=${MA_ADMIN_LASTNAME}
      - BASE_URL=${BASE_URL}
      - ZABBIX_URL=${ZABBIX_URL}
      - BROKER_URL=${BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
      - LICENCE_PUBLIC_KEY=${LICENCE_PUBLIC_KEY}
      - WG_START_PORT=${WG_START_PORT}
      - WG_END_PORT=${WG_END_PORT}
      - SERVER_IP=${SERVER_IP}
      - WG_SERVER_IP=${WG_SERVER_IP}
      - WG_SERVER_USER=${WG_SERVER_USER}
      - WG_SERVER_PASSWORD=${WG_SERVER_PASSWORD}
      - CONTROL_TUNNEL_PORT=${CONTROL_TUNNEL_PORT}
      - ZABBIX_USER=${ZABBIX_USER}
      - ZABBIX_PASSWORD=${ZABBIX_PASSWORD}
      - LOGGING_LEVEL=${LOGGING_LEVEL}
      - GUACAMOLE_API_URL=${GUACAMOLE_API_URL}
      - GUACAMOLE_USERNAME=${GUACAMOLE_USERNAME}
      - GUACAMOLE_PASSWORD=${GUACAMOLE_PASSWORD}
      - EM_VERSION=${EM_VERSION}
      - DEBIAN_REPO_URL=${DEBIAN_REPO_URL}
      - CURRENT_ENV=${CURRENT_ENV}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ZABBIX_SERVER_IP=${ZABBIX_SERVER_IP}
      - ZABBIX_SERVER_USER=${ZABBIX_SERVER_USER}
      - ZABBIX_SERVER_PWD=${ZABBIX_SERVER_PWD}
    logging:
      driver: "${LOG_DRIVER}"
      options:
        max-size: "100m"
        max-file: "5"
    depends_on:
      - broker
      - celery_scheduler
    volumes:
      - /opt/inseego/etc/wireguard-data/config:/config
      - /opt/inseego/media/:/app/sdwan_device_service/media/
      - /opt/inseego/collection/Collections:/app/sdwan_device_service/media/Collections
      - /opt/inseego/log/Logs:/app/sdwan_device_service/media/Logs
      - /opt/inseego/log/devicelog:/app/sdwan_device_service/media/devicelog
    links:
      - broker
      - celery_scheduler
    stdin_open: true
    tty: true
    networks:
      longship_network:
        ipv4_address: 172.24.0.20

