FROM python:3.13-alpine

ENV PYTHONUNBUFFERED=1 \
    PORT=8000

WORKDIR /app

RUN addgroup -S game && adduser -S game -G game

COPY --chown=game:game app/ /app/

USER game

EXPOSE 8000

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

CMD ["python", "-u", "server.py"]
