FROM python:3.12-alpine

ARG VCS_REF=unknown

LABEL org.opencontainers.image.title="Alta Video Player DEV" \
      org.opencontainers.image.description="WebAVP browser runtime for isolated DEV review" \
      org.opencontainers.image.source="https://git.pejicorp.com/peji/WebAVP" \
      org.opencontainers.image.revision="${VCS_REF}"

ENV WEBAVP_HOST=0.0.0.0 \
    WEBAVP_PORT=5152 \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

RUN addgroup -S -g 10001 webavp \
    && adduser -S -D -H -u 10001 -G webavp webavp

COPY --chown=10001:10001 app.py ./
COPY --chown=10001:10001 static ./static
COPY --chown=10001:10001 templates ./templates

USER 10001:10001

EXPOSE 5152

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5152/', timeout=3).read(1)"

CMD ["python", "app.py"]
