Upload Dockerfile
Browse files- Dockerfile +12 -13
Dockerfile
CHANGED
|
@@ -1,38 +1,37 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
#
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PIP_NO_CACHE_DIR=1 \
|
| 7 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 8 |
ENABLE_AUTO_DISCOVERY=false
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN apt-get update && apt-get install -y \
|
| 12 |
gcc \
|
|
|
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
WORKDIR /app
|
| 17 |
|
| 18 |
-
#
|
| 19 |
COPY requirements.txt .
|
| 20 |
-
|
| 21 |
-
# نصب وابستگیهای Python
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
-
#
|
| 25 |
COPY . .
|
| 26 |
|
| 27 |
-
#
|
| 28 |
RUN mkdir -p logs
|
| 29 |
|
| 30 |
-
#
|
| 31 |
EXPOSE 8000 7860
|
| 32 |
|
| 33 |
-
#
|
| 34 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 35 |
-
CMD
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
CMD ["sh", "-c", "
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PIP_NO_CACHE_DIR=1 \
|
| 7 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 8 |
ENABLE_AUTO_DISCOVERY=false
|
| 9 |
|
| 10 |
+
# System dependencies (gcc + curl for healthcheck)
|
| 11 |
RUN apt-get update && apt-get install -y \
|
| 12 |
gcc \
|
| 13 |
+
curl \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# Workdir
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
+
# Python deps
|
| 20 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
+
# App code
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
+
# Logs dir
|
| 27 |
RUN mkdir -p logs
|
| 28 |
|
| 29 |
+
# Ports (HF usually sets PORT=7860)
|
| 30 |
EXPOSE 8000 7860
|
| 31 |
|
| 32 |
+
# Healthcheck without extra Python deps
|
| 33 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 34 |
+
CMD curl -f "http://127.0.0.1:${PORT:-8000}/health" || exit 1
|
| 35 |
|
| 36 |
+
# Run server (FastAPI app is in app.py -> app)
|
| 37 |
+
CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"]
|