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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -12
Dockerfile CHANGED
@@ -1,38 +1,38 @@
1
  FROM python:3.11-slim
2
 
3
- # Environment
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 deps (gcc + curl برای 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
- # Dependencies
20
  COPY requirements.txt .
21
 
 
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
- # App code
25
  COPY . .
26
 
27
- # Logs dir
28
  RUN mkdir -p logs
29
 
30
- # Ports (HF معمولا فقط از PORT استفاده می‌کنه، ولی این اشکالی نداره)
31
  EXPOSE 8000 7860
32
 
33
- # Healthcheck (بدون نیاز به requests)
34
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
35
- CMD curl -f "http://127.0.0.1:${PORT:-8000}/health" || exit 1
36
 
37
- # Run server (HF PORT env var)
38
- CMD ["sh", "-c", "uvicorn api_server_extended:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
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}"]