FROM alpine:3.23
WORKDIR /usr/app
COPY --chmod=400 --chown=root:root ./getflag.c   /
COPY --chmod=400 --chown=root:root ./flag.txt    /root/
COPY --chmod=775 --chown=root:root ./app/        ./
RUN apk add --update --no-cache           \
        supervisor~=4                     \
        nodejs~=24                        \
        npm~=11                           \
        gcc~=15                           \
        build-base~=0.5                && \
    npm install                        && \
    mv fr it en node_modules           && \
    gcc /getflag.c -o /getflag         && \
    chmod u+s /getflag                 && \
    rm /getflag.c                      && \
    mkdir -p /etc/supervisor/conf.d/   && \
    adduser -H -D ctf
COPY --chmod=775 --chown=ctf:ctf   ./run.sh        /home/ctf/
COPY --chmod=775 --chown=ctf:ctf   ./messages.js   /home/ctf/
COPY --chmod=400 --chown=root:root ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ENV TMPDIR=/fcsc
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
