Spaces:
Running
Running
# Use a stable and widely compatible Python version | |
FROM python:3.11-slim | |
# Set the working directory | |
WORKDIR /app | |
# Create a non-root user and a writable home directory to solve permission errors | |
RUN useradd -m -u 1000 appuser | |
ENV HOME=/home/appuser | |
ENV MPLCONFIGDIR=$HOME/.config/matplotlib | |
# Copy requirements and install them, giving ownership to the new user | |
COPY --chown=appuser:appuser requirements.txt ./ | |
RUN pip install --no-cache-dir -r requirements.txt | |
# --- THIS IS THE CRITICAL FIX --- | |
# Copy the application source code AND the data folder | |
COPY --chown=appuser:appuser src/ ./src/ | |
COPY --chown=appuser:appuser data/ ./data/ | |
# --- END OF FIX --- | |
# Switch to the non-root user before running the app | |
USER appuser | |
# Expose the Streamlit port | |
EXPOSE 8501 | |
# Define the healthcheck for the app | |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
# Define the command to run the app | |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |