Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +22 -7
Dockerfile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 10 |
HF_HOME=/tmp/huggingface \
|
|
@@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 \
|
|
| 12 |
HF_DATASETS_CACHE=/tmp/huggingface \
|
| 13 |
HF_HUB_CACHE=/tmp/huggingface
|
| 14 |
|
| 15 |
-
#
|
| 16 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 17 |
build-essential \
|
| 18 |
ffmpeg \
|
|
@@ -20,9 +20,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 20 |
curl \
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
-
#
|
| 24 |
COPY requirements.txt .
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
RUN mkdir -p /tmp/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ===== Base Image =====
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# ===== Working Directory =====
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# ===== Environment Variables =====
|
| 8 |
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 10 |
HF_HOME=/tmp/huggingface \
|
|
|
|
| 12 |
HF_DATASETS_CACHE=/tmp/huggingface \
|
| 13 |
HF_HUB_CACHE=/tmp/huggingface
|
| 14 |
|
| 15 |
+
# ===== System Dependencies =====
|
| 16 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 17 |
build-essential \
|
| 18 |
ffmpeg \
|
|
|
|
| 20 |
curl \
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
+
# ===== Python Dependencies =====
|
| 24 |
COPY requirements.txt .
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
+
# ===== Cache & Permissions =====
|
| 28 |
+
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface
|
| 29 |
+
|
| 30 |
+
# ===== Copy Project Files =====
|
| 31 |
+
COPY . .
|
| 32 |
+
|
| 33 |
+
# ===== Optional Performance Libraries =====
|
| 34 |
+
RUN pip install --no-cache-dir uvloop gunicorn
|
| 35 |
+
|
| 36 |
+
# ===== Expose App Port =====
|
| 37 |
+
EXPOSE 7860
|
| 38 |
+
|
| 39 |
+
# ===== Healthcheck =====
|
| 40 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/health || exit 1
|
| 41 |
+
|
| 42 |
+
# ===== Start App =====
|
| 43 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2", "--timeout-keep-alive", "30"]
|