# Use Python 3.12-slim as the base image
FROM python:3.12-slim

# Set the working directory in the container
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements file
COPY requirements.txt requirements.txt

# Upgrade pip and install dependencies
RUN pip install --no-cache-dir -U pip && pip install --no-cache-dir -r requirements.txt

# Create a fake sudo command to bypass sudo errors
RUN echo '#!/bin/sh\nexec "$@"' > /usr/bin/sudo && chmod +x /usr/bin/sudo

# Clone and install TemporalLib
RUN git clone --depth 1 https://github.com/TheRandonauts/temporal.git /app/temporal \
    && cd /app/temporal \
    && ./make.sh \
    && rm -rf /app/temporal

# Copy application files
COPY . .

# Expose Streamlit's default port
EXPOSE 8501

# Run the application
CMD ["streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]