Spaces:
Runtime error
Runtime error
Create Dockerfile
Browse files- Dockerfile +61 -0
Dockerfile
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FROM nvidia/cuda:11.3.1-base-ubuntu20.04
|
| 2 |
+
FROM ubuntu:20.04
|
| 3 |
+
|
| 4 |
+
# Remove any third-party apt sources to avoid issues with expiring keys.
|
| 5 |
+
RUN rm -f /etc/apt/sources.list.d/*.list
|
| 6 |
+
|
| 7 |
+
# Install some basic utilities
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
curl ca-certificates sudo git bzip2 libx11-6 && \
|
| 10 |
+
rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# Create a working directory
|
| 13 |
+
RUN mkdir /app
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
|
| 16 |
+
# Create a non-root user and switch to it
|
| 17 |
+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user && \
|
| 18 |
+
chown -R user:user /app
|
| 19 |
+
|
| 20 |
+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 21 |
+
USER user
|
| 22 |
+
|
| 23 |
+
# All users can use /home/user as their home directory
|
| 24 |
+
ENV HOME=/home/user
|
| 25 |
+
RUN mkdir $HOME/.cache $HOME/.config && \
|
| 26 |
+
chmod -R 777 $HOME
|
| 27 |
+
|
| 28 |
+
# Set up the Conda environment
|
| 29 |
+
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 30 |
+
PATH=$HOME/miniconda/bin:$PATH
|
| 31 |
+
|
| 32 |
+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh && \
|
| 33 |
+
chmod +x ~/miniconda.sh && \
|
| 34 |
+
~/miniconda.sh -b -p ~/miniconda && \
|
| 35 |
+
rm ~/miniconda.sh && \
|
| 36 |
+
conda clean -ya
|
| 37 |
+
|
| 38 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 39 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 40 |
+
GRADIO_NUM_PORTS=1 \
|
| 41 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 42 |
+
GRADIO_THEME=huggingface \
|
| 43 |
+
SYSTEM=spaces
|
| 44 |
+
|
| 45 |
+
RUN conda install -c conda-forge -y jupyterlab
|
| 46 |
+
|
| 47 |
+
# RUN pip install --no-cache-dir fire gradio datasets huggingface_hub
|
| 48 |
+
|
| 49 |
+
# Install user requirements
|
| 50 |
+
COPY ./requirements.txt /app/requirements.txt
|
| 51 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
| 52 |
+
|
| 53 |
+
WORKDIR $HOME/app
|
| 54 |
+
|
| 55 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 56 |
+
COPY --chown=user . $HOME/app
|
| 57 |
+
|
| 58 |
+
RUN chmod +x start_server.sh
|
| 59 |
+
|
| 60 |
+
EXPOSE 7860
|
| 61 |
+
CMD ["./start_server.sh"]
|