Skip to content

Commit

Permalink
Add containers build based on static binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavlin committed May 12, 2023
1 parent 5bbb248 commit 53310f6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 27 deletions.
95 changes: 69 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -325,47 +325,90 @@ endif

ARCH :=amd64
NWAKU_BASE_TAG := latest_
NWAKU_DIST_TAG := dist_
#nwaku-base-20230502082624_arm64

SHELL := /bin/bash

static-arm64: ARCH :=arm64
static-arm64:
BINARIES := wakunode2 wakunode1 chat2

static-base:
set -x &&\
mkdir -p $${PWD}/vendor-$(ARCH) $${PWD}/build/$(ARCH) &&\
mkdir -p $${PWD}/vendor-$(ARCH) $${PWD}/build/$(ARCH) $${PWD}/nimcache-$(ARCH) &&\
docker run -it --rm\
-v $${PWD}:/home/user/nwaku:z\
-v $${PWD}/vendor-arm64:/home/user/nwaku/vendor:z\
-v $${PWD}/build/arm64:/home/user/nwaku/build:z\
-v $${PWD}/vendor-$(ARCH):/home/user/nwaku/vendor:z\
-v $${PWD}/nimcache-$(ARCH):/home/user/nwaku/nimcache:z\
-v $${PWD}/build/$(ARCH):/home/user/nwaku/build:z\
--workdir /home/user/nwaku\
--user $$(id -u):$$(id -g)\
nwaku:$(NWAKU_BASE_TAG)$(ARCH)\
$(JOBS)\
V=1\
V=1\
LOG_LEVEL="TRACE"\
QUICK_AND_DIRTY_COMPILER=1\
NIMFLAGS="--cpu:arm64 --os:linux --gcc.exe:aarch64-alpine-linux-musl-gcc --gcc.linkerexe:aarch64-alpine-linux-musl-gcc --passL:-static"\
wakunode2
NIMFLAGS="$(NIMFLAGS)"\
$(BINARIES)

static-arm64: ARCH :=arm64
static-arm64: NIMFLAGS := $(NIMFLAGS) --cpu:arm64 --os:linux --gcc.exe:aarch64-alpine-linux-musl-gcc --gcc.linkerexe:aarch64-alpine-linux-musl-gcc --passL:-static
static-arm64:
$(MAKE) $(JOBS) static-base NIMFLAGS="$(NIMFLAGS)" ARCH=$(ARCH)



static-amd64: ARCH :=amd64
static-amd64: NIMFLAGS := $(NIMFLAGS) --cpu:amd64 --os:linux --gcc.exe:x86_64-alpine-linux-musl-gcc --gcc.linkerexe:x86_64-alpine-linux-musl-gcc --passL:-static
static-amd64:
set -x &&\
mkdir -p $${PWD}/vendor-$(ARCH) $${PWD}/build/$(ARCH) &&\
docker run -it --rm\
-v $${PWD}:/home/user/nwaku:z\
-v $${PWD}/vendor-amd64:/home/user/nwaku/vendor:z\
-v $${PWD}/build/amd64:/home/user/nwaku/build:z\
--workdir /home/user/nwaku\
--user $$(id -u):$$(id -g)\
nwaku:$(NWAKU_BASE_TAG)$(ARCH)\
$(JOBS)\
V=1\
LOG_LEVEL="TRACE"\
QUICK_AND_DIRTY_COMPILER=1\
NIMFLAGS="--cpu:amd64 --os:linux --gcc.exe:x86_64-alpine-linux-musl-gcc --gcc.linkerexe:x86_64-alpine-linux-musl-gcc --passL:-static"\
wakunode2

static-all: static-arm64 static-amd64
$(MAKE) $(JOBS) static-base NIMFLAGS="$(NIMFLAGS)" ARCH=$(ARCH)

static-clean:
rm -rf build/arm64 build/amd64 vendor-arm64 vendor-amd64
rm -rf build/arm64 build/amd64 vendor-arm64 vendor-amd64


################################################
# Distributable Artifacts (tars and containers) #
################################################

dist-base:
mkdir -p dist &&\
pushd build/$(ARCH) &&\
tar czf ../../dist/wakunode-$(GIT_VERSION)-$(ARCH).tgz $(BINARIES)

dist-amd64: static-amd64
$(MAKE) $(JOBS) dist-base ARCH=amd64

dist-arm64: static-arm64
$(MAKE) $(JOBS) dist-base ARCH=arm64

dist-container-base:
echo $(ARCH) &&\
ls &&\
cd build/$(ARCH) &&\
docker build -t nwaku:$(NWAKU_DIST_TAG)$(ARCH) -f ../../docker/dist/Dockerfile.$(ARCH) .

dist-container-amd64: | dist-amd64
$(MAKE) $(JOBS) dist-container-base ARCH=amd64

dist-container-arm64: | dist-arm64
$(MAKE) $(JOBS) dist-container-base ARCH=arm64

dist-container:
$(MAKE) $(JOBS) dist-container-amd64
$(MAKE) $(JOBS) dist-container-arm64
docker manifest create quay.io/vpavlin0/nwaku:multiarch \
--amend nwaku:$(NWAKU_DIST_TAG)amd64 \
--amend nwaku:$(NWAKU_DIST_TAG)arm64

###################
# Release Targets #
###################

release-notes:
docker run \
-it \
--rm \
-v $${PWD}:/opt/sv4git/repo:z \
-u $(shell id -u) \
quay.io/vpavlin0/sv4git:latest \
release-notes
2 changes: 1 addition & 1 deletion docker/base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ die() {

trap 'die' SIGINT

make "$@"
make "$@"
5 changes: 5 additions & 0 deletions docker/dist/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM --platform=amd64 alpine:edge

ADD . /usr/local/bin

ENTRYPOINT [ "wakunode2" ]
5 changes: 5 additions & 0 deletions docker/dist/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM --platform=arm64 alpine:edge

ADD . /usr/local/bin

ENTRYPOINT [ "wakunode2" ]

0 comments on commit 53310f6

Please sign in to comment.