From dea1ff26fd9c1f3357d8a955f62ca36d6601525f Mon Sep 17 00:00:00 2001 From: SuperMock Date: Thu, 1 Mar 2018 20:18:12 -0300 Subject: [PATCH 1/4] Initial commit --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..28036a1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 SuperMock + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 13a3d986f41a4d0e9f2bf06c8d12ca8bbae84353 Mon Sep 17 00:00:00 2001 From: Otavio Tomasevic Date: Thu, 1 Mar 2018 20:46:10 -0300 Subject: [PATCH 2/4] n2n v2 --- .gitignore | 1 + Makefile | 34 ++++++++++++++++++++ README.md | 50 ++++++++++++++++++++++++++++++ image-platforms/Dockerfile.arm32v7 | 25 +++++++++++++++ image-platforms/Dockerfile.x86_64 | 25 +++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 image-platforms/Dockerfile.arm32v7 create mode 100644 image-platforms/Dockerfile.x86_64 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 From 0a5a0dc5e77e5154dd5ddd149e5bd5e4176dae20 Mon Sep 17 00:00:00 2001 From: Otavio Tomasevic Date: Thu, 1 Mar 2018 20:57:13 -0300 Subject: [PATCH 3/4] Fixed 'make push' command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e1d9441..ccbb5b2 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ build: push: if [ ! "$(TARGET_ARCHITECTURE)" = "" ]; then \ docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-$(TARGET_ARCHITECTURE); \ - docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE) \ + docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE); \ else \ echo "Please pass TARGET_ARCHITECTURE, see README.md."; \ fi From 954c4dd975f2c466089c05a8f2e059fdad434982 Mon Sep 17 00:00:00 2001 From: Otavio Tomasevic Date: Sun, 4 Mar 2018 20:41:51 -0300 Subject: [PATCH 4/4] Added the system name in the file name --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ccbb5b2..70cbf21 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,15 @@ steps: 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$(ARCHITECTURE) - docker container cp builder:/usr/src/n2n/edge ./build/edge$(ARCHITECTURE) + 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) .