diff --git a/Documentation/Building-Multi-Arch.md b/Documentation/Building-Multi-Arch.md new file mode 100644 index 00000000..82a57286 --- /dev/null +++ b/Documentation/Building-Multi-Arch.md @@ -0,0 +1,55 @@ +# BUILDING MULTI-ARCHITECTURE IMAGES + +While the Docker images for Fission can be built by running: + +``` +make image +``` + +the stable images are build for multiple architectures (and automatically pushed to the repository) by + +``` +make images-multiarch +``` + +However, there are several options and requirements for building these images, which are explained here. + +## BUILDERS + +We use `docker buildx` to build images for multiple architectures. At the moment, this is considered an +experimental feature by Docker, and as such it requires access to experimental features to be enabled +in the daemon.json file. + +By default, this will use BuildKit and QEMU emulation support to build the image for each architecture +locally. However, for faster building, it is possible to use native nodes to build each architecture, +either simple remote Docker instances or a Kubernetes cluster. For information on how to set this up, +please see the blog article here: + + + +And/or the command reference here: + + + +## BUILD OPTIONS + +### PLATFORMS + +The PLATFORMS variable can be set to a comma-separated list of platforms for which images should be +built when running the multi-arch build. If unset, it defaults to _linux/amd64,linux/arm64,linux/arm_. + +### REPOSITORY SELECTION + +By default, the multi-arch build will automatically try to push the resulting images to the fission/* +repositories, under the dev tag; i.e. fission/fission-bundle:dev, fission/fetcher:dev, and +fission/builder:dev. However, for convenient, this can be customized by setting the REPO and TAG +environment variables to set a different repository prefix and tag for the images. + +For example: + +``` +REPO=randomdev TAG=test make images-multiarch +``` + +would build and push the images randomdev/fission-bundle:test, randomdev/fetcher:test, and +randomdev/builder:test . Private Docker repositories can be used in the same manner. diff --git a/Makefile b/Makefile index bbd806a9..1eb6c610 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,13 @@ .DEFAULT_GOAL := check +# Platforms to build in multi-architecture images. +PLATFORMS ?= linux/amd64,linux/arm64,linux/arm + +# Repository prefix and tag to push multi-architecture images to. +REPO ?= fission +TAG ?= dev + check: test-run build clean # run basic check scripts @@ -41,6 +48,13 @@ image: docker build -t fetcher -f cmd/fetcher/Dockerfile.fission-fetcher . docker build -t builder -f cmd/builder/Dockerfile.fission-builder . +# build multi-architecture images for release. +image-multiarch: + docker buildx build --platform=$(PLATFORMS) -t $(REPO)/fission-bundle:$(TAG) --push -f cmd/fission-bundle/Dockerfile.fission-bundle . + docker buildx build --platform=$(PLATFORMS) -t $(REPO)/fetcher:$(TAG) --push -f cmd/fetcher/Dockerfile.fission-fetcher . + docker buildx build --platform=$(PLATFORMS) -t $(REPO)/builder:$(TAG) --push -f cmd/builder/Dockerfile.fission-builder . + docker buildx build --platform=$(PLATFORMS) -t $(REPO)/preupgradechecks:$(TAG) --push -f cmd/preupgradechecks/Dockerfile.fission-preupgradechecks . + clean: @rm -f cmd/fission-bundle/fission-bundle @rm -f cmd/fission-cli/fission diff --git a/cmd/builder/Dockerfile.fission-builder b/cmd/builder/Dockerfile.fission-builder index fc259c39..502c3b97 100644 --- a/cmd/builder/Dockerfile.fission-builder +++ b/cmd/builder/Dockerfile.fission-builder @@ -31,7 +31,7 @@ ARG BUILDVERSION=unknown ARG BUILDDATE=unknown # E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ +RUN CGO_ENABLED=0 go build \ -o /go/bin/builder \ -gcflags=-trimpath=$GOPATH \ -asmflags=-trimpath=$GOPATH \ diff --git a/cmd/fetcher/Dockerfile.fission-fetcher b/cmd/fetcher/Dockerfile.fission-fetcher index 2bf9e63c..ae70951a 100644 --- a/cmd/fetcher/Dockerfile.fission-fetcher +++ b/cmd/fetcher/Dockerfile.fission-fetcher @@ -31,7 +31,7 @@ ARG BUILDVERSION=unknown ARG BUILDDATE=unknown # E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ +RUN CGO_ENABLED=0 go build \ -o /go/bin/fetcher \ -gcflags=-trimpath=$GOPATH \ -asmflags=-trimpath=$GOPATH \ diff --git a/cmd/fission-bundle/Dockerfile.fission-bundle b/cmd/fission-bundle/Dockerfile.fission-bundle index e6d87646..98f9f411 100644 --- a/cmd/fission-bundle/Dockerfile.fission-bundle +++ b/cmd/fission-bundle/Dockerfile.fission-bundle @@ -31,7 +31,7 @@ ARG BUILDVERSION=unknown ARG BUILDDATE=unknown # E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ +RUN CGO_ENABLED=0 go build \ -o /go/bin/fission-bundle \ -gcflags=-trimpath=$GOPATH \ -asmflags=-trimpath=$GOPATH \ diff --git a/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks b/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks index 297dede2..f6c32061 100644 --- a/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks +++ b/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks @@ -31,7 +31,7 @@ ARG BUILDVERSION=unknown ARG BUILDDATE=unknown # E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ +RUN CGO_ENABLED=0 go build \ -o /go/bin/pre-upgrade-checks \ -gcflags=-trimpath=$GOPATH \ -asmflags=-trimpath=$GOPATH \