gtech13's picture
Update Dockerfile
78a56d4 verified
raw
history blame contribute delete
922 Bytes
FROM python:3.10
# 1. Set a temporary working directory
WORKDIR /code
# 2. Copy requirements and install them GLOBALLY (Prevents "Streamlit not found" errors)
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# 3. Create the restricted user required by Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
# 4. Set up the user's safe environment variables
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:/usr/local/bin:$PATH
# 5. Set the working directory to the user's safe space
WORKDIR $HOME/app
# 6. Copy your app.py and images into the container
COPY --chown=user:user . $HOME/app
# 7. Launch Streamlit safely with CORS disabled so Hugging Face doesn't hang
CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0", "--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]