Update Dockerfile
Browse files- Dockerfile +6 -15
Dockerfile
CHANGED
|
@@ -4,15 +4,14 @@ FROM python:3.10-slim
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy files
|
| 8 |
-
|
| 9 |
-
COPY . .
|
| 10 |
|
| 11 |
# Install dependencies
|
| 12 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
-
# Create cache directory
|
| 15 |
-
RUN mkdir -p /app/hf_cache
|
| 16 |
|
| 17 |
# Set environment variables for Hugging Face cache
|
| 18 |
ENV HF_HOME=/app/hf_cache
|
|
@@ -21,16 +20,8 @@ ENV TRANSFORMERS_CACHE=/app/hf_cache
|
|
| 21 |
# Expose Space port
|
| 22 |
EXPOSE 7860
|
| 23 |
|
| 24 |
-
# --- FIX IS HERE ---
|
| 25 |
-
# Create non-root user
|
| 26 |
-
RUN useradd -m appuser
|
| 27 |
-
|
| 28 |
-
# Give the new user ownership of the entire app directory
|
| 29 |
-
# This includes all code files and the hf_cache
|
| 30 |
-
RUN chown -R appuser:appuser /app
|
| 31 |
-
# --- END FIX ---
|
| 32 |
-
|
| 33 |
# Switch to non-root user
|
|
|
|
| 34 |
USER appuser
|
| 35 |
|
| 36 |
# Run Flask directly (no Gunicorn)
|
|
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy files
|
| 8 |
+
COPY . .
|
|
|
|
| 9 |
|
| 10 |
# Install dependencies
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Create cache directory and make it writable for non-root
|
| 14 |
+
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
|
| 15 |
|
| 16 |
# Set environment variables for Hugging Face cache
|
| 17 |
ENV HF_HOME=/app/hf_cache
|
|
|
|
| 20 |
# Expose Space port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# Switch to non-root user
|
| 24 |
+
RUN useradd -m appuser
|
| 25 |
USER appuser
|
| 26 |
|
| 27 |
# Run Flask directly (no Gunicorn)
|