# Use Python base image FROM python:3.13-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* # Install uv globally for all users RUN curl -LsSf https://astral.sh/uv/install.sh | sh ENV PATH="/root/.local/bin:$PATH" # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies with uv (as root first) RUN uv pip install --system -r requirements.txt # Create non-root user for security RUN useradd --create-home --shell /bin/bash app && \ chown -R app:app /app # Copy uv binary to system location for app user access RUN cp /root/.local/bin/uv /usr/local/bin/uv && \ chmod +x /usr/local/bin/uv # Switch to app user USER app # Copy application code COPY --chown=app:app . . # Create necessary directories RUN mkdir -p autonomous_demand_forecasting/database && \ mkdir -p logs # Fix line endings and make scripts executable RUN sed -i 's/\r$//' start.sh && chmod +x start.sh # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV PORT=7860 # Health check for Streamlit HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:${PORT}/_stcore/health || exit 1 # Expose port for Streamlit EXPOSE 7860 # Start the application CMD ["bash", "start.sh"]