billowy-cat-69904
06/03/2024, 5:49 PMdocker_environment
to build pex binaries, copy those binaries to docker image (Dockerfile
has COPY command), build this new image and publish this image to ECR Repository using pants publish
command. The build and docker files are in the thread.
If anyone has any pointers on why this error might be happening, would love your help.
| ProcessExecutionFailure: Process 'Extract environment variables from the Docker image python:3.11.9-slim' failed with exit code 126.
| stdout:
| OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/pants-sandbox/pants-sandbox-PRbWVL") set in config.json failed: no such file or directory: unknown
|
| stderr:
|
|
|
| Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
|
billowy-cat-69904
06/03/2024, 5:50 PMpants.toml
, under the section:
[environments-preview.names]
linux = "//:linux"
docker_environment(
name="linux",
platform="linux_x86_64",
image="python:3.11.9-slim",
python_bootstrap_search_path=(
"<PATH>",
"/opt/hostedtoolcache/Python/3.11.9/x64",
"/usr/local/bin",
),
)
billowy-cat-69904
06/03/2024, 5:52 PMpython_sources()
python_requirements(
name="reqs",
)
if env("GITHUB_ACTIONS"):
platform = ["hunch:ci-platform"]
else:
platform = ["hunch:linux-platform"]
kwargs = dict( entry_point="hunch.projects.followed_users_post.src.forecast:main",
layout="packed",
environment="linux",
execution_mode="venv",
)
pex_binary(name="pex-dependencies", include_sources=False, **kwargs)
pex_binary(name="pex-sources", include_requirements=False, **kwargs)
docker_image(
name="followed_users_post_img",
repository="followed_users_post",
registries=[
env("ECR_REGISTRY", "ECR Registry name e.g. `47474747.dkr.ecr.amazonaws.com`")
],
image_tags=["{build_args.IMAGE_LATEST_TAG}", "{build_args.IMAGE_VERSION_TAG}"],
extra_build_args=("IMAGE_LATEST_TAG", "IMAGE_VERSION_TAG", "--provenance=false"),
)
billowy-cat-69904
06/03/2024, 5:53 PMFROM --platform=linux/amd64 python:3.11.9-slim as deps
# FROM python:3.11.9-slim as deps
COPY hunch.projects.followed_users_post/pex-dependencies.pex /libs_binary.pex
RUN PEX_TOOLS=1 /usr/local/bin/python /libs_binary.pex venv --scope=deps --compile /bin/app
FROM --platform=linux/amd64 python:3.11.9-slim as srcs
# FROM python:3.11.9-slim as srcs
COPY hunch.projects.followed_users_post/pex-sources.pex /fp_binary.pex
RUN PEX_TOOLS=1 /usr/local/bin/python /fp_binary.pex venv --scope=srcs --compile /bin/app
FROM --platform=linux/amd64 python:3.11.9-slim
# FROM python:3.11.9-slim
COPY --from=deps /bin/app /bin/app
COPY --from=srcs /bin/app /bin/app
curved-television-6568
06/03/2024, 6:00 PMenv(..)
construct in the same BUILD file as your docker_environment
target? (I think that could be the issue.. thought it was called out in the docs, but seems not)billowy-cat-69904
06/03/2024, 6:06 PMdocker_environment
target, I am not using env()
construct, however I am using it inside docker_image()
target and in the BUILD
file . Both of these are in separate BUILD
files. docker_environment()
target is in the BUILD
file which is in the root directory of monorepo, while docker_image()
target is in the BUILD
file which is in the project directory e.g. monorepo/projects/projectA/BUILD
curved-television-6568
06/03/2024, 7:22 PM