Spaces:
Paused
Paused
Upload Dockerfile
Browse files- Dockerfile +22 -4
Dockerfile
CHANGED
|
@@ -1,14 +1,32 @@
|
|
| 1 |
-
FROM python:3.10
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
COPY requirements.txt .
|
| 6 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
|
|
|
| 8 |
COPY . .
|
| 9 |
|
| 10 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
EXPOSE 7860
|
| 12 |
|
| 13 |
-
# Run
|
| 14 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Copy requirements first
|
| 6 |
COPY requirements.txt .
|
| 7 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
|
| 9 |
+
# Copy app files
|
| 10 |
COPY . .
|
| 11 |
|
| 12 |
+
# Create non-root user with home directory
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
+
# Create matplotlib config directory and set permissions
|
| 16 |
+
RUN mkdir -p /app/.config/matplotlib && \
|
| 17 |
+
mkdir -p /app/.cache && \
|
| 18 |
+
chown -R user:user /app
|
| 19 |
+
|
| 20 |
+
# Switch to non-root user
|
| 21 |
+
USER user
|
| 22 |
+
|
| 23 |
+
# Set environment variables for matplotlib
|
| 24 |
+
ENV MPLCONFIGDIR=/app/.config/matplotlib
|
| 25 |
+
ENV MATPLOTLIB_CACHE_DIR=/app/.cache
|
| 26 |
+
ENV HOME=/app
|
| 27 |
+
|
| 28 |
+
# HF Spaces expects port 7860
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
+
# Run with gunicorn
|
| 32 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|