Browse Source

Merge pull request #33 from supermock/merge-n2n-builder

Merge n2n builder
pull/36/head
Luca Deri 6 years ago
committed by GitHub
parent
commit
2c77a1b3f4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 38
      Makefile
  3. 54
      README.md
  4. 25
      image-platforms/Dockerfile.arm32v7
  5. 25
      image-platforms/Dockerfile.x86_64

1
.gitignore

@ -0,0 +1 @@
build

38
Makefile

@ -1,4 +1,3 @@
N2N_VERSION=2.3.0
N2N_OSNAME=$(shell uname -p)
@ -105,3 +104,40 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/
# Docker builder section
DOCKER_IMAGE_NAME=ntop/supernode
DOCKER_IMAGE_VERSION=$N2N_VERSION
N2N_COMMIT_HASH=21055550f3392235a1b41d71257e9dc9ead0dfa0
default: steps
steps:
if [ "$(TARGET_ARCHITECTURE)" = "arm32v7" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.arm32v7" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-arm32v7 make build; fi
if [ "$(TARGET_ARCHITECTURE)" = "x86_64" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.x86_64" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-x86_64 make build; fi
build:
$(eval OS := $(shell uname -s))
$(eval ARCHITECTURE := $(shell export DOCKER_IMAGE_TAGNAME="$(DOCKER_IMAGE_TAGNAME)"; echo $$DOCKER_IMAGE_TAGNAME | grep -oe -.*))
docker build --target builder --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) .
docker container create --name builder $(DOCKER_IMAGE_TAGNAME)
if [ ! -d "./build" ]; then mkdir ./build; fi
docker container cp builder:/usr/src/n2n/supernode ./build/supernode-$(OS)$(ARCHITECTURE)
docker container cp builder:/usr/src/n2n/edge ./build/edge-$(OS)$(ARCHITECTURE)
docker container rm -f builder
docker build --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) .
docker tag $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest$(ARCHITECTURE)
push:
if [ ! "$(TARGET_ARCHITECTURE)" = "" ]; then \
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-$(TARGET_ARCHITECTURE); \
docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE); \
else \
echo "Please pass TARGET_ARCHITECTURE, see README.md."; \
fi
.PHONY: steps build push
# End Docker builder section

54
README.md

@ -1,3 +1,5 @@
# N2N
Edge node
---------
@ -5,11 +7,14 @@ You need to start an edge node on each host you want to connect with the *same*
community.
Enable the edge process
```
```sh
$ sudo ./edge -d n2n0 -c mynetwork -k encryptme -u 99 -g 99 -m 3C:A0:12:34:56:78 -a 1.2.3.4 -l a.b.c.d:xyw
```
or
```
```sh
$ N2N_KEY=encryptme sudo ./edge -d n2n0 -c mynetwork -u 99 -g 99 -m 3C:A0:12:34:56:78 -a 1.2.3.4 -l a.b.c.d:xyw
```
@ -17,7 +22,6 @@ By defaul the edge will run in background but you can use the `-f` option to kee
Note that `-d`, `-u`, `-g` and `-f` options are not available for Windows.
Supernode
--------
@ -25,8 +29,6 @@ You need to start the supernode once (no need to be root unless you want to use
1. `./supernode -l 1234 -v`
Dropping Root Privileges and SUID-Root Executables (UNIX)
--------------------------------------------------
@ -106,6 +108,44 @@ AES (-O3) 12532
TF (-O3) 14046
NULL (-O3) 10659
-----------------
# N2N Builder (Supernode Docker Image based on Debian)
## Running the supernode image
```sh
$ docker run --rm -d -p 5645:5645/udp -p 7654:7654/udp supermock/supernode:[TAGNAME]
```
## Docker registry
- [DockerHub](https://hub.docker.com/r/supermock/supernode/)
- [DockerStore](https://store.docker.com/community/images/supermock/supernode/)
(C) 2007-18 - ntop.org and contributors
## Documentation
### 1. Build image and binaries
Use `make` command to build the images. Before starting the arm32v7 platform build, you need to run this registry, so you can perform a cross-build. Just follow the documentation: https://github.com/multiarch/qemu-user-static/blob/master/README.md
```sh
$ TARGET_ARCHITECTURE=[arm32v7, x86_64, (nothing to build all architectures)] make
```
### 2. Push it
Use `make push` command to push the image, TARGET_ARCHITECTURE is necessary.
```sh
$ TARGET_ARCHITECTURE=[arm32v7, x86_64] make push
```
### 3. Test it
Once the image is built, it's ready to run:
```sh
$ docker run --rm -d -p 5645:5645/udp -p 7654:7654/udp supermock/supernode:[TAGNAME]
```
-----------------
(C) 2007-2018 - ntop.org and contributors

25
image-platforms/Dockerfile.arm32v7

@ -0,0 +1,25 @@
FROM multiarch/debian-debootstrap:armhf-stretch AS builder
ARG COMMIT_HASH
WORKDIR /usr/src
RUN apt-get update && apt-get install -y \
gcc \
libc6-dev \
libssl-dev \
ca-certificates \
git \
make \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/ntop/n2n && cd n2n && git reset --hard $COMMIT_HASH && make
FROM arm32v7/debian:stretch
COPY --from=builder /usr/src/n2n/supernode /usr/bin
EXPOSE 7654 7654/udp
EXPOSE 5645 5645/udp
ENTRYPOINT ["/usr/bin/supernode", "-f"]

25
image-platforms/Dockerfile.x86_64

@ -0,0 +1,25 @@
FROM debian:stretch AS builder
ARG COMMIT_HASH
WORKDIR /usr/src
RUN apt-get update && apt-get install -y \
gcc \
libc6-dev \
libssl-dev \
ca-certificates \
git \
make \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/ntop/n2n && cd n2n && git reset --hard $COMMIT_HASH && make
FROM debian:stretch
COPY --from=builder /usr/src/n2n/supernode /usr/bin
EXPOSE 7654 7654/udp
EXPOSE 5645 5645/udp
ENTRYPOINT ["/usr/bin/supernode", "-f"]
Loading…
Cancel
Save