Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +29 -11
Dockerfile
CHANGED
|
@@ -1,20 +1,38 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy the
|
| 8 |
-
COPY .
|
| 9 |
|
| 10 |
-
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Use the official Python image as the base image
|
| 2 |
+
FROM python:3.9
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy the requirements file into the container
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
|
| 10 |
+
# Install the dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Create a non-root user with a home directory
|
| 14 |
+
RUN useradd -m -u 1000 appuser
|
| 15 |
+
|
| 16 |
+
# Set environment variables for cache directories
|
| 17 |
+
ENV HF_HOME=/home/appuser/.cache/huggingface
|
| 18 |
+
ENV TRANSFORMERS_CACHE=/home/appuser/.cache/huggingface/transformers
|
| 19 |
+
ENV TORCH_HOME=/home/appuser/.cache/torch
|
| 20 |
+
|
| 21 |
+
# Create cache directories and set permissions
|
| 22 |
+
RUN mkdir -p $HF_HOME $TRANSFORMERS_CACHE $TORCH_HOME \
|
| 23 |
+
&& chown -R appuser:appuser /home/appuser/.cache
|
| 24 |
+
|
| 25 |
+
# Switch to the non-root user
|
| 26 |
+
USER appuser
|
| 27 |
|
| 28 |
+
# Copy the rest of the application code
|
| 29 |
+
COPY . .
|
| 30 |
+
|
| 31 |
+
# Set the environment variable for the Hugging Face API token
|
| 32 |
+
ENV HUGGINGFACEHUB_API_TOKEN=your_huggingface_api_token
|
| 33 |
+
|
| 34 |
+
# Expose the port the app runs on
|
| 35 |
+
EXPOSE 8000
|
| 36 |
|
| 37 |
+
# Command to run the application
|
| 38 |
+
CMD ["python", "app.py"]
|