FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    postgresql-client \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install uv and add to path
ENV PATH="/root/.cargo/bin:${PATH}"
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
    echo 'export PATH="/root/.cargo/bin:$PATH"' >> /root/.bashrc

# Set working directory
WORKDIR /app

# Copy project files
COPY . .

# Install Python dependencies using uv
RUN . /root/.bashrc && \
    uv pip install --system --no-cache-dir -e .

# Create directory for logs
RUN mkdir -p /root/.automagik/logs

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV AUTOMAGIK_ENV=production

# Expose port for API
EXPOSE 8888
