FROM python:3.12-slim-bookworm

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH=/service_app

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /service_app

# Create logs directory
RUN mkdir -p /service_app/logs

COPY ApiServices/AuthService/pyproject.toml .

RUN uv venv .venv
RUN . .venv/bin/activate && uv pip install -r pyproject.toml

COPY ApiServices ./ApiServices
COPY databases ./databases
COPY api_services ./api_services
COPY api_objects ./api_objects
COPY api_configs ./api_configs
COPY api_events ./api_events
COPY api_library ./api_library
COPY api_validations ./api_validations

WORKDIR /service_app/ApiServices/AuthService

# Create startup script
RUN echo '#!/bin/bash\n\
source /service_app/.venv/bin/activate\n\
exec python app.py' > /service_app/start.sh && \
    chmod +x /service_app/start.sh

CMD ["/service_app/start.sh"]
