tgi-benchmark-space / Dockerfile
derek-thomas's picture
Merge remote-tracking branch 'origin/main'
bfe58c8
raw
history blame
1.43 kB
# Start from the TGI base image
FROM ghcr.io/huggingface/text-generation-inference:2.0 as base
# Install git
RUN apt-get update && apt-get install -y git
# Set up the Conda environment
ENV CONDA_AUTO_UPDATE_CONDA=false \
PATH=$HOME/miniconda/bin:$PATH
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh \
&& conda clean -ya
WORKDIR $HOME/app
# Create a non-root user with UID 1000
RUN useradd -m -u 1000 -s /bin/bash user
# Create the /data directory and set its ownership
RUN mkdir /data && chown user:user /data
#######################################
# End root user section
#######################################
USER user
# Python packages
RUN --mount=target=requirements.txt,source=requirements.txt \
pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user ./jupyterlab $HOME/app
RUN chmod +x start_server.sh
COPY --chown=user ./jupyterlab/login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
ENV PYTHONUNBUFFERED=1 \
GRADIO_ALLOW_FLAGGING=never \
GRADIO_NUM_PORTS=1 \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_THEME=huggingface \
SYSTEM=spaces \
SHELL=/bin/bash
CMD ["./start_server.sh"]