FROM docker.io/library/python:3.13-trixie
ENV PYTHONUNBUFFERED=1
ENV DEBUG="0"
ENV DATABASE_URL="sqlite:////data/database/tinywiki.sqlite"
ENV MEDIA_URL="media/"
ENV MEDIA_ROOT="/data/media"
ENV STATIC_URL="static/"
ENV STATIC_ROOT="/data/static"

RUN apt update \
    && apt upgrade -y \
    && apt install -y gettext libxmlsec1-dev xmlsec1\
    && python -m pip install --upgrade pip \
    && pip install poetry \
    && mkdir /app \
    && mkdir -p /data/static /data/media /data/database
VOLUME "/data"

WORKDIR /app
COPY . .

RUN poetry install --all-groups \
    && chmod 0755 start-django.sh
HEALTHCHECK --interval=30s --retries=5 --timeout=30s CMD curl -sS 127.0.0.1:8000
EXPOSE 8000
ENTRYPOINT ["/app/start-django.sh"]
