build.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. set -e -x
  3. rm -rf ./build
  4. mkdir ./build
  5. # TODO: Assumes your docker bridge network is a /24, and the first container that launches will be .1
  6. # - We could make this better by launching the lighthouse first and then fetching what IP it is.
  7. NET="$(docker network inspect bridge -f '{{ range .IPAM.Config }}{{ .Subnet }}{{ end }}' | cut -d. -f1-3)"
  8. (
  9. cd build
  10. cp ../../../../build/linux-amd64/nebula .
  11. cp ../../../../build/linux-amd64/nebula-cert .
  12. if [ "$1" ]
  13. then
  14. cp "../../../../build/$1/nebula" "$1-nebula"
  15. fi
  16. HOST="lighthouse1" \
  17. AM_LIGHTHOUSE=true \
  18. ../genconfig.sh >lighthouse1.yml
  19. HOST="host2" \
  20. LIGHTHOUSES="192.168.100.1 $NET.2:4242" \
  21. ../genconfig.sh >host2.yml
  22. HOST="host3" \
  23. LIGHTHOUSES="192.168.100.1 $NET.2:4242" \
  24. INBOUND='[{"port": "any", "proto": "icmp", "group": "lighthouse"}]' \
  25. ../genconfig.sh >host3.yml
  26. HOST="host4" \
  27. LIGHTHOUSES="192.168.100.1 $NET.2:4242" \
  28. OUTBOUND='[{"port": "any", "proto": "icmp", "group": "lighthouse"}]' \
  29. ../genconfig.sh >host4.yml
  30. ../../../../nebula-cert ca -curve "${CURVE:-25519}" -name "Smoke Test"
  31. ../../../../nebula-cert sign -name "lighthouse1" -groups "lighthouse,lighthouse1" -ip "192.168.100.1/24"
  32. ../../../../nebula-cert sign -name "host2" -groups "host,host2" -ip "192.168.100.2/24"
  33. ../../../../nebula-cert sign -name "host3" -groups "host,host3" -ip "192.168.100.3/24"
  34. ../../../../nebula-cert sign -name "host4" -groups "host,host4" -ip "192.168.100.4/24"
  35. )
  36. docker build -t "nebula:${NAME:-smoke}" .