ManTea commited on
Commit
60531e4
·
1 Parent(s): db406df
Files changed (1) hide show
  1. Dockerfile +25 -16
Dockerfile CHANGED
@@ -1,27 +1,36 @@
1
- FROM python:3.9-slim
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
- # Install system dependencies
6
- RUN apt-get update && apt-get install -y \
7
- build-essential \
8
- curl \
9
- software-properties-common \
10
- git \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy requirements and install Python dependencies
 
 
 
 
 
14
  COPY requirements.txt .
15
- RUN pip install --no-cache-dir -r requirements.txt
 
16
 
17
- # Copy application files
18
  COPY . .
19
 
20
- # Expose port for Streamlit
 
21
  EXPOSE 7860
 
22
 
23
- # Health check
24
- HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
25
-
26
- # Run Streamlit app
27
- ENTRYPOINT ["streamlit", "run", "main.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
+ # ---- Base Python ----
2
+ FROM python:3.11-slim # (nên dùng 3.11/3.12; nếu buộc 3.9 thì thay lại)
3
+
4
+ ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1
6
 
7
  WORKDIR /app
8
 
9
+ # ---- System deps (gọn, không recommends) ----
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ build-essential \
12
+ curl \
13
+ git \
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # (tuỳ app: nếu cần xử lý ảnh/video, mở thêm:)
17
+ # RUN apt-get update && apt-get install -y --no-install-recommends \
18
+ # ffmpeg libsm6 libxext6 libgl1 \
19
+ # && rm -rf /var/lib/apt/lists/*
20
+
21
+ # ---- Python deps ----
22
  COPY requirements.txt .
23
+ RUN pip install --upgrade pip \
24
+ && pip install --no-cache-dir -r requirements.txt
25
 
26
+ # ---- App code ----
27
  COPY . .
28
 
29
+ # ---- Streamlit config ----
30
+ # Dùng PORT do môi trường cung cấp (HF Spaces hoặc PaaS khác)
31
  EXPOSE 7860
32
+ HEALTHCHECK CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
33
 
34
+ # Chạy với $PORT nếu có, mặc định 7860 khi chạy local
35
+ ENV PORT=7860
36
+ ENTRYPOINT ["sh", "-c", "streamlit run main.py --server.address=0.0.0.0 --server.port=${PORT}"]