Max F
02/19/2025, 11:06 PMdocker: setup_script with the example given in bento-build-options but containerize is failing b/c it is unable to find the setup script:
#13 [base-container 9/12] RUN chmod +x ./env/docker/script__9d1f8130046bce7702569a931db2dac3 && ./env/docker/script__9d1f8130046bce7702569a931db2dac3
#13 0.543 chmod: cannot access './env/docker/script__9d1f8130046bce7702569a931db2dac3': No such file or directory
Is there anything additional I need to add to get it work? For reference my bentofile and shell script:
service: "service:Example"
include:
- "*.py"
- "*.sh"
python:
packages:
- "nltk"
docker:
setup_script: "./setup.sh"
and
#!/bin/bash
set -euxo pipefail
echo "Downloading NLTK data.."
python -m nltk.downloader allFrost Ming
02/20/2025, 8:44 AMPierre Lecerf
04/07/2025, 2:28 PM1.4.7.
It's possible that the path for the setup_script does not play nice with the build-context option.
I've tried notably:
β’ include /my-dir/docker-setup.sh
β’ setup_script "/my-dir/docker-setup.sh"
β’ service build context : /my-dir
β’ the error mentions FileNotFoundError: [Errno 2] No such file or directory: b'/my-dir/my-dir/docker-setup.sh'
If I try to change setup_script to "./docker-setup.sh" , then the error becomes FileNotFoundError: [Errno 2] No such file or directory: b'/my-dir/docker-setup.sh'
Of note: this is in order to fix the issue mentioned here.Pierre Lecerf
04/07/2025, 3:27 PMdocker-setup.sh script.
It only crashes when ran from a bentos.build_bentofile call, there it fails and cannot locate the file.Pierre Lecerf
04/07/2025, 5:27 PMsetup_script.
a/
ββ b/
ββ .git/
ββ c/
ββ bentofile.yaml
ββ docker-setup.sh
ββ service.py
working directory : /a
/a/b/c/bentofile.yaml :
# only highlighting the script bit
docker:
setup_script: "c/docker-setup.sh"
test script resulting in an error:
bentos.build_bentofile(
bentofile="/a/b/c/bentofile.yaml",
version="0.0.0",
build_ctx="/a/b",
)
Using an absolute path for the setup_script appears to be working but is far from ideal as the service is not expected to be aware of the working directory where the build is happening.Frost Ming
04/08/2025, 12:45 AMFrost Ming
04/08/2025, 12:45 AMservice config in bentofile.yaml?Frost Ming
04/08/2025, 12:47 AMbuild_bentofile("a/b/c/bentofile.yaml", build_ctx="a/b")
bentofile.yaml:
service: c.service:MyService
include:
- "*.py"
- "*.sh"
python:
packages:
- "nltk"
docker:
setup_script: "./setup.sh"Frost Ming
04/08/2025, 12:47 AMPierre Lecerf
04/08/2025, 7:44 AMmy_project/
ββ .git/
ββ conf/
ββ my_module/
ββ project_logic.py
ββ utils/
ββ various_python_stuff.py
ββ bento_stuff/
ββ bentofile.yaml
ββ service.py
Basically the BentoML part is encapsulated in its own directory tree, and we wanted paths in the bentofile to not be relative.
I'll try to produce a minimal working example for the context issue.