# Use the base image with the correct Python version (e.g., Python 3.9) FROM python:3.9 # Create a new user with user ID 1000 (e.g., user) RUN useradd -m -u 1000 user # Switch to the created user for subsequent commands USER user # Update the PATH environment variable to include the user's local bin ENV PATH="/home/user/.local/bin:$PATH" # Set the working directory inside the container WORKDIR /app # Copy requirements.txt and set the ownership to the created user COPY --chown=user ./requirements.txt requirements.txt # Install the required Python dependencies without caching RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application files to the working directory COPY --chown=user . /app # Start the Streamlit app on port 7860, which is the default port expected by Hugging Face Spaces CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] # Reference: https://huggingface.co/docs/hub/en/spaces-sdks-docker