Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +21 -6
Dockerfile
CHANGED
|
@@ -1,24 +1,39 @@
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
-
WORKDIR /
|
| 4 |
|
| 5 |
# Install system dependencies for document processing
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
ffmpeg \
|
|
|
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
# Copy requirements
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
# Copy application code
|
| 15 |
COPY . .
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Create temp directory for file processing
|
| 18 |
RUN mkdir -p /tmp/materials
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
# Start the application
|
| 24 |
-
CMD uvicorn app:app --host 0.0.0.0 --port
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
WORKDIR /app
|
| 4 |
|
| 5 |
# Install system dependencies for document processing
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
ffmpeg \
|
| 8 |
+
libmagic1 \
|
| 9 |
+
poppler-utils \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Copy requirements first for better caching
|
| 13 |
COPY requirements.txt .
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
# Copy application code
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
+
# Create a non-root user (better security for Hugging Face)
|
| 20 |
+
RUN useradd -m -u 1000 user
|
| 21 |
+
RUN chown -R user:user /app
|
| 22 |
+
USER user
|
| 23 |
+
|
| 24 |
# Create temp directory for file processing
|
| 25 |
RUN mkdir -p /tmp/materials
|
| 26 |
|
| 27 |
+
# Set environment variables
|
| 28 |
+
ENV PYTHONUNBUFFERED=1
|
| 29 |
+
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
|
| 30 |
+
|
| 31 |
+
# Expose port (Hugging Face uses port 7860 by default)
|
| 32 |
+
EXPOSE 7860
|
| 33 |
+
|
| 34 |
+
# Health check command (Hugging Face Spaces requirement)
|
| 35 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 36 |
+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
|
| 37 |
|
| 38 |
+
# Start the application with gunicorn for production
|
| 39 |
+
CMD uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1
|