bumpy-cricket-95527
11/05/2024, 3:03 PMoci_pull_images(
name="python",
repository="docker.io/library/python",
variants=
{
"3.11.10-slim": "459ee2a00675825a5cf39a34d0c4a3f7cb994c76b647c88c1605ed9aca05b97e",
},
architecture="amd64",
os="linux",
)
python_requirements(
name="lib",
source="pyproject.toml",
)
file(name="start", source="start.sh")
pex_binary(
name="pex",
dependencies=[":lib"],
execution_mode="venv",
output_path="pex.pex",
)
oci_layer(
name="layer",
packages=[":pex"],
)
oci_image_build(
name="image",
base=[":python#3.11.10-slim"],
repository=(repo)
tag="latest",
entrypoint="./start.sh",
layers=[":layer", ":start"],
)
where start.sh
simply contains
#!/bin/bash
./pex.pex -m "$@"
But I get this error when trying to pants package (path):image
/Users/[me]/.cache/pants/named_caches/pex_root/venvs/s/66d63bf8/venv/lib/python3.9/site-packages/pants_backend_oci/util_rules/layer.py", line 153, in build_image_layer
raw_layer_digest, layer_name = real_layers[0]
IndexError: list index out of range
The end goal is to get an image that can accept some arguments like python_module_name arg1 arg2 ...
, which in reality would be like doing ./pex.pex -m python_module_name arg1 arg2 ...
, or the like. Am I approaching the problem the wrong way? Super grateful for any help 🙏gorgeous-winter-99296
11/05/2024, 3:14 PMbumpy-cricket-95527
11/05/2024, 3:20 PMpants-backend-oci==0.7.0
Yes, turning it to a resource results in the same error.bumpy-cricket-95527
11/05/2024, 3:22 PMbumpy-cricket-95527
11/05/2024, 3:22 PMfile(name="start_file", source="start.sh")
...
oci_layer(
name="start",
packages=[":start_file"],
)
...
gorgeous-winter-99296
11/05/2024, 3:26 PMgorgeous-winter-99296
11/05/2024, 3:35 PMgorgeous-winter-99296
11/05/2024, 3:50 PMfile
to files
, that seems to work when I repro it.bumpy-cricket-95527
11/05/2024, 4:00 PMoci_layer
with only the file?gorgeous-winter-99296
11/05/2024, 4:00 PMbumpy-cricket-95527
11/05/2024, 4:24 PMpants run (path):image
because I’m on Mac). This has never happened before 😄
podman build -f image.tar
Error: no FROM statement found
gorgeous-winter-99296
11/05/2024, 4:25 PMpodman run oci:dist/examples.oci.file/image.d
That's the method I'd suggest if possible.gorgeous-winter-99296
11/05/2024, 4:29 PMpodman load
or podman import
? But I've never seen those used with -f
either... You can podman pull or run the oci dir directly, or you can tar it and load/import...)gorgeous-winter-99296
11/05/2024, 5:05 PMfile
... will have to investigate more. I'm wondering if changing the type of start
led to some weird cache mismatch.)bumpy-cricket-95527
11/06/2024, 4:18 PMmakeself_archive
to do exactly what I wanted, and then created an oci_layer
out of that. Basically did what is stated here: https://www.pantsbuild.org/stable/docs/shell/self-extractable-archives#bundling-packages-like-pex_binarybumpy-cricket-95527
11/06/2024, 4:19 PMpodman run oci:dist/examples.oci.file/image.d
doesn’t work for me at all 😞gorgeous-winter-99296
11/06/2024, 5:40 PMbumpy-cricket-95527
11/07/2024, 7:44 AMv5.2.1