Really-amin commited on
Commit
c67f2fd
·
verified ·
1 Parent(s): 63f6088

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # پورت‌ها (HF معمولاً PORT=7860 می‌ده)
31
  EXPOSE 8000 7860
32
 
33
- # Health Check
34
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
35
- CMD python -c "import os, requests; requests.get('http://localhost:{}/health'.format(os.getenv('PORT', '8000')))" || exit 1
36
 
37
- # اجرای سرور با ماژول صحیح (app:app)
38
- CMD ["sh", "-c", "python -m uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
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}"]