ARG BASE_IMAGE=python:3.11-slim-bookworm
FROM ${BASE_IMAGE}
ARG INDEX_URL=https://pypi.org/simple
ARG APT_MIRROR=deb.debian.org
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_SYSTEM_PYTHON=1
RUN sed -i "s@deb.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources && \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN pip install uv -i ${INDEX_URL}
COPY pyproject.toml uv.lock* ./
COPY . .
RUN uv pip install --system -e . --group backend --index-url ${INDEX_URL} --prerelease allow
RUN mkdir -p data/databases logs
RUN chmod +x start_backend.py || true
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')" || exit 1
CMD ["python", "start_backend.py"]