networks:
  fips-net:
    name: ${FIPS_NETWORK:-fips-sidecar-net}
    driver: bridge
    ipam:
      config:
        - subnet: ${FIPS_SUBNET:-172.20.1.0/24}

services:
  fips:
    image: fips-test:latest
    hostname: fips-sidecar
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
    restart: "no"
    environment:
      - RUST_LOG=${RUST_LOG:-info}
      - FIPS_TEST_MODE=sidecar
      - FIPS_NSEC=${FIPS_NSEC}
      - FIPS_PEER_NPUB=${FIPS_PEER_NPUB:-}
      - FIPS_PEER_ADDR=${FIPS_PEER_ADDR:-}
      - FIPS_PEER_ALIAS=${FIPS_PEER_ALIAS:-peer}
      - FIPS_UDP_BIND=${FIPS_UDP_BIND:-0.0.0.0:2121}
      - FIPS_TUN_MTU=${FIPS_TUN_MTU:-1280}
      - FIPS_PEER_TRANSPORT=${FIPS_PEER_TRANSPORT:-udp}
    networks:
      fips-net:
        ipv4_address: ${FIPS_IPV4:-172.20.1.20}

  app:
    image: fips-test-app:latest
    network_mode: "service:fips"
    depends_on:
      - fips
    volumes:
      - ../docker/resolv.conf:/etc/resolv.conf:ro
    command: ["sleep", "infinity"]
