Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +12 -17
Dockerfile
CHANGED
|
@@ -1,42 +1,37 @@
|
|
| 1 |
-
FROM
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
# Use the official Python 3.9 image
|
| 4 |
-
FROM python:3.11.11
|
| 5 |
-
|
| 6 |
-
# Set the working directory to /code
|
| 7 |
WORKDIR /code
|
| 8 |
-
|
| 9 |
-
# Copy the current directory contents into the container at /code
|
| 10 |
COPY ./requirements.txt /code/requirements.txt
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
RUN useradd -m -u 1000 user
|
| 16 |
|
| 17 |
-
# Switch to the "user" user
|
| 18 |
USER user
|
| 19 |
|
| 20 |
-
# Set home to the user's home directory
|
| 21 |
ENV HOME=/home/user \
|
| 22 |
PATH=/home/user/.local/bin:$PATH
|
| 23 |
|
| 24 |
-
# Set the working directory to the user's home directory
|
| 25 |
WORKDIR $HOME/app
|
| 26 |
|
| 27 |
-
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
| 28 |
RUN pip install --no-cache-dir --upgrade pip
|
| 29 |
|
| 30 |
USER root
|
| 31 |
RUN apt-get update && apt-get install -y ffmpeg
|
| 32 |
|
| 33 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 34 |
COPY --chown=user . $HOME/app
|
| 35 |
|
| 36 |
RUN git config --global --add safe.directory /home/user/app
|
| 37 |
|
| 38 |
-
# Get secret EXAMPLE and output it to /test at buildtime
|
| 39 |
RUN --mount=type=secret,id=GENAI_API_KEY,mode=0444,required=true
|
| 40 |
|
| 41 |
-
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
| 42 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
|
|
|
|
| 1 |
+
FROM python:3.11-slim-bookworm
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /code
|
| 6 |
+
|
|
|
|
| 7 |
COPY ./requirements.txt /code/requirements.txt
|
| 8 |
|
| 9 |
+
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends gcc g++ && \
|
| 10 |
+
pip install --no-cache-dir --upgrade pip && \
|
| 11 |
+
pip install --no-cache-dir --upgrade -r /code/requirements.txt && \
|
| 12 |
+
pip install --no-cache-dir --upgrade setuptools wheel && \
|
| 13 |
+
pip install git+https://github.com/huggingface/transformers.git && \
|
| 14 |
+
apt-get purge -y --auto-remove gcc g++ && \
|
| 15 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
RUN useradd -m -u 1000 user
|
| 18 |
|
|
|
|
| 19 |
USER user
|
| 20 |
|
|
|
|
| 21 |
ENV HOME=/home/user \
|
| 22 |
PATH=/home/user/.local/bin:$PATH
|
| 23 |
|
|
|
|
| 24 |
WORKDIR $HOME/app
|
| 25 |
|
|
|
|
| 26 |
RUN pip install --no-cache-dir --upgrade pip
|
| 27 |
|
| 28 |
USER root
|
| 29 |
RUN apt-get update && apt-get install -y ffmpeg
|
| 30 |
|
|
|
|
| 31 |
COPY --chown=user . $HOME/app
|
| 32 |
|
| 33 |
RUN git config --global --add safe.directory /home/user/app
|
| 34 |
|
|
|
|
| 35 |
RUN --mount=type=secret,id=GENAI_API_KEY,mode=0444,required=true
|
| 36 |
|
|
|
|
| 37 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
|