fresh-continent-76371
03/01/2024, 2:51 AM❯ pants list common/base-containers::
common/base-containers:images-python@parametrize=py310alpine
common/base-containers:images-python@parametrize=py310deb
common/base-containers:images-python@parametrize=py311alpine
common/base-containers:images-python@parametrize=py311deb
common/base-containers:images-python@parametrize=py312alpine
common/base-containers:images-python@parametrize=py312deb
What is the "BASE_IMAGE" name to use for a sibling container, to choose (in the Dockerfile ? )
# services/myservice/BUILD
docker_image(
name="myservice_cntr",
repository="therepository",
image_tags=["{build_args.DEFAULT_TAG}"],
dependencies= [
"//common/base-containers:images-python@parametrize=py310deb",
],
)
In the Dockerfile - what is the correct format, to use the container that is a dependee ?
#services/myservce/Dockerfile
# ARG BASE_IMAGE=common/base-containers:images-python@parametrize=py310deb
# ARG BASE_IMAGE=//common/base-containers:images-python@parametrize=py310deb
# ARG BASE_IMAGE=:images-python@parametrize=py310deb
ARG BASE_IMAGE=../../common.base-containers:images-python@parametrize=py310deb
FROM $BASE_IMAGE
broad-processor-92400
03/01/2024, 5:12 AMfresh-continent-76371
03/01/2024, 5:13 AMfresh-continent-76371
03/01/2024, 5:14 AMbroad-processor-92400
03/01/2024, 5:19 AMfresh-continent-76371
03/01/2024, 5:24 AMfresh-continent-76371
03/01/2024, 5:26 AMversion_and_changelog(hyphenated_format=True)
docker_image(
name="mything",
repository="mything",
image_tags=["{build_args.DEFAULT_TAG}"],
extra_build_args=["BASE_IMAGE=registry.internal/library/python:3.10-slim"],
dependencies= [
...,
"//common/base-containers:images-python@parametrize=py310deb",
],
)
curved-television-6568
03/01/2024, 9:40 AMcurved-television-6568
03/01/2024, 10:06 AMcurved-television-6568
03/01/2024, 10:51 AMcurved-television-6568
03/01/2024, 10:53 AM# ARG BASE_IMAGE=common/base-containers:images-python@parametrize=py310deb
# ARG BASE_IMAGE=//common/base-containers:images-python@parametrize=py310deb
curved-television-6568
03/01/2024, 10:58 AMwhat does a "non" parameterised (seperate BUILD) file inference look like ?not sure what you mean here... it's the same, only difference is the address used for the build ARG value in the Dockerfile instruction. Or this became a non-question now that we know you hit a bug? 🙂
fresh-continent-76371
03/02/2024, 2:28 AMfresh-continent-76371
03/14/2024, 9:21 PMpants docker base_image (FROM via ARGS)
mechanism
the build-arg BASE_IMAGE/ARG can either be
- static, repository reachable, images inside the Dockerfile
- static, inside the Dockerfile - pants targets, (relative, absolute, and parametrized)
- "dynamic", passed in via the extra_build_args, ONLY if FROM image value is a : repository reachable, images inside the Dockerfile (not a pants inferenced one)
to be clear, target inference only works on the static Dockerfile, it does not update, or make changes to any "args" being passed to docker .. --build_args
fresh-continent-76371
03/14/2024, 9:25 PMfresh-continent-76371
03/14/2024, 9:28 PM❯ pants list containers/sample:: | xargs -Ixx sh -c "echo ======= xx; pants package xx 2>&1 | sed 's#^# #'"
======= containers/sample:sample-external-image-via-build_args
08:10:44.95 [INFO] Starting: Building docker image sample-external-image-via-build_args:latest
08:10:53.83 [INFO] Completed: Building docker image sample-external-image-via-build_args:latest
08:10:53.84 [INFO] Wrote dist/containers.sample/sample-external-image-via-build_args.docker-info.json
Built docker image: sample-external-image-via-build_args:latest
Docker image ID: sha256:fed834eb510decd18e8cdc0e4abf9b1d8ecb293f58941cd616f7725ce0e00479
======= containers/sample:sample-other-pants-tgt-basic-image-relative-via-build_args
08:11:00.68 [INFO] Starting: Building docker image python:3.11-slim
08:11:03.16 [INFO] Completed: Building docker image python:3.11-slim
08:11:03.16 [INFO] Starting: Building docker image sample-other-pants-tgt-basic-image-relative-via-build_args:latest
08:11:05.01 [INFO] Completed: Building docker image sample-other-pants-tgt-basic-image-relative-via-build_args:latest
08:11:05.01 [WARN] Docker build failed for `docker_image` containers/sample:sample-other-pants-tgt-basic-image-relative-via-build_args. There are files in the Docker build context that were not referenced by any `COPY` instruction (this is not an error):
* containers.common/python-3-11-basic.docker-info.json
* my_simple_lib-4.3.1-py3-none-any.whl
* my_simple_lib-4.3.1.tar.gz
08:11:05.01 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
ProcessExecutionFailure: Process 'Building docker image sample-other-pants-tgt-basic-image-relative-via-build_args:latest' failed with exit code 1.
stdout:
stderr:
#0 building with "default" instance using docker driver
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 115B done
#2 DONE 0.0s
#3 [internal] load metadata for <http://docker.io/containers/common:python-3-11-basic|docker.io/containers/common:python-3-11-basic>
#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
------
> [internal] load metadata for <http://docker.io/containers/common:python-3-11-basic|docker.io/containers/common:python-3-11-basic>:
------
Dockerfile:2
--------------------
1 | ARG BASE_IMAGE
2 | >>> FROM $BASE_IMAGE
3 |
4 | RUN apt update && apt install -y \
--------------------
ERROR: failed to solve: containers/common:python-3-11-basic: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
======= containers/sample:sample-other-pants-tgt-parametrized-image-absolute-via-build_args
08:11:12.22 [INFO] Starting: Building docker image python:3.11-slim
08:11:13.82 [INFO] Completed: Building docker image python:3.11-slim
08:11:13.83 [INFO] Starting: Building docker image sample-other-pants-tgt-parametrized-image-absolute-via-build_args:latest
08:11:13.93 [INFO] Completed: Building docker image sample-other-pants-tgt-parametrized-image-absolute-via-build_args:latest
08:11:13.94 [WARN] Docker build failed for `docker_image` containers/sample:sample-other-pants-tgt-parametrized-image-absolute-via-build_args. There are files in the Docker build context that were not referenced by any `COPY` instruction (this is not an error):
* containers.common/images-python@parametrize=py311deb.docker-info.json
* my_simple_lib-4.3.1-py3-none-any.whl
* my_simple_lib-4.3.1.tar.gz
08:11:13.94 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
ProcessExecutionFailure: Process 'Building docker image sample-other-pants-tgt-parametrized-image-absolute-via-build_args:latest' failed with exit code 1.
stdout:
stderr:
#0 building with "default" instance using docker driver
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 115B done
#2 DONE 0.0s
Dockerfile:2
--------------------
1 | ARG BASE_IMAGE
2 | >>> FROM $BASE_IMAGE
3 |
4 | RUN apt update && apt install -y \
--------------------
ERROR: failed to solve: failed to parse stage name "//containers/common:images-python@parametrize=py311deb": invalid reference format
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
======= containers/sample:sample-other-pants-tgt-parametrized-image-relative-via-build_args
08:11:20.97 [INFO] Starting: Building docker image python:3.11-slim
08:11:22.59 [INFO] Completed: Building docker image python:3.11-slim
08:11:22.59 [INFO] Starting: Building docker image sample-other-pants-tgt-parametrized-image-relative-via-build_args:latest
08:11:22.70 [INFO] Completed: Building docker image sample-other-pants-tgt-parametrized-image-relative-via-build_args:latest
08:11:22.70 [WARN] Docker build failed for `docker_image` containers/sample:sample-other-pants-tgt-parametrized-image-relative-via-build_args. There are files in the Docker build context that were not referenced by any `COPY` instruction (this is not an error):
* containers.common/images-python@parametrize=py311deb.docker-info.json
* my_simple_lib-4.3.1-py3-none-any.whl
* my_simple_lib-4.3.1.tar.gz
08:11:22.70 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
ProcessExecutionFailure: Process 'Building docker image sample-other-pants-tgt-parametrized-image-relative-via-build_args:latest' failed with exit code 1.
stdout:
stderr:
#0 building with "default" instance using docker driver
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 115B done
#2 DONE 0.0s
Dockerfile:2
--------------------
1 | ARG BASE_IMAGE
2 | >>> FROM $BASE_IMAGE
3 |
4 | RUN apt update && apt install -y \
--------------------
ERROR: failed to solve: failed to parse stage name "containers/common:images-python@parametrize=py311deb": invalid reference format
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
======= containers/sample:sample-other-pants-tgt-parametrized-image-via-static_in_dockerfile
08:11:29.59 [INFO] Starting: Building docker image python:3.11-slim
08:11:31.23 [INFO] Completed: Building docker image python:3.11-slim
08:11:31.24 [INFO] Starting: Building docker image sample-other-pants-tgt-parametrized-image-via-static_in_dockerfile:latest
08:11:35.83 [INFO] Completed: Building docker image sample-other-pants-tgt-parametrized-image-via-static_in_dockerfile:latest
08:11:35.83 [INFO] Wrote dist/containers.sample/sample-other-pants-tgt-parametrized-image-via-static_in_dockerfile.docker-info.json
Built docker image: sample-other-pants-tgt-parametrized-image-via-static_in_dockerfile:latest
Docker image ID: sha256:a0c60e6f2e41b60d445837ee76b5cc993f90d7097b302b517d3632d834f06aad
fresh-continent-76371
03/14/2024, 9:33 PMfresh-continent-76371
03/14/2024, 11:05 PMsed -i s/pants_tgt_address/pants_image_sha_pre-built/g Dockerfile
• and not cat $pants_docker_cmd_line_args | sed s/pants_tgt_address/pants_image_sha_pre-built/g
curved-television-6568
03/15/2024, 7:47 AMcurved-television-6568
03/15/2024, 7:47 AMfresh-continent-76371
03/15/2024, 7:48 AMcurved-television-6568
03/15/2024, 7:49 AMBASE_IMAGE
build arg to the Docker build command." that was intended to say: You can't use this as a regular build arg.. 😉fresh-continent-76371
03/15/2024, 7:50 AMcurved-television-6568
03/15/2024, 7:51 AM