FROM python:3.13-alpine3.23 AS builder
ENV UV_SYSTEM_PYTHON=1
COPY pyproject.toml .
RUN pip install uv && uv pip install -r pyproject.toml && pip uninstall -y uv

FROM python:3.13-alpine3.23

COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages

WORKDIR /code

# Set user and group
ARG user=apps
ARG uid=1001
ARG gid=1001

RUN addgroup -S ${user} && adduser -S ${user} -G ${user} -u ${uid} -s /bin/sh

RUN apk add --no-cache gettext pango ttf-dejavu
RUN chown -R ${user}:${user} /code

COPY --chown=${user}:${user} . /code

RUN apk add --no-cache --virtual .tailwind-runtime libstdc++ libgcc \
    && su ${user} -c "sh ./scripts/build.sh" \
    && apk del .tailwind-runtime

USER ${user}
CMD ["sh", "./scripts/run.sh"]
