# Dockerfile.backend
# Backend FastAPI production image

FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*

# Install uv
RUN pip install uv

# Copy dependency files
COPY pyproject.toml uv.lock ./

# Install dependencies
RUN uv sync --frozen --no-dev

# Copy application code
COPY src/ ./src/
COPY alembic/ ./alembic/
COPY alembic.ini ./

# Run migrations and start application
CMD ["sh", "-c", "echo 'DATABASE_URL from env: '$DATABASE_URL && uv run alembic upgrade head && uv run uvicorn src.main:app --host 0.0.0.0 --port 8000"]
