Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +21 -8
Dockerfile
CHANGED
|
@@ -4,20 +4,33 @@ FROM python:3.9-slim
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Install any needed packages specified in requirements.txt
|
| 11 |
-
RUN pip install --no-cache-dir --upgrade -r
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
COPY ./app.py /code/app.py
|
| 16 |
|
| 17 |
# Make port 7860 available
|
| 18 |
EXPOSE 7860
|
| 19 |
|
| 20 |
-
# --- AND CHANGE IS HERE ---
|
| 21 |
# Command to run your app.
|
| 22 |
-
# "app:app" means: "Look for a file named app.py, and inside it, find the object named app".
|
| 23 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
+
# --- NEW: Set up a non-root user ---
|
| 8 |
+
# Create a user 'user' with user ID 1000
|
| 9 |
+
RUN useradd -m -u 1000 user
|
| 10 |
+
# Switch to this new user
|
| 11 |
+
USER user
|
| 12 |
+
|
| 13 |
+
# --- NEW: Set environment variables for the user ---
|
| 14 |
+
# Set the home directory for the user
|
| 15 |
+
ENV HOME=/home/user
|
| 16 |
+
# Set the cache directory for transformers inside the user's home
|
| 17 |
+
# This is the key change to fix the permission error.
|
| 18 |
+
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 19 |
+
|
| 20 |
+
# Set the working directory to the user's home for subsequent operations
|
| 21 |
+
WORKDIR $HOME/app
|
| 22 |
+
|
| 23 |
+
# Copy the requirements file into the app directory
|
| 24 |
+
COPY --chown=user:user ./requirements.txt .
|
| 25 |
|
| 26 |
# Install any needed packages specified in requirements.txt
|
| 27 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 28 |
|
| 29 |
+
# Copy your app.py file into the app directory
|
| 30 |
+
COPY --chown=user:user ./app.py .
|
|
|
|
| 31 |
|
| 32 |
# Make port 7860 available
|
| 33 |
EXPOSE 7860
|
| 34 |
|
|
|
|
| 35 |
# Command to run your app.
|
|
|
|
| 36 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|