-
Notifications
You must be signed in to change notification settings - Fork 692
Add "entrypoint" to py_image rule #498
Comments
You should be able to use More about command line flags: https://docs.bazel.build/versions/master/command-line-reference.html |
I ran bazel with Description of the problem / feature request:
I'm working around this by patching diff --git a/python3/image.bzl b/python3/image.bzl
index 1f1f178..9f7fa82 100644
--- a/python3/image.bzl
+++ b/python3/image.bzl
@@ -58,7 +58,9 @@ DEFAULT_BASE = select({
"//conditions:default": "@py3_image_base//image",
})
-def py3_image(name, base = None, deps = [], layers = [], **kwargs):
+DEFAULT_ENTRYPOINT = ["/usr/bin/python"]
+
+def py3_image(name, base = None, deps = [], layers = [], entrypoint = None, **kwargs):
"""Constructs a container image wrapping a py_binary target.
Args:
@@ -89,7 +91,7 @@ def py3_image(name, base = None, deps = [], layers = [], **kwargs):
app_layer(
name = name,
base = base,
- entrypoint = ["/usr/bin/python"],
+ entrypoint = entrypoint or DEFAULT_ENTRYPOINT,
binary = binary_name,
lang_layers = layers,
visibility = visibility,
I'm not sure this is the best solution, Inheriting Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_docker",
urls = ["https://github.com/bazelbuild/rules_docker/archive/d6046608f4979ad891a8c0574dd07ca7bf5f870e.tar.gz"],
sha256 = "6872b8b0b509c6c3fcc3876f9b009b1984d9c5de80f9234dd6bfb8d8c504f314",
strip_prefix = "rules_docker-d6046608f4979ad891a8c0574dd07ca7bf5f870e",
)
load("@io_bazel_rules_docker//python3:image.bzl", py3_container_repositories = "repositories")
py3_container_repositories()
load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
container_pull(
name = "python_cp37_image_base",
registry = "index.docker.io",
repository = "library/python",
tag = "3.7.0-alpine3.8",
)
load("@io_bazel_rules_docker//python3:image.bzl", "py3_image")
# This works, because distroless:python3 image has python at /usr/bin/python
py3_image(
name = "distroless",
srcs = ["bin.py"],
main = "bin.py",
)
# This doesn't work, python is /usr/local/bin/python
py3_image(
name = "alpine",
base = "@python_cp37_image_base//image",
srcs = ["bin.py"],
main = "bin.py",
# We need this to make it work
# entrypoint = ["/usr/local/bin/python"],
) Any other information, logs, or outputs that you want to share?
|
Thanks for the additional explanation.
We want to maintain sync between xx_binary and xx_image rules, so adding entrypoint to these rules is not an option. Let me know if the suggestion above works, otherwise I can think of other options. |
closing this issue as it should be possible to fix via adding the symlink, please let me know if you want to reopen (and suggest an alternative path if possible) |
py_image
assumes python is at/usr/bin/python
, that's not always the case when changing the base image.python:alpine
from Docker hub has python at/usr/local/bin/python
.I'm affected by
py_image
&py3_image
but I assume other lang rules are the samemaybe related #467
The text was updated successfully, but these errors were encountered: