BentoML
                                
                                 BentoML copied to clipboard
                                
                                    BentoML copied to clipboard
                            
                            
                            
                        feat(docker): passing templates via configuration
Feature request
Supporting passing custom dockerfile templates via bentofile.yaml:
docker:
  dockerfile_template: |
    {% extends bento_base_template %}
    {% block SETUP_BENTO_BASE_IMAGE %}
    {{ super() }}
    WORKDIR /tmp
    SHELL [ "bash", "-exo", "pipefail", "-c" ]
    COPY ./src/tfops/zero_out.cc .
    RUN pip3 install tensorflow
    RUN bash <<EOF
    set -ex
    TF_CFLAGS=( $(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
    TF_LFLAGS=( $(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
    g++ --std=c++14 -shared zero_out.cc -o zero_out.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -I$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include());') -D_GLIBCXX_USE_CXX11_ABI=0 -O2
    EOF
    {% endblock %}
    {% block SETUP_BENTO_COMPONENTS %}
    {{ super() }}
    RUN stat /usr/lib/zero_out.so
    {% endblock %}
Motivation
This is a QOL for users who want to put their dockerfile templates inside the yaml file like so.
Implementation details:
- user custom dockerfile templates will be parsed here, We would just need to add a check whether if it is a file or inline yaml string
- We will have to take care of is formatting and handle white space and escape character correctly if parsing as a YAML string.
Other
Would love to hear more from the community.