Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +10 -21
Dockerfile
CHANGED
|
@@ -1,32 +1,21 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy
|
| 8 |
-
COPY requirements.txt .
|
| 9 |
|
| 10 |
-
# Install
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# Copy
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
ENV PORT=7860
|
| 18 |
-
|
| 19 |
-
# Expose the port the app runs on
|
| 20 |
EXPOSE 7860
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
# It uses gthread workers and a longer timeout to ensure stable connections for sessions.
|
| 25 |
-
CMD ["gunicorn", \
|
| 26 |
-
"--bind", "0.0.0.0:7860", \
|
| 27 |
-
"--workers", "1", \
|
| 28 |
-
"--threads", "4", \
|
| 29 |
-
"--timeout", "60", \
|
| 30 |
-
"--worker-class", "gthread", \
|
| 31 |
-
"--forwarded-allow-ips", "*", \
|
| 32 |
-
"app:app"]
|
|
|
|
| 1 |
+
# Use a modern Python base
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy dependency list first (cache layer)
|
| 8 |
+
COPY requirements.txt ./
|
| 9 |
|
| 10 |
+
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Copy application code
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
+
# Expose the default port
|
| 17 |
ENV PORT=7860
|
|
|
|
|
|
|
| 18 |
EXPOSE 7860
|
| 19 |
|
| 20 |
+
# Use gunicorn for production; keep one worker with threads (adjust workers for your need)
|
| 21 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "60", "--worker-class", "gthread", "app:app"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|