File size: 1,159 Bytes
6a2bbff 4eaff40 fb67f1e 4eaff40 6a2bbff fb67f1e ebcc94a 4eaff40 ebcc94a fb67f1e 4eaff40 fb67f1e 4eaff40 fb67f1e 4eaff40 fb67f1e 698ccbf 2d7bceb fb67f1e e39ffd5 4eaff40 fb67f1e 2b882c5 fb67f1e | 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 43 44 | FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc g++ \
redis-server \
nginx \
&& rm -rf /var/lib/apt/lists/*
# Setup Nginx for non-root user
RUN mkdir -p /var/lib/nginx /var/log/nginx /run/nginx && \
chown -R 1000:1000 /var/lib/nginx /var/log/nginx /run/nginx
# 🚀 CRITICAL FOR HUGGING FACE SPACES 🚀
# HF Spaces run as a non-root user (uid 1000)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy and install dependencies first (caches this step)
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy the rest of the application
COPY --chown=user . .
# Create necessary directories for the backend
RUN mkdir -p backend/runs backend/tmp
RUN chmod +x start.sh
ENV PYTHONPATH=$HOME/app/backend:$PYTHONPATH
ENV MAX_UPLOAD_MB=500
# Tell your start.sh script to boot Streamlit on 7860 (the only port HF exposes)
ENV PORT=7860
EXPOSE 7860
# Start up using your existing robust launch script (handles FastAPI + Streamlit simultaneously)
CMD ["bash", "start.sh"]
|