Skip to content

Commit

Permalink
Support source=None for docker_image targets. (pantsbuild#17578)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaos authored Nov 27, 2022
1 parent a597859 commit d74c5ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/python/pants/backend/docker/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def compute_value(cls, raw_value: Optional[str], address: Address) -> Optional[s


class DockerImageSourceField(OptionalSingleSourceField):
none_is_valid_value = True
default = "Dockerfile"

# When the default glob value is in effect, we don't want the normal glob match error behavior
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,34 @@ def test_pex_custom_output_path_issue14031(rule_runner: RuleRunner) -> None:
Address("project/test", target_name="test-image"),
expected_files=["project/test/Dockerfile", "project/test.pex"],
)


def test_dockerfile_instructions_issue_17571(rule_runner: RuleRunner) -> None:
rule_runner.write_files(
{
"src/docker/Dockerfile": "do not use this file",
"src/docker/BUILD": dedent(
"""\
docker_image(
source=None,
instructions=[
"FROM python:3.8",
]
)
"""
),
}
)

assert_build_context(
rule_runner,
Address("src/docker"),
expected_files=["src/docker/Dockerfile.docker"],
expected_interpolation_context={
"tags": {
"baseimage": "3.8",
"stage0": "3.8",
},
"build_args": {},
},
)

0 comments on commit d74c5ef

Please sign in to comment.