-
Notifications
You must be signed in to change notification settings - Fork 695
Closed
Closed
Copy link
Labels
Can Close?Will close in 30 days unless there is a comment indicating why notWill close in 30 days unless there is a comment indicating why not
Description
I am using Python's official python:3.7.3-slim
image from Dockerhub. Here is my pull command:
[container_pull(
name = name,
registry = "index.docker.io",
repository = "library/python",
digest = "sha256:64d8fdeff90572068f5fb5e7fa0d67e28fa4629f54682a67156c6d6fbf3125b9",
) for name in [
"py3_image_base",
"py3_debug_image_base",
]]
As a result, I have a custom Python toolchain for the container execution target:
# Modified from @rules_docker//toolchains:BUILD
py_runtime(
name = "container_py2_runtime",
interpreter_path = "/usr/bin/python",
python_version = "PY2",
)
# Path in the python:slim-3.7 image
py_runtime(
name = "container_py3_runtime",
interpreter_path = "/usr/local/bin/python3",
python_version = "PY3",
)
py_runtime_pair(
name = "container_py_runtime_pair",
py2_runtime = ":container_py2_runtime",
py3_runtime = ":container_py3_runtime",
)
toolchain(
name = "container_py_toolchain",
exec_compatible_with = [
"@io_bazel_rules_docker//platforms:run_in_container",
],
toolchain = ":container_py_runtime_pair",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
I then register the toolchain and execution platforms as such (copied and altered from rules_docker/python3/image.bzl):
register_toolchains(
"//toolchain:container_py_toolchain",
)
register_execution_platforms(
"@local_config_platform//:host",
"@io_bazel_rules_docker//platforms:local_container_platform",
)
My py3_image rule looks like this
DEPS = [
requirement("certifi"),
requirement("chardet"),
requirement("idna"),
requirement("prometheus_client"),
requirement("requests"),
requirement("urllib3"),
]
py3_image(
name = "image",
srcs = ["probe.py"],
layers = DEPS + [
":probe",
],
main = "probe.py",
)
I then build the image:
bazel run --toolchain_resolution_debug //insights/monitor/probe/pipeline:image
and I get this
/usr/bin/docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"/usr/bin/python\": stat /usr/bin/python: no such file or directory": unknown.
This seems to be due to the entrypoint attribute on the app_layer conflicting with the toolchain. Since PYTHON_BINARY is extracted from the toolchain and injected into image.binary as the default Python path, it seems as though the ["/usr/bin/python"]
entrypoint can be removed altogether.
A PR with this change is forthcoming.
Metadata
Metadata
Assignees
Labels
Can Close?Will close in 30 days unless there is a comment indicating why notWill close in 30 days unless there is a comment indicating why not