Spaces:
Sleeping
Sleeping
File size: 1,310 Bytes
29206ac c568c6d effc62f c568c6d effc62f c568c6d 3d072c5 c568c6d a5f67d6 fef55f9 c568c6d fef55f9 c568c6d effc62f c568c6d fef55f9 effc62f c568c6d effc62f fef55f9 e67b323 fef55f9 c568c6d |
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 |
# 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"] |