Files
ctf/2026/cscg/misc/table-madness/service-entry/Dockerfile
2026-04-10 03:31:12 +02:00

44 lines
1.4 KiB
Docker

FROM debian:bookworm AS builder
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
libguestfs-tools cloud-image-utils curl linux-image-amd64 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
RUN chmod 0644 /boot/vmlinuz*
RUN curl -Lo user.qcow2 https://cloud.debian.org/images/cloud/bookworm/20260316-2418/debian-12-nocloud-amd64-20260316-2418.qcow2 && \
echo "661a11d853616ba72913ace404961a28350c58eb4041edd2c847aec932d5b99b user.qcow2" | sha256sum --check
COPY entry.service vmentry.sh .
RUN virt-customize -a user.qcow2 \
--update \
--install socat \
--install python3 \
--upload vmentry.sh:/vmentry.sh \
--upload entry.service:/etc/systemd/system/entry.service \
--run-command 'systemctl daemon-reload && systemctl enable entry.service' \
--run-command 'chmod +x /vmentry.sh' \
--run-command 'rm -rf /var/lib/apt/lists/*'
FROM debian:bookworm-slim
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
qemu-system-x86 qemu-utils qemu-kvm \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/user.qcow2 /vm/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]