diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e1d9441 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +DOCKER_IMAGE_NAME=supermock/supernode +DOCKER_IMAGE_VERSION=v2 +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 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$(ARCHITECTURE) + docker container cp builder:/usr/src/n2n/edge ./build/edge$(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 +.SILENT: \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e1f932 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Supernode Docker Image (Image based on Debian) + +## About the project + +This repository is just a project builder (https://github.com/ntop/n2n), any problem should be reported to the source repository unless it is about building it. I have no link with the owners of the code I just set up a constructor, which also makes a supernode container available. + +## 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/) + +## 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] +``` + +## Contributions + +Just download the code make your change and send a pull request explaining the purpose if it is a bug or an improvement and etc... After this will be analyzed to be approved. Note: If it is a major change, open a issue explaining what will be done so you do not waste your precious time developing something that will not be used. Make yourself at home! + +## License + +MIT \ No newline at end of file diff --git a/image-platforms/Dockerfile.arm32v7 b/image-platforms/Dockerfile.arm32v7 new file mode 100644 index 0000000..b7be82f --- /dev/null +++ b/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"] \ No newline at end of file diff --git a/image-platforms/Dockerfile.x86_64 b/image-platforms/Dockerfile.x86_64 new file mode 100644 index 0000000..0d95895 --- /dev/null +++ b/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"] \ No newline at end of file