# Use the official Python 3.10 slim image as a base FROM python:3.10-slim # Set the working directory inside the container WORKDIR /app # Copy the requirements file into the container COPY requirements.txt ./requirements.txt # Install the Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy your Streamlit application file into the container COPY streamlit_app.py ./streamlit_app.py # Expose the port that Streamlit will run on EXPOSE 8501 # Create a non-root user for security RUN useradd -m -u 1000 user # Set up writable cache directories and give the new user ownership RUN mkdir -p /home/user/.cache && \ chown -R user:user /home/user/.cache # Switch to the non-root user USER user # Set environment variables to point to the new cache directories ENV TRANSFORMERS_CACHE=/home/user/.cache/transformers \ HF_HOME=/home/user/.cache/huggingface # The command to run your Streamlit application when the container starts ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]