Test / Dockerfile
UKielz's picture
Update Dockerfile
321a434 verified
raw
history blame contribute delete
996 Bytes
FROM python:3.10-slim
WORKDIR /app
COPY . /app
# Install dependencies
RUN pip install --no-cache-dir -r requirements_product.txt
# Create a non-root user (match HF Spaces' default UID)
RUN useradd -m -u 1000 appuser
# Create cache and config directories in /data (persistent storage)
RUN mkdir -p /data/hf_cache /data/streamlit_config && \
chown -R appuser:appuser /data/hf_cache /data/streamlit_config /app && \
chmod -R 775 /data/hf_cache /data/streamlit_config /app
# Clean up any lock files in the cache
RUN rm -rf /data/hf_cache/huggingface/hub/*
# Set environment variables for Hugging Face and Streamlit
ENV HF_HOME=/data/hf_cache
ENV TRANSFORMERS_CACHE=/data/hf_cache
ENV STREAMLIT_HOME=/data/streamlit_config
ENV STREAMLIT_CONFIG_DIR=/data/streamlit_config
# Switch to non-root user
USER appuser
# Expose ports
EXPOSE 7860
EXPOSE 8000
CMD ["bash", "-c", "uvicorn server:app --host 0.0.0.0 --port 8000 & streamlit run app.py --server.port 7860 --server.address 0.0.0.0"]