FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV STREAMLIT_SERVER_PORT=8501 ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ wget \ && rm -rf /var/lib/apt/lists/* # Create a non-root user to run the application RUN useradd -m -u 1000 appuser # Copy the entire project directory # .dockerignore should exclude .venv and other unnecessary files COPY . . # Install uv and dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install uv && \ uv venv /app/.venv && \ . /app/.venv/bin/activate && \ uv pip install . && \ uv sync # Set environment variable to use the venv ENV PATH="/app/.venv/bin:$PATH" # Create and set permissions for directories that need write access RUN mkdir -p /.local && \ chown -R appuser:appuser /.local && \ mkdir -p /home/appuser/.cache && \ chown -R appuser:appuser /home/appuser # Set proper permissions for all app files RUN chown -R appuser:appuser /app # Switch to non-root user USER appuser # Expose Streamlit port EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health # Command to run the application CMD ["streamlit", "run", "app/main.py", "--server.port=8501", "--server.address=0.0.0.0"]