Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +23 -8
Dockerfile
CHANGED
|
@@ -3,21 +3,36 @@ FROM python:3.10-slim
|
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Install dependencies
|
| 7 |
-
RUN apt-get update &&
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
COPY requirements.txt .
|
| 14 |
-
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
# Expose port
|
| 20 |
EXPOSE 7860
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Run the app
|
| 23 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Install system dependencies
|
| 7 |
+
RUN apt-get update && \
|
| 8 |
+
apt-get install -y --no-install-recommends build-essential && \
|
| 9 |
+
rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Create and set writable cache directories with proper permissions
|
| 12 |
+
RUN mkdir -p /tmp/hf_cache && \
|
| 13 |
+
chmod -R 777 /tmp/hf_cache
|
| 14 |
|
| 15 |
+
# Set environment variables for Hugging Face cache
|
| 16 |
+
ENV HF_HOME=/tmp/hf_cache
|
| 17 |
+
ENV TRANSFORMERS_CACHE=/tmp/hf_cache
|
| 18 |
+
ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
|
| 19 |
+
|
| 20 |
+
# Copy requirements first to leverage Docker cache
|
| 21 |
COPY requirements.txt .
|
|
|
|
| 22 |
|
| 23 |
+
# Install Python dependencies
|
| 24 |
+
RUN pip install --upgrade pip && \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt
|
| 26 |
+
|
| 27 |
+
# Copy application code
|
| 28 |
COPY . .
|
| 29 |
|
| 30 |
# Expose port
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
+
# Run as non-root user for better security
|
| 34 |
+
RUN useradd -m myuser && chown -R myuser /app
|
| 35 |
+
USER myuser
|
| 36 |
+
|
| 37 |
# Run the app
|
| 38 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|