Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +15 -24
Dockerfile
CHANGED
|
@@ -1,40 +1,31 @@
|
|
| 1 |
-
# Stage 1: Builder
|
| 2 |
-
FROM python:3.9-slim as builder
|
| 3 |
-
|
| 4 |
-
WORKDIR /app
|
| 5 |
-
COPY requirements.txt .
|
| 6 |
-
|
| 7 |
-
RUN apt-get update && \
|
| 8 |
-
apt-get install -y --no-install-recommends gcc python3-dev && \
|
| 9 |
-
pip install --no-cache-dir -r requirements.txt gunicorn && \
|
| 10 |
-
rm -rf /var/lib/apt/lists/*
|
| 11 |
-
|
| 12 |
-
# Stage 2: Runtime
|
| 13 |
FROM python:3.9-slim
|
| 14 |
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
RUN apt-get update && \
|
| 19 |
-
apt-get install -y --no-install-recommends libgomp1 && \
|
| 20 |
rm -rf /var/lib/apt/lists/*
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
COPY
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Copy application code
|
| 27 |
COPY app.py text2generation.py ./
|
| 28 |
|
| 29 |
-
# Expose Hugging Face's default port
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
-
# Health check
|
| 33 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 \
|
| 34 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# Run with Gunicorn
|
| 40 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Set cache directory and fix numpy version
|
| 6 |
+
ENV TRANSFORMERS_CACHE=/tmp/huggingface-cache \
|
| 7 |
+
NUMBA_CACHE_DIR=/tmp/numba-cache \
|
| 8 |
+
HF_HOME=/tmp/huggingface-home
|
| 9 |
+
|
| 10 |
+
# Install system dependencies with cleanup
|
| 11 |
RUN apt-get update && \
|
| 12 |
+
apt-get install -y --no-install-recommends gcc python3-dev libgomp1 && \
|
| 13 |
rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
+
# Install Python dependencies with pinned numpy version
|
| 16 |
+
COPY requirements.txt .
|
| 17 |
+
RUN pip install --no-cache-dir -r requirements.txt numpy==1.26.4 && \
|
| 18 |
+
mkdir -p ${TRANSFORMERS_CACHE} && \
|
| 19 |
+
chmod 777 ${TRANSFORMERS_CACHE}
|
| 20 |
|
| 21 |
# Copy application code
|
| 22 |
COPY app.py text2generation.py ./
|
| 23 |
|
|
|
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
+
# Health check endpoint
|
| 27 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 \
|
| 28 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 29 |
|
| 30 |
+
# Run with Flask directly (no Gunicorn issues)
|
| 31 |
+
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|