@@ -821,7 +821,7 @@ def _init_deployment_files(
821
821
and rel_path not in DEFAULT_BENTO_BUILD_FILES
822
822
):
823
823
continue
824
- if rel_path in (REQUIREMENTS_TXT , "setup.sh" ):
824
+ if rel_path in (REQUIREMENTS_TXT , "setup.sh" , "post_setup.sh" ):
825
825
continue
826
826
file_content = open (full_path , "rb" ).read ()
827
827
if (
@@ -852,6 +852,11 @@ def _init_deployment_files(
852
852
setup_md5 = hashlib .md5 (setup_script ).hexdigest ()
853
853
if setup_md5 != pod_files .get ("setup.sh" , "" ):
854
854
upload_files .append (("setup.sh" , setup_script ))
855
+ post_setup_script = _build_post_setup_script (bento_dir , svc .image )
856
+ if post_setup_script :
857
+ post_setup_md5 = hashlib .md5 (post_setup_script ).hexdigest ()
858
+ if post_setup_md5 != pod_files .get ("post_setup.sh" , "" ):
859
+ upload_files .append (("post_setup.sh" , post_setup_script ))
855
860
self .upload_files (upload_files , console = console )
856
861
# Upload a ready flag file after all files are uploaded
857
862
self .upload_files ([(".project_ready" , b"" )], console = console )
@@ -892,6 +897,7 @@ def watch_filter(change: watchfiles.Change, path: str) -> bool:
892
897
* DEFAULT_BENTO_BUILD_FILES ,
893
898
REQUIREMENTS_TXT ,
894
899
"setup.sh" ,
900
+ "post_setup.sh" ,
895
901
) or bento_spec .includes (rel_path )
896
902
897
903
console = Console (highlight = False )
@@ -1582,6 +1588,14 @@ def _build_setup_script(bento_dir: str, image: Image | None) -> bytes:
1582
1588
content += f"apt-get update && apt-get install -y { ' ' .join (config .docker .system_packages )} || exit 1\n " .encode ()
1583
1589
if image and image .commands :
1584
1590
content += "\n " .join (image .commands ).encode () + b"\n "
1591
+ return content
1592
+
1593
+
1594
+ def _build_post_setup_script (bento_dir : str , image : Image | None ) -> bytes :
1595
+ content = b""
1596
+ config = BentoBuildConfig .from_bento_dir (bento_dir )
1597
+ if image and image .post_commands :
1598
+ content += "\n " .join (image .post_commands ).encode () + b"\n "
1585
1599
if config .docker .setup_script and os .path .exists (
1586
1600
fullpath := os .path .join (bento_dir , config .docker .setup_script )
1587
1601
):
0 commit comments