mcp-stock-math / Dockerfile
Entz's picture
Upload 8 files
29206ac verified
# Dockerfile
# Use the same base as before
FROM python:3.10-slim
# Create a non-root user matching HF Spaces runtime (UID 1000)
RUN useradd -m -u 1000 user
# Switch to the non-root user
USER user
# Set HOME and PATH for the user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory under HOME
WORKDIR $HOME/app
# (Optional) system deps if you need them; safe to remove if not needed
# Note: Run as root if needed, but here it's fine as user since no installs yet
USER root
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
USER user
# Install Python deps as the user
COPY --chown=user requirements.txt $HOME/app/
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Copy code with correct ownership
COPY --chown=user . $HOME/app/
# Create .streamlit config to disable usage stats (prevents the write attempt causing permission errors)
RUN mkdir -p $HOME/.streamlit \
&& echo "[browser]\ngatherUsageStats = false" > $HOME/.streamlit/config.toml
# Do NOT set STREAMLIT_SERVER_PORT here.
# Spaces will inject $PORT at runtime.
# Start Streamlit on the port Spaces provides, and bind to 0.0.0.0
CMD ["streamlit", "run", "frontend.py", "--server.port", "8501", "--server.address", "0.0.0.0"]