# Dockerfile  --  CYBR 358 Buffer Overflow environment (x86-64 Linux).
#
# One image, identical for every student. Build once, exploit inside.
#
# On Apple Silicon or any ARM host this image runs under emulation, and the
# debugger can be flaky there. See DEPLOY.md for the verified x86-64 VM fallback.
FROM --platform=linux/amd64 ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        gcc gdb make python3 python3-pip file binutils ca-certificates \
    && pip3 install --no-cache-dir --break-system-packages pwntools \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /lab
COPY src/ /lab/src/
COPY lab-doctor.sh /lab/
COPY solve.example.py /lab/
COPY hints/ /lab/hints/
RUN chmod +x /lab/lab-doctor.sh && make -C /lab/src all

# A non-root user. Debugging does NOT need root, and --privileged is never
# required for this lab; do not add it.
RUN useradd -m student && chown -R student:student /lab
USER student
WORKDIR /lab
CMD ["/bin/bash"]
