Hi, I'm trying to use `docker: setup_script` with ...
# ask-for-help
m
Hi, I'm trying to use
docker: setup_script
with the example given in bento-build-options but containerize is failing b/c it is unable to find the setup script:
Copy code
#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:
Copy code
service: "service:Example"
include:
  - "*.py"
  - "*.sh"
python:
  packages:
    - "nltk"
docker:
  setup_script: "./setup.sh"
and
Copy code
#!/bin/bash
set -euxo pipefail

echo "Downloading NLTK data.."
python -m nltk.downloader all
f
Hi, this bug is fixed in v1.4.0
πŸ‘ 1
p
Hi there @Frost Ming πŸ‘‹ I'm still having this issue with BentoML
1.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.
The weird thing is that I can't seem to be able to reproduce it with the BentoML CLI, with various combinations of build-context, script placement and configuration. When I look at the generated Dockerfile it contains a line for the script with a hashed/generated name, and it invariably contains what's in my
docker-setup.sh
script. It only crashes when ran from a
bentos.build_bentofile
call, there it fails and cannot locate the file.
OK so, here is a setup that seems to indicate that the build-context is not used for resolving the path to the
setup_script
.
Copy code
a/
β”œβ”€ b/
   β”œβ”€ .git/
   β”œβ”€ c/
      β”œβ”€ bentofile.yaml
      β”œβ”€ docker-setup.sh
      β”œβ”€ service.py
working directory :
/a
/a/b/c/bentofile.yaml
:
Copy code
# only highlighting the script bit
docker:
  setup_script: "c/docker-setup.sh"
test script resulting in an error:
Copy code
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.
f
why did you use a different build_ctx from bentofile.yaml anyway?
what is the
service
config in bentofile.yaml?
also didn’t reproduce:
Copy code
build_bentofile("a/b/c/bentofile.yaml", build_ctx="a/b")
bentofile.yaml:
Copy code
service: c.service:MyService
include:
  - "*.py"
  - "*.sh"
python:
  packages:
    - "nltk"
docker:
  setup_script: "./setup.sh"
the folder structure is exactly the same
p
The reason why the build_ctx is different is that our projects typically have the following structure :
Copy code
my_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.