Spaces:
Sleeping
Sleeping
Commit
·
a55a81e
1
Parent(s):
e61d508
Updated
Browse files- Dockerfile +4 -23
Dockerfile
CHANGED
|
@@ -1,46 +1,27 @@
|
|
| 1 |
-
# Use lightweight Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Install system dependencies as root
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
| 7 |
git \
|
| 8 |
curl \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
# Create non-root user
|
| 12 |
RUN useradd -m appuser
|
| 13 |
-
|
| 14 |
-
# Set working directory
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
# Copy requirements first for caching
|
| 18 |
COPY requirements.txt .
|
| 19 |
-
|
| 20 |
-
# Install Python dependencies
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
# Copy project files
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
-
# Give appuser ownership of /app
|
| 27 |
RUN chown -R appuser:appuser /app
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
RUN mkdir -p /app/huggingface_cache && chmod -R 777 /app/huggingface_cache
|
| 31 |
-
|
| 32 |
-
# Switch to non-root user
|
| 33 |
-
USER appuser
|
| 34 |
-
|
| 35 |
-
# Expose FastAPI port
|
| 36 |
-
EXPOSE 7860
|
| 37 |
-
|
| 38 |
-
# Environment variables
|
| 39 |
ENV HF_HOME=/app/huggingface_cache
|
| 40 |
ENV TRANSFORMERS_CACHE=/app/huggingface_cache
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
|
| 45 |
-
# Run FastAPI
|
| 46 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
RUN apt-get update && apt-get install -y \
|
| 4 |
build-essential \
|
| 5 |
git \
|
| 6 |
curl \
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
|
|
|
| 9 |
RUN useradd -m appuser
|
|
|
|
|
|
|
| 10 |
WORKDIR /app
|
| 11 |
|
|
|
|
| 12 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
|
|
|
| 15 |
COPY . .
|
| 16 |
|
|
|
|
| 17 |
RUN chown -R appuser:appuser /app
|
| 18 |
|
| 19 |
+
# HuggingFace cache config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
ENV HF_HOME=/app/huggingface_cache
|
| 21 |
ENV TRANSFORMERS_CACHE=/app/huggingface_cache
|
| 22 |
+
RUN rm -rf /root/.cache/huggingface && mkdir -p /app/huggingface_cache && chmod -R 777 /app/huggingface_cache
|
| 23 |
|
| 24 |
+
USER appuser
|
| 25 |
+
EXPOSE 7860
|
| 26 |
|
|
|
|
| 27 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|