Docker image builds (and localdev starts) fail if BASE_IMAGE env var not defined
richscott opened this issue · 0 comments
richscott commented
Armada uses the goreleaser
tool to build Docker images. In the .goreleaser
configuration file, it defines BASE_IMAGE_ARG
if BASE_IMAGE
env variable is defined (surrounding entries deleted for brevity):
env:
- BASE_IMAGE_ARG={{ if index .Env "BASE_IMAGE" }}BASE_IMAGE={{ .Env.BASE_IMAGE }}{{ else }}{{ end }}
and later references it:
dockers:
- id: bundle
build_flag_templates: &BUILD_FLAG_TEMPLATES
- --build-arg={{ .Env.BASE_IMAGE_ARG }}
- --builder={{ .Env.DOCKER_BUILDX_BUILDER }}
When BASE_IMAGE
is not defined when a user runs mage localdev full
to install andstart a local Armada cluster, it results in the following error:
• docker images
• building docker image image=gresearch/armada-jobservice:latest
• building docker image image=gresearch/armada-lookout-bundle:latest
• building docker image image=gresearch/armada-bundle:latest
⨯ release failed after 31s error=docker build failed: failed to build gresearch/armada-jobservice:latest: exit status 1: ERROR: invalid key-value pair "": empty key
Adding a --verbose
option to the invocation of goreleaser in magefiles/goreleaser.go
shows that Goreleaser is constructing a faulty invocation (see the --build-arg=
):
• running cmd=[docker buildx] cwd=/tmp/goreleaserdocker2205406399 args=[--builder default build . --load -t gresearch/armada-jobservice:latest -t gresearch/armada-jobservice:0.4.12-SNAPSHOT-d48147ed --build-arg= --builder=default --cache-to=type=inline --cache-from=type=inline --label=org.opencontainers.image.source=https://github.com/armadaproject/armada --label=org.opencontainers.image.version=0.4.12-SNAPSHOT-d48147ed --label=org.opencontainers.image.created=2024-01-24T22:34:50Z --label=org.opencontainers.image.revision=d48147ed7947ab30343ade2f4d4c9d49563d64b4 --label=org.opencontainers.image.base.name=alpine:3.18.3 --label=org.opencontainers.image.licenses=Apache-2.0 --label=org.opencontainers.image.vendor=G-Research]