ARG PYTHON_VERSION

FROM docker.io/library/python:${PYTHON_VERSION}-alpine

RUN apk update --no-cache \
    && apk upgrade --no-cache \
    && pip install --no-cache-dir --upgrade pip

RUN addgroup -g 10001 py \
    && adduser -D -u 10000 -G py py

WORKDIR /var/app

COPY build/requirements.txt ./

RUN pip install --no-cache-dir \
    --require-hashes \
    --requirement requirements.txt

USER 10000:10001

COPY alembic.ini entrypoint.sh pyproject.toml run ./
COPY alembic ./alembic
COPY scripts ./scripts
COPY unwind ./unwind

RUN pip install --no-cache-dir --editable .

ENV UNWIND_DATA="/data"
VOLUME $UNWIND_DATA

ENV UNWIND_PORT=8097
EXPOSE $UNWIND_PORT

ENTRYPOINT ["/var/app/entrypoint.sh"]
CMD ["server"]
