Updates required for multi-architecture builds. (#1891)
Co-authored-by: Rahul Bhati <rjbhati009@gmail.com>
This commit is contained in:
co-authored by
Rahul Bhati
parent
ef83d4314e
commit
e0522cc20e
@@ -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:
|
||||
|
||||
<https://www.docker.com/blog/multi-arch-images/>
|
||||
|
||||
And/or the command reference here:
|
||||
|
||||
<https://docs.docker.com/engine/reference/commandline/buildx_create/>
|
||||
|
||||
## 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.
|
||||
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user