Closed qdii closed 1 month ago
What is intriguing is that the hermetic python interpreter is present on the docker image, as can be inspected with dive qdii/myapp:0.0.1
or using docker:
docker run -it --entrypoint "/bin/bash" qdii/myapp:0.0.1 "-c" "stat /myapp/myapp.runfiles/rules_python~~python~python_3_11_x86_64-unknown-linux-gnu/bin/python3"
File: /myapp/myapp.runfiles/rules_python~~python~python_3_11_x86_64-unknown-linux-gnu/bin/python3
Size: 20944 Blocks: 48 IO Block: 4096 regular file
Device: 9ch/156d Inode: 41449532 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ UNKNOWN) Gid: ( 0/ UNKNOWN)
Access: 2023-01-01 08:00:00.000000000 +0000
Modify: 2023-01-01 08:00:00.000000000 +0000
Change: 2024-10-10 05:45:17.165399421 +0000
I am not sure what rules_oci needs to fix here. Sounds like there is a problem in your container image.
FWIW there is a new api in rules_py that might work for you; https://github.com/aspect-build/rules_py/blob/main/docs/py_image_layer.md
After a bit of debugging with Eric Hauser on Slack, we found that py_binary
provides a python interpreter that is linked against glibc
, while the Alpine image ships with musl
.
I think it's unrelated to rules_oci
, so feel free to close the bug. However if you have any pointer on how to convince Aspect bazel to provide a musl-linked interpreter, that would be awesome :)
However if you have any pointer on how to convince Aspect bazel to provide a musl-linked interpreter, that would be awesome :)
I don't think that's possible, as this would involve building cpython from source and link against musl libc. Even then there is no guarantee all the python packages will work as they might still depend on glibc.
Closing this as there is nothing for us to fix here.
I’ve tried to put together a minimal flask app using the recommendations I gathered from Aspect documentation namely:
py_binary
instead of defaultrules_oci
to build and push the image to DockerHubpy_layers.bzl
to split the image into layersWhile running the python binary works fine, using docker to run the image I built with
rules_oci
fails with:Steps to reproduce:
git clone https://github.com/qdii/minimal-flask-app
repository
attribute insidemyapp/BUILD
to point to a Dockerhub repository you control.blaze run //myapp:push
to build and push the image to this registrydocker run <your image>
.What happens: The error above is produced. I expected the same output as
blaze run //myapp