Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: oci_python_image should set default entrypoint and workdir #375

Open
gfrankliu opened this issue Nov 18, 2024 · 0 comments
Open

[FR]: oci_python_image should set default entrypoint and workdir #375

gfrankliu opened this issue Nov 18, 2024 · 0 comments
Labels
enhancement New feature or request untriaged Requires traige

Comments

@gfrankliu
Copy link

What is the current behavior?

No response

Describe the feature

In py3_image from rules_docker, the default workdir and entrypoints are properly set to reasonable values. Can we do the same in oci_python_image rule? something like:

@@ -1,6 +1,7 @@
 "Wrapper macro to make three separate layers for python applications"
 
 load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
+load("@aspect_bazel_lib//lib:utils.bzl", "utils")
 load("@rules_oci//oci:defs.bzl", "oci_image")
 
 # match *only* external repositories that have the string "python"
@@ -74,6 +75,12 @@ def py_layers(name, binary):
 
 def py_oci_image(name, binary, tars = [], **kwargs):
     "Wrapper around oci_image that splits the py_binary into layers."
+
+    if "entrypoint" not in kwargs:
+        kwargs["entrypoint"] = ["/" + utils.to_label(binary).package + "/" + utils.to_label(binary).name]
+    if "workdir" not in kwargs:
+        kwargs["workdir"] =  "/" + utils.to_label(binary).package + "/" + utils.to_label(binary).name + ".runfiles/__main__"
+
     oci_image(
         name = name,
         tars = tars + py_layers(name, binary),

@gfrankliu gfrankliu added the enhancement New feature or request label Nov 18, 2024
@github-actions github-actions bot added the untriaged Requires traige label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

1 participant