# VERSION=latest
# DATA_PREFIX=/usr/local/goedge
# NETWORK_PREFIX=172.20.0
# DB_NAME=edges
# DB_PASSWORD=123456

name: goedge-instance

networks:
  goedge:
    name: goedge
    driver: bridge
    ipam:
      driver: default
      config:
        - gateway: ${NETWORK_PREFIX}.1
          subnet: ${NETWORK_PREFIX}.0/24
    driver_opts:
      com.docker.network.bridge.name: goedge

services:
  db:
    container_name: goedge-mysql
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
    volumes:
      - ${DATA_PREFIX}/mysql/data:/var/lib/mysql
      - ${DATA_PREFIX}/mysql/conf.d:/etc/mysql/conf.d
    networks:
      goedge:
        ipv4_address: ${NETWORK_PREFIX}.2

  instance:
    container_name: goedge-instance
    image: goedge/edge-instance
    restart: always
    networks:
      goedge:
        ipv4_address: ${NETWORK_PREFIX}.3
    environment:
      - EDGE_DB_HOST=${NETWORK_PREFIX}.2
      - EDGE_DB_PASSWORD=${DB_PASSWORD}
      - EDGE_DB_NAME=${DB_NAME}
      - EDGE_HTTP_FIREWALL_ENDPOINT=${HTTP_FIREWALL_ENDPOINT}
    ports:
      - 7788:7788
      - 7799:7799
      - 8001:8001
      - 8002:8002
      - 80:80
      - 443:443
    volumes:
      - ${DATA_PREFIX}/cache:/opt/cache
      - ${DATA_PREFIX}/edge-admin/logs:/usr/local/goedge/edge-admin/logs
      - ${DATA_PREFIX}/edge-admin/configs:/usr/local/goedge/edge-admin/configs
      - ${DATA_PREFIX}/edge-api/logs:/usr/local/goedge/edge-api/logs
      - ${DATA_PREFIX}/edge-api/configs:/usr/local/goedge/edge-api/configs
      - ${DATA_PREFIX}/edge-node/logs:/usr/local/goedge/edge-node/logs
      - ${DATA_PREFIX}/edge-node/configs:/usr/local/goedge/edge-node/configs
      - ${DATA_PREFIX}/edge-node/data:/usr/local/goedge/edge-node/data
      - ${DATA_PREFIX}/edge-user/logs:/usr/local/goedge/edge-user/logs
      - ${DATA_PREFIX}/edge-user/configs:/usr/local/goedge/edge-user/configs
    depends_on:
      - db