text_embedding_model / Dockerfile
B4869's picture
bug fix again
8cb12cf
raw
history blame
1.06 kB
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# Hugging Face Spaces best practices for Docker
FROM python:3.9
# สร้าง non-root user เพื่อความปลอดภัย
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# ตั้งค่า cache directory สำหรับ Hugging Face models
# ใช้ /tmp เพราะมี space มากกว่า default location (~/.cache/)
ENV HF_HOME="/home/user/.cache/huggingface"
WORKDIR /app
# Copy requirements และ install dependencies
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY --chown=user ./download_model.py download_model.py
RUN python download_model.py
# Copy application code
COPY --chown=user . /app
# Expose port 7860 (default port สำหรับ Hugging Face Spaces)
EXPOSE 7860
# Run Flask app with Gunicorn (production WSGI server)
CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120"]