Files
Cam Hutchison 0bdb62aa7f build: Remove docker builder from building buildboxes (#38952)
Do not specify the docker builder via `--builder` when using `docker
buildx`, as the method of determine the builder name is flawed and is
having local developer impact. The original reason for adding it was to
fix the CI build of the FIPS buildbox as building the FIPS buildbox
requires using the local docker image cache which is only available with
the `docker` builder.

Instead unify the centos7 and centos7-fips Dockerfiles and use
`--target` to select which bit to build up to for the `buildbox-centos7`
and `buildbox-centos7-fips` targets. As as multi-stage build, the
`docker-container` driver now does see the base buildbox and builds a
correct buildbox when not pushing to the registry (as occurs at the
start of tag builds). This is the recommended method in the Docker
documentation, with a more complex alternative being "bake files". They
are more appropriate when the separate image builds are rather separate.
In our case, the two are closely related and work well with the simpler
multi-stage build approach.

This approach should work for any of the docker builders used and allows
developers to select whichever builder works for them, while on CI we
will continue to use the `docker` default builder.

Remove the `PULL_ON_CI` logic as that is not needed because of the use
of `--cache-from` and `-cache-to` used for all buildboxes.

Use a `make` trick in `build.assets/arch.mk` to only run `go env GOARCH`
once max, or not at all if not needed, and use `GOTOOLCHAIN=local` so we
don't update the go toolchain unnecessarily. The GitHub Actions runner
has an older version of Go than we specify in our `go.mod` so every time
`make` ran on a fresh runner, it would download go1.22.0 even though it
was not needed.
2024-03-05 19:56:37 +00:00

17 lines
654 B
Makefile

# These variables are extracted from build.assets/Makefile so they can be imported
# by other Makefiles
# Eval $(ARCH) one time max, or not at all if $(ARCH) is not used.
# Calling `go` can emit an error if not installed, which we do not
# want to do if $(ARCH) is never used.
# https://make.mad-scientist.net/deferred-simple-variable-expansion/
ARCH = $(eval ARCH := $$(shell GOTOOLCHAIN=local go env GOARCH))$(ARCH)
HOST_ARCH := $(shell uname -m)
RUNTIME_ARCH_x86_64 := amd64
# uname returns different value on Linux (aarch64) and macOS (arm64).
RUNTIME_ARCH_arm64 := arm64
RUNTIME_ARCH_aarch64 := arm64
RUNTIME_ARCH := $(RUNTIME_ARCH_$(HOST_ARCH))