Skip to content

Docker not recognizing [docker].env_vars #18544

Open
@rhuanbarreto

Description

@rhuanbarreto

Describe the bug
I setup pants.toml with:

[docker]
env_vars = ["GITHUB_SHA=development"]
build_args = ["GITHUB_SHA"]

[environments-preview.names]
docker_linux = "//:docker_linux"
local_mac = "//:local_mac"
local_linux = "//:local_linux"

And BUILD file:

local_environment(
    name="local_mac",
    compatible_platforms=["macos_arm64"],
    fallback_environment="local_linux",
)

local_environment(
    name="local_linux",
    compatible_platforms=["linux_x86_64"],
    fallback_environment="docker_linux",
)

docker_environment(
    name="docker_linux",
    platform="linux_x86_64",
    image="python:3.11.2-slim-bullseye",
    python_bootstrap_search_path=["/usr/local/bin"],
)

I get an error when I run pants package :: :

[ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

DockerBuildContextError: Undefined value for build arg on the <redacted>:app target: The Docker environment variable 'GITHUB_SHA' is undefined. You may provide a value for this variable either in `[docker].env_vars` or in Pants's own environment.

If you did not intend to inherit the value for this build arg from the environment, provide a default value with the option `[docker].build_args` or in the `extra_build_args` field on the target definition. Alternatively, you may also provide a default value on the `ARG` instruction directly in the `Dockerfile`.

Pants version
2.15.0

OS
Mac OS M1 Max

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions