diff --git a/python/image.bzl b/python/image.bzl index 5f5458d60..0615cc3ba 100644 --- a/python/image.bzl +++ b/python/image.bzl @@ -78,7 +78,7 @@ def py_layer(name, deps, filter = "", **kwargs): native.py_library(name = binary_name, deps = deps, **kwargs) filter_layer(name = name, dep = binary_name, filter = filter) -def py_image(name, base = None, deps = [], layers = [], env = {}, **kwargs): +def py_image(name, base = None, deps = [], layers = [], env = {}, entrypoint = ["/usr/bin/python"], **kwargs): """Constructs a container image wrapping a py_binary target. Args: @@ -117,7 +117,7 @@ def py_image(name, base = None, deps = [], layers = [], env = {}, **kwargs): app_layer( name = name, base = base, - entrypoint = ["/usr/bin/python"], + entrypoint = entrypoint, env = env, binary = binary_name, visibility = visibility, diff --git a/python3/image.bzl b/python3/image.bzl index 9b4f12816..28a652d7a 100644 --- a/python3/image.bzl +++ b/python3/image.bzl @@ -73,7 +73,7 @@ DEFAULT_BASE = select({ "//conditions:default": "@py3_image_base//image", }) -def py3_image(name, base = None, deps = [], layers = [], env = {}, **kwargs): +def py3_image(name, base = None, deps = [], layers = [], env = {}, entrypoint = ["/usr/bin/python"], **kwargs): """Constructs a container image wrapping a py_binary target. Args: @@ -113,7 +113,7 @@ def py3_image(name, base = None, deps = [], layers = [], env = {}, **kwargs): app_layer( name = name, base = base, - entrypoint = ["/usr/bin/python"], + entrypoint = entrypoint, env = env, binary = binary_name, visibility = visibility, diff --git a/tests/container/python3/BUILD b/tests/container/python3/BUILD index 2e5d5df17..a738f630d 100644 --- a/tests/container/python3/BUILD +++ b/tests/container/python3/BUILD @@ -37,3 +37,22 @@ container_test( configs = ["//tests/container/python3/configs:py3_image.yaml"], image = ":py3_image", ) + +py3_image( + name = "py3_image_custom_entrypoint", + entrypoint = ["/usr/bin/python3"], + srcs = ["//testdata:py3_image.py"], + args = [ + "arg0" + ], + data = [":BUILD"], + layers = [ + "//tests/container/python:py_image_library", + ], +) + +container_test( + name = "py3_image_test_custom_entrypoint", + configs = ["//tests/container/python3/configs:py3_image_custom_entrypoint.yaml"], + image = ":py3_image_custom_entrypoint", +) diff --git a/tests/container/python3/configs/py3_image_custom_entrypoint.yaml b/tests/container/python3/configs/py3_image_custom_entrypoint.yaml new file mode 100644 index 000000000..57e5eb140 --- /dev/null +++ b/tests/container/python3/configs/py3_image_custom_entrypoint.yaml @@ -0,0 +1,10 @@ +schemaVersion: 2.0.0 + +metadataTest: + cmd: [ + 'arg0', + ] + entrypoint: [ + '/usr/bin/python3', + '/app/tests/container/python3/py3_image.binary', + ]