FROM alpine:3.23
WORKDIR /usr/app
COPY --chown=1000:1000 --chmod=400 ./requirements.txt ./
COPY --chown=1000:1000 --chmod=400 ./wsgi.py          ./
COPY --chown=root:root             ./app/             ./app/
RUN apk add --update --no-cache        \
        python3~=3                     \
        python3-dev~=3                 \
        curl-dev~=8                    \
        gcc~=15                        \
        musl-dev~=1                    \
        py3-pip~=25                 && \
    pip install                        \
        --no-cache-dir                 \
        --break-system-packages        \
        -r requirements.txt         && \
    rm requirements.txt             && \
    adduser -D -H ctf
EXPOSE 4000
USER ctf
CMD [                                  \
    "gunicorn",                        \
    "--bind", "0.0.0.0:3000",          \
    "--keep-alive", "5",               \
    "--worker-class", "gevent",        \
    "--access-logfile",                \
    "-",                               \
    "wsgi:app"                         \
]
