Really-amin commited on
Commit
5788794
·
verified ·
1 Parent(s): 06abcc2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -3
Dockerfile CHANGED
@@ -1,23 +1,36 @@
 
1
  FROM python:3.11-slim
2
 
 
3
  ENV PYTHONUNBUFFERED=1 \
4
  PYTHONDONTWRITEBYTECODE=1 \
5
  PIP_NO_CACHE_DIR=1 \
6
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
7
  ENABLE_AUTO_DISCOVERY=false \
8
- PORT=7860
9
 
 
10
  RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
11
 
 
12
  WORKDIR /app
13
 
 
14
  COPY requirements.txt .
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
 
17
  COPY . .
18
 
 
19
  RUN mkdir -p logs
20
 
21
- EXPOSE 7860
 
22
 
23
- CMD ["uvicorn", "api_server_extended:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
1
+ # استفاده از Python 3.11 Slim
2
  FROM python:3.11-slim
3
 
4
+ # تنظیم متغیرهای محیطی پایه
5
  ENV PYTHONUNBUFFERED=1 \
6
  PYTHONDONTWRITEBYTECODE=1 \
7
  PIP_NO_CACHE_DIR=1 \
8
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
9
  ENABLE_AUTO_DISCOVERY=false \
10
+ PORT=8000
11
 
12
+ # نصب وابستگی‌های سیستمی
13
  RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
14
 
15
+ # دایرکتوری کاری
16
  WORKDIR /app
17
 
18
+ # نصب پکیج‌ها
19
  COPY requirements.txt .
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
+ # کپی کل سورس
23
  COPY . .
24
 
25
+ # دایرکتوری لاگ‌ها
26
  RUN mkdir -p logs
27
 
28
+ # فقط روی یک پورت واحد کار می‌کنیم (۸۰۰۰)
29
+ EXPOSE 8000
30
 
31
+ # Healthcheck مثل قبل، فقط مطمئن می‌شیم از همون PORT استفاده می‌کند
32
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
33
+ CMD python -c "import os, requests; requests.get('http://localhost:{}/health'.format(os.getenv('PORT', '8000')))" || exit 1
34
+
35
+ # اجرای همان سرور اصلی خودت
36
+ CMD ["sh", "-c", "python -m uvicorn api_server_extended:app --host 0.0.0.0 --port ${PORT}"]