Browse Source

Merge pull request #36 from supermock/master

N2N Builder adjustments for local repository
master
Luca Deri 6 years ago
committed by GitHub
parent
commit
268308607d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .dockerignore
  2. 48
      Makefile
  3. 2
      README.md
  4. 22
      image-platforms/Dockerfile.arm32v7
  5. 22
      image-platforms/Dockerfile.x86_64
  6. 6
      image-platforms/common/dependencies.pkglist
  7. 8
      image-platforms/common/prepare-build.sh

1
.dockerignore

@ -0,0 +1 @@
build

48
Makefile

@ -1,5 +1,5 @@
N2N_VERSION=2.3.0 N2N_VERSION=2.3.0
N2N_OSNAME=$(shell uname -p) N2N_OSNAME=$(shell uname)
######## ########
@ -106,13 +106,15 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
$(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/
# Docker builder section # Docker builder section
DOCKER_IMAGE_NAME=ntop/supernode DOCKER_IMAGE_NAME=supermock/supernode
DOCKER_IMAGE_VERSION=$N2N_VERSION DOCKER_IMAGE_VERSION=v$(N2N_VERSION)
N2N_COMMIT_HASH=21055550f3392235a1b41d71257e9dc9ead0dfa0
default: steps pre_platforms:
if [ ! "$(N2N_COMMIT_HASH)" = "" ]; then \
echo -n "Are you sure you want to build the hash commit, with the version 2.3 tag, if it is not right, change the N2N_VERSION environment variable in the Makefile. (y/n) " && read sure && [ $$sure == y ]; \
fi
steps: platforms: pre_platforms
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)" = "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 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
@ -122,22 +124,28 @@ build:
docker build --target builder --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) . 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) docker container create --name n2n-builder $(DOCKER_IMAGE_TAGNAME)
if [ ! -d "./build" ]; then mkdir ./build; fi if [ ! -d "./build" ]; then mkdir ./build; fi
docker container cp builder:/usr/src/n2n/supernode ./build/supernode-$(OS)$(ARCHITECTURE) docker container cp n2n-builder:/usr/src/n2n/supernode ./build/supernode-$(OS)$(ARCHITECTURE)
docker container cp builder:/usr/src/n2n/edge ./build/edge-$(OS)$(ARCHITECTURE) docker container cp n2n-builder:/usr/src/n2n/edge ./build/edge-$(OS)$(ARCHITECTURE)
docker container rm -f builder docker container rm -f n2n-builder
docker build --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) . docker build --cache-from $(DOCKER_IMAGE_TAGNAME) \
docker tag $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest$(ARCHITECTURE) --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) \
-t $(DOCKER_IMAGE_TAGNAME) \
push: -t $(DOCKER_IMAGE_NAME):latest$(ARCHITECTURE) \
if [ ! "$(TARGET_ARCHITECTURE)" = "" ]; then \ -f image-platforms/$(DOCKER_IMAGE_FILENAME) .
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-$(TARGET_ARCHITECTURE); \
docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE); \ pre_push:
else \ if [ "$(TARGET_ARCHITECTURE)" = "" ]; then \
echo "Please pass TARGET_ARCHITECTURE, see README.md."; \ echo "Please pass TARGET_ARCHITECTURE, see README.md."; \
exit 1; \
fi fi
.PHONY: steps build push push: pre_push
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-$(TARGET_ARCHITECTURE)
docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE)
.PHONY: pre_platforms platforms build pre_push push
.SILENT: pre_platforms pre_push
# End Docker builder section # End Docker builder section

2
README.md

@ -128,7 +128,7 @@ $ docker run --rm -d -p 5645:5645/udp -p 7654:7654/udp supermock/supernode:[TAGN
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 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 ```sh
$ TARGET_ARCHITECTURE=[arm32v7, x86_64, (nothing to build all architectures)] make $ N2N_COMMIT_HASH=[(optional)] TARGET_ARCHITECTURE=[arm32v7, x86_64, (nothing to build all architectures)] make platforms
``` ```
### 2. Push it ### 2. Push it

22
image-platforms/Dockerfile.arm32v7

@ -1,20 +1,20 @@
FROM multiarch/debian-debootstrap:armhf-stretch AS builder FROM multiarch/debian-debootstrap:armhf-stretch AS builder
ARG DEBIAN_FRONTEND=noninteractive
COPY ./image-platforms/common/dependencies.pkglist /tmp
RUN apt-get update \
&& cat tmp/dependencies.pkglist | xargs apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ARG COMMIT_HASH ARG COMMIT_HASH
WORKDIR /usr/src COPY ./ /usr/src/n2n
RUN apt-get update && apt-get install -y \ WORKDIR /usr/src/n2n
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 RUN chmod +x image-platforms/common/prepare-build.sh && image-platforms/common/prepare-build.sh
FROM arm32v7/debian:stretch FROM arm32v7/debian:stretch
COPY --from=builder /usr/src/n2n/supernode /usr/bin COPY --from=builder /usr/src/n2n/supernode /usr/bin

22
image-platforms/Dockerfile.x86_64

@ -1,20 +1,20 @@
FROM debian:stretch AS builder FROM debian:stretch AS builder
ARG DEBIAN_FRONTEND=noninteractive
COPY ./image-platforms/common/dependencies.pkglist /tmp
RUN apt-get update \
&& cat tmp/dependencies.pkglist | xargs apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ARG COMMIT_HASH ARG COMMIT_HASH
WORKDIR /usr/src COPY ./ /usr/src/n2n
RUN apt-get update && apt-get install -y \ WORKDIR /usr/src/n2n
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 RUN chmod +x image-platforms/common/prepare-build.sh && image-platforms/common/prepare-build.sh
FROM debian:stretch FROM debian:stretch
COPY --from=builder /usr/src/n2n/supernode /usr/bin COPY --from=builder /usr/src/n2n/supernode /usr/bin

6
image-platforms/common/dependencies.pkglist

@ -0,0 +1,6 @@
gcc
libc6-dev
libssl-dev
ca-certificates
git
make

8
image-platforms/common/prepare-build.sh

@ -0,0 +1,8 @@
#!/bin/bash
if [ ! "$COMMIT_HASH" = "" ]; then
echo "Using COMMIT_HASH=$COMMIT_HASH"
git reset --hard $COMMIT_HASH
fi
make
Loading…
Cancel
Save