Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions python3/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions tests/container/python3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
schemaVersion: 2.0.0

metadataTest:
cmd: [
'arg0',
]
entrypoint: [
'/usr/bin/python3',
'/app/tests/container/python3/py3_image.binary',
]