Spaces:
Sleeping
Sleeping
File size: 1,356 Bytes
4584aec e6660cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # Dockerfile สำหรับ Hugging Face Spaces (Docker SDK)
# รัน Streamlit app บน port 7860 (HF Spaces convention)
FROM python:3.11-slim
# ตั้ง working directory
WORKDIR /app
# ติดตั้ง system dependencies ที่จำเป็น (น้อยที่สุด)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# ก๊อป requirements ก่อน เพื่อให้ Docker cache ทำงาน
COPY requirements.txt .
# ติดตั้ง Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# ก๊อปโค้ดทั้งหมด
COPY . .
# สร้าง user ปกติ (HF Spaces ต้องการ — ไม่ใช่ root)
RUN useradd -m -u 1000 user && chown -R user:user /app
USER user
# Streamlit ใช้ home directory ของ user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
STREAMLIT_SERVER_PORT=7860 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# Expose port
EXPOSE 7860
# Entrypoint builds .streamlit/secrets.toml from Space secrets, then runs Streamlit
CMD ["bash", "entrypoint.sh"]
|