eager-dress-66405
03/02/2022, 5:46 AM...
[docker]
build_args.add = [
"BASE_PYTHON_IMAGE=foo",
]
`pants.ci.toml`:
...
[docker]
# Expose aws auth to docker.
build_args.add = [
"AWS_DEFAULT_REGION",
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
]
`Dockerfile`:
ARG BASE_PYTHON_IMAGE
FROM ${BASE_PYTHON_IMAGE}
...
Running in CI:
$ export PANTS_CONFIG_FILES=pants.ci.toml
$ ./pants package docker/image:target
...
failed to solve with frontend dockerfile.v0: failed to create LLB definition: base name (${BASE_PYTHON_IMAGE}) should not be blank
...
eager-dress-66405
03/02/2022, 5:48 AMbuild_args
and build_args.add
eager-dress-66405
03/02/2022, 5:49 AMeager-dress-66405
03/02/2022, 5:53 AMCOMMIT_SHA
is defined in pant.toml
) with a build arg that I'm using in an image tag I get this error:
Traceback (most recent call last):
File "/github/home/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0+git57344e8f_py38/lib/python3.8/site-packages/pants/engine/internals/selectors.py", line 705, in native_engine_generator_send
res = func.send(arg)
File "/github/home/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0+git57344e8f_py38/lib/python3.8/site-packages/pants/backend/docker/goals/package_image.py", line 227, in build_docker_image
tags = field_set.image_refs(
File "/github/home/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0+git57344e8f_py38/lib/python3.8/site-packages/pants/backend/docker/goals/package_image.py", line 158, in image_refs
image_names = tuple(
File "/github/home/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0+git57344e8f_py38/lib/python3.8/site-packages/pants/backend/docker/goals/package_image.py", line 159, in <genexpr>
":".join(s for s in [repository, self.format_tag(tag, version_context)] if s)
File "/github/home/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0+git57344e8f_py38/lib/python3.8/site-packages/pants/backend/docker/goals/package_image.py", line 98, in format_tag
raise DockerImageTagValueError(msg) from e
pants.backend.docker.goals.package_image.DockerImageTagValueError: Invalid tag value for the `image_tags` field of the `docker_image` target at src/infra/pipeline/annotator:annotator: '{build_args.COMMIT_SHA}'.
The build arg 'COMMIT_SHA' is undefined. Defined build args are: AWS_ACCESS_KEY_ID, AWS_DEFAULT_REGION, AWS_ROLE_ARN, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_WEB_IDENTITY_TOKEN_FILE.
This build arg may be defined in `pants.toml` under `[docker].build_args`, on the command line with `--docker-build-args` or directly on the `docker_image` target using the `extra_build_args` field.
fast-nail-55400
03/02/2022, 1:48 PM--docker-build-args
?
$ export PANTS_CONFIG_FILES=pants.ci.toml
$ ./pants help docker
fast-nail-55400
03/02/2022, 1:58 PMwitty-family-13337
03/02/2022, 2:35 PMPANTS_CONFIG_FILES
be something more like PANTS_CONFIG_FILES="+[pants.ci.toml]"
if the plan is to still load the default pants.toml
?happy-kitchen-89482
03/02/2022, 4:06 PMeager-dress-66405
03/02/2022, 5:00 PM$ PANTS_CONFIG_FILES=pants.ci.toml ./pants help docker | grep -A 12 docker-build-args
--docker-build-args="[<shell_str>, <shell_str>, ...]"
PANTS_DOCKER_BUILD_ARGS
build_args
default: []
current value: [
"AWS_DEFAULT_REGION",
"AWS_ACCESS_KEY_ID",
"AWS_ROLE_ARN",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
"AWS_WEB_IDENTITY_TOKEN_FILE"
] (from pants.ci.toml)
Global build arguments (for Docker `--build-arg` options) to use for all `docker build`
$ PANTS_CONFIG_FILES="+['pants.ci.toml']" ./pants help docker | grep -A 12 docker-build-args
--docker-build-args="[<shell_str>, <shell_str>, ...]"
PANTS_DOCKER_BUILD_ARGS
build_args
default: []
current value: [
"AWS_DEFAULT_REGION",
"AWS_ACCESS_KEY_ID",
"AWS_ROLE_ARN",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
"AWS_WEB_IDENTITY_TOKEN_FILE"
] (from pants.ci.toml)
Global build arguments (for Docker `--build-arg` options) to use for all `docker build`
$ ./pants help docker | grep -A 7 docker-build-args
--docker-build-args="[<shell_str>, <shell_str>, ...]"
PANTS_DOCKER_BUILD_ARGS
build_args
default: []
current value: [
"COMMIT_SHA",
"BASE_PYTHON_IMAGE=foo"
] (from pants.toml)
eager-dress-66405
03/02/2022, 5:06 PM$ PANTS_CONFIG_FILES="['pants.toml', 'pants.ci.toml']" ./pants help docker | grep -A 12 docker-build-args
--docker-build-args="[<shell_str>, <shell_str>, ...]"
PANTS_DOCKER_BUILD_ARGS
build_args
default: []
current value: [
"AWS_DEFAULT_REGION",
"AWS_ACCESS_KEY_ID",
"AWS_ROLE_ARN",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
"AWS_WEB_IDENTITY_TOKEN_FILE"
] (from pants.ci.toml)
Global build arguments (for Docker `--build-arg` options) to use for all `docker build`
$ PANTS_CONFIG_FILES="['pants.ci.toml', 'pants.toml']" ./pants help docker | grep -A 7 docker-build-args
--docker-build-args="[<shell_str>, <shell_str>, ...]"
PANTS_DOCKER_BUILD_ARGS
build_args
default: []
current value: [
"COMMIT_SHA",
"BASE_PYTHON_IMAGE=foo"
] (from pants.toml)
Global build arguments (for Docker `--build-arg` options) to use for all `docker build`
eager-dress-66405
03/02/2022, 8:13 PMfast-nail-55400
03/02/2022, 8:37 PMfast-nail-55400
03/02/2022, 8:37 PMeager-dress-66405
03/02/2022, 9:02 PMeager-dress-66405
03/02/2022, 10:33 PM