2
2
{% - include "cache.Dockerfile.jinja" %}
3
3
{% - endif %} {#- endif model_cache_v1 #}
4
4
5
+ {% - set requires_live_reload = config .live_reload and not config .docker_server %}
6
+
7
+ {% - if requires_live_reload %}
8
+ {% include "control_venv.Dockerfile.jinja" %}
9
+ {% - endif %} {#- endif requires_live_reload #}
10
+
5
11
{% extends "base.Dockerfile.jinja" %}
6
12
13
+
7
14
{% block base_image_patch %}
8
15
{# If user base image is supplied in config, apply build commands from truss base image #}
9
16
{% if config .base_image %}
@@ -27,14 +34,14 @@ COPY ./{{ base_server_requirements_filename }} {{ base_server_requirements_filen
27
34
RUN pip install -r {{ base_server_requirements_filename }} --no-cache-dir && rm -rf /root/.cache/pip
28
35
{% - endif %} {#- endif not config.docker_server #}
29
36
30
- {% - if config . live_reload and not config . docker_server %}
37
+ {% - if requires_live_reload %}
31
38
{# Create symlink for inference server IF a user base image is supplied and live_reload is enabled. #}
32
39
{# This links the base images primary python executable path to /usr/local/bin/python. #}
33
40
{# This is specific to the user-provided base image scenario. #}
34
41
RUN readlink {{ config.base_image.python_executable_path }} & >/dev/null \
35
42
&& echo "WARNING: Overwriting existing link at /usr/local/bin/python"
36
43
RUN ln -sf {{ config.base_image.python_executable_path }} /usr/local/bin/python
37
- {% - endif %} {#- endif config.live_reload and not config.docker_server (for symlink) #}
44
+ {% - endif %} {#- endif requires_live_reload #}
38
45
{% endif %} {#- endif config.base_image #}
39
46
40
47
{% endblock %} {#- endblock base_image_patch #}
@@ -91,34 +98,24 @@ COPY ./truss /app/truss
91
98
{% - endif %} {#- endif use_local_src #}
92
99
93
100
COPY ./config.yaml /app/config.yaml
94
- {% - if config . live_reload and not config . docker_server %}
101
+ {% - if requires_live_reload %}
95
102
COPY ./control /control
96
- # Step 1: Ensure a usable python{{ control_python_version }} is available
97
- RUN if python{{ control_python_version }} -c 'import venv; venv.EnvBuilder(with_pip=True).create("/tmp/__probe_env")' > /dev/null 2>&1 ; then \
98
- echo "Using system python{{ control_python_version }}"; \
99
- python{{ control_python_version }} -m pip install --upgrade pip virtualenv && \
100
- python{{ control_python_version }} -m virtualenv /control/.env; \
101
- else \
102
- echo "Installing Miniforge-based python{{ control_python_version }}..."; \
103
- curl -fsSL -o miniforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh && \
104
- bash miniforge.sh -b -p /opt/conda-control && \
105
- rm miniforge.sh && \
106
- /opt/conda-control/bin/conda create -y -p /opt/conda-control/envs/py{{ control_python_version }} python={{ control_python_version }} && \
107
- /opt/conda-control/envs/py{{ control_python_version }}/bin/pip install --upgrade pip virtualenv && \
108
- /opt/conda-control/bin/conda clean -afy && \
109
- rm -rf /opt/conda-control/pkgs && \
110
- /opt/conda-control/envs/py{{ control_python_version }}/bin/python -m virtualenv /control/.env; \
111
- fi
112
-
113
- # Step 2: Install requirements into the freshly created venv
103
+
104
+ # NB(nikhil): Copy the virtual env, and system dependencies for the
105
+ # python version specific to the control server. We need to run ldconfig
106
+ # so dynamic linking works.
107
+ COPY --from=control-server-venv /usr/local/lib/ /usr/local/lib/
108
+ COPY --from=control-server-venv /control/.env /control/.env
109
+ RUN ldconfig
110
+
114
111
RUN /control/.env/bin/pip install -r /control/requirements.txt
115
- {% - endif %} {#- endif config.live_reload and not config.docker_server (for control server setup) #}
112
+ {% - endif %} {#- endif requires_live_reload #}
113
+
116
114
{% - if model_dir_exists %}
117
115
COPY ./{{ config.model_module_dir }} /app/model
118
116
{% - endif %} {#- endif model_dir_exists #}
119
117
{% endblock %} {#- endblock app_copy #}
120
118
121
-
122
119
{% block run %}
123
120
{% - if config .docker_server %}
124
121
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -136,7 +133,7 @@ COPY supervisord.conf {{ supervisor_config_path }}
136
133
ENV SUPERVISOR_SERVER_URL="{{ supervisor_server_url }}"
137
134
ENV SERVER_START_CMD="supervisord -c {{ supervisor_config_path }}"
138
135
ENTRYPOINT ["supervisord", "-c", "{{ supervisor_config_path }}"]
139
- {% - elif config . live_reload %} {#- elif config.live_reload #}
136
+ {% - elif requires_live_reload %} {#- elif requires_live_reload #}
140
137
ENV HASH_TRUSS="{{ truss_hash }}"
141
138
ENV CONTROL_SERVER_PORT="8080"
142
139
ENV INFERENCE_SERVER_PORT="8090"
0 commit comments