{%- if model_cache %}
{%- include "cache.Dockerfile.jinja" %}
{%- endif %}


FROM ghcr.io/huggingface/text-generation-inference:1.1.0 as tgi
EXPOSE 8080

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        nginx supervisor curl && \
        rm -rf /var/lib/apt/lists/*


COPY ./proxy.conf /etc/nginx/conf.d/proxy.conf

RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

{% for env_var_name, env_var_value in config.environment_variables.items() %}
ENV {{ env_var_name }} {{ env_var_value }}
{% endfor %}

ENV SERVER_START_CMD /usr/bin/supervisord

{%- if model_cache %}
        {%- set hf_dst_directory="/data/"%}
        {%- include "copy_cache_files.Dockerfile.jinja"%}
{%- endif %}

ENTRYPOINT ["/usr/bin/supervisord"]
