services:
  wireguard-ui:
    container_name: ${CONTAINER_NAME}
    restart: always
    depends_on:
      - wireguard
    cap_add:
      - NET_ADMIN
    network_mode: service:wireguard
    environment:
      - SENDGRID_API_KEY
      - EMAIL_FROM_ADDRESS
      - EMAIL_FROM_NAME
      - SESSION_SECRET
      - WGUI_USERNAME=${WEBUI_USER}
      - WGUI_PASSWORD=${WEBUI_PWD}
      - WG_CONF_TEMPLATE
      - WGUI_MANAGE_START=false
      - WGUI_MANAGE_RESTART=true
      - WGUI_SERVER_LISTEN_PORT=${PANEL_APP_PORT_WIREGUARD}
      - BIND_ADDRESS=0.0.0.0:${PANEL_APP_PORT_HTTP}
    volumes:
      - ./data/db:/app/db
      - ./data/config:/etc/wireguard
    image: ngoduykhanh/wireguard-ui:latest
    logging:
      driver: json-file
      options:
        max-size: 50m
    labels:  
      createdBy: "Apps"

  wireguard:
    container_name: ${CONTAINER_NAME}-wireguard
    restart: always
    networks:
      - 1panel-network
    cap_add:
      - NET_ADMIN
    volumes:
      - ./data/config:/config
    ports:
      - "${PANEL_APP_PORT_HTTP}:${PANEL_APP_PORT_HTTP}"
      - "${PANEL_APP_PORT_WIREGUARD}:${PANEL_APP_PORT_WIREGUARD}/udp"
    environment:
      - PUID=1000
      - PGID=1000
      - PEERS=1
      - SERVERPORT=${PANEL_APP_PORT_WIREGUARD}
    image: linuxserver/wireguard:latest
    labels:  
      createdBy: "Apps"

networks:  
  1panel-network:  
    external: true
