Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +8 -4
Dockerfile
CHANGED
|
@@ -6,14 +6,15 @@ COPY requirements.txt .
|
|
| 6 |
|
| 7 |
RUN apt-get update && \
|
| 8 |
apt-get install -y --no-install-recommends gcc python3-dev && \
|
| 9 |
-
pip install --user -r requirements.txt
|
|
|
|
| 10 |
|
| 11 |
# Stage 2: Runtime
|
| 12 |
FROM python:3.9-slim
|
| 13 |
|
| 14 |
WORKDIR /app
|
| 15 |
|
| 16 |
-
# Copy
|
| 17 |
COPY --from=builder /root/.cache /root/.cache
|
| 18 |
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
|
| 19 |
|
|
@@ -25,9 +26,12 @@ RUN apt-get update && \
|
|
| 25 |
# Copy application code
|
| 26 |
COPY app.py text2generation.py ./
|
| 27 |
|
| 28 |
-
#
|
| 29 |
EXPOSE 7860
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 32 |
|
|
|
|
| 33 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|
|
|
|
| 6 |
|
| 7 |
RUN apt-get update && \
|
| 8 |
apt-get install -y --no-install-recommends gcc python3-dev && \
|
| 9 |
+
pip install --user -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 |
+
# Copy Python dependencies from builder
|
| 18 |
COPY --from=builder /root/.cache /root/.cache
|
| 19 |
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
|
| 20 |
|
|
|
|
| 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 |
+
# Run with Gunicorn (now properly installed)
|
| 37 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|