version: '3.4'
services:
  bootstrap-router:
    build:
      context: .
      dockerfile: docker/compose/bootstrap.Dockerfile
    image: bootstrap
    cap_add:
      - NET_ADMIN
    devices:
      - "/dev/net/tun:/dev/net/tun"
    ports:
      - target: 1090
        protocol: udp
      - target: 1190
        protocol: tcp
    volumes:
      - bootstrap-dir:/root/.lokinet/
    environment:
      - LOKINET_NETID=docker
    networks:
      testing_net:

  router:
    depends_on:
      - bootstrap-router
    build:
      context: .
      dockerfile: docker/compose/router.Dockerfile
    image: router
    devices:
      - "/dev/net/tun:/dev/net/tun"
    ports:
      - target: 1090
        protocol: udp
        mode: host
      - target: 1190
        protocol: tcp
        mode: host
    cap_add:
      - NET_ADMIN
    volumes:
      - bootstrap-dir:/bootstrap/
    environment:
      - LOKINET_NETID=docker
    networks:
      testing_net:

  client:
    depends_on:
      - bootstrap-router
    build:
      context: .
      dockerfile: docker/compose/router.Dockerfile
    image: router
    devices:
      - "/dev/net/tun:/dev/net/tun"
    ports:
      - target: 1090
        protocol: udp
        mode: host
      - target: 1190
        protocol: tcp
        mode: host
      - target: 53
        protocol: tcp
        mode: host
    cap_add:
      - NET_ADMIN
    volumes:
      - bootstrap-dir:/bootstrap/
    environment:
      - LOKINET_NETID=docker
    networks:
      testing_net:

volumes:
  bootstrap-dir:

networks:
  testing_net:
    driver: bridge
    internal: true
    ipam:
      driver: default
      config:
        - subnet: 172.28.0.0/16
