# syntax=docker/dockerfile:1.7-labs ARG BASE_STAGE=dev # Built from docker/Dockerfile.microvm; CI checks this matches hack/microvm-image-tag.sh. ARG MICROVM_IMAGE=public.ecr.aws/n4e0e1y0/beta9-microvm:d22ea0c29c1c FROM golang:1.25-bookworm AS golang RUN apt-get update && apt-get install -y curl git FROM debian:bookworm as dropbear ENV DROPBEAR_VERSION=2025.88 ENV DROPBEAR_SHA256=783f50ea27b17c16da89578fafdb6decfa44bb8f6590e5698a4e4d3672dc53d4 RUN apt update && apt install curl bzip2 zlib1g-dev make gcc -y RUN mkdir /dropbear && \ curl -fsSL https://dropbear.nl/mirror/releases/dropbear-${DROPBEAR_VERSION}.tar.bz2 -o /dropbear/dropbear.tar.bz2 && \ echo "${DROPBEAR_SHA256} /dropbear/dropbear.tar.bz2" | sha256sum -c - RUN cd /dropbear && tar -xvf dropbear.tar.bz2 && cd dropbear-${DROPBEAR_VERSION} && ./configure --enable-static --enable-pam=no CPPFLAGS="-DDISABLE_PAM" LDFLAGS="-static" && make PROGRAMS="dropbear" && mv dropbear /usr/local/bin/dropbear # runc # ======================== # FIXME: once we upgrade to 1.23, we can just use "FROM golang" FROM golang:1.23-bookworm AS runc WORKDIR /workspace COPY docker/patches/runc/runc-criu-production-log-level.patch /tmp/runc-criu-production-log-level.patch COPY docker/patches/runc/runc-criu-cpu-compatibility.patch /tmp/runc-criu-cpu-compatibility.patch COPY docker/patches/buildah/runtime-helper-reaping.patch /tmp/buildah-runtime-helper-reaping.patch RUN apt-get update && apt-get install -y \ make \ btrfs-progs \ git \ go-md2man \ iptables \ libapparmor-dev \ libglib2.0-dev \ libgpgme11-dev \ libseccomp-dev \ libselinux1-dev \ libbtrfs-dev \ pkg-config RUN < /tmp/runsc.sha512 else curl -fsSL "$RUNSC_SHA512_URL" -o /tmp/runsc.sha512 fi # Verify checksum (cd to /tmp where both files are) cd /tmp && sha512sum -c runsc.sha512 # Move to final location and make executable mv /tmp/runsc /usr/local/bin/runsc chmod +x /usr/local/bin/runsc # Verify installation and check available platforms /usr/local/bin/runsc --version /usr/local/bin/runsc help 2>&1 | grep -i platform || { echo "Platform options unavailable" >&2; exit 1; } EOT # qemu-storage-daemon # ======================== # jammy's qemu-utils (6.2) predates qemu-storage-daemon being packaged, so # build the tools from source against the same ubuntu:22.04 userland as the # final image. Tools-only build: no system emulation, no user emulation. FROM ubuntu:22.04 AS qemu ARG QEMU_VERSION=8.2.10 RUN apt-get update && apt-get install -y \ curl xz-utils python3 python3-pip pkg-config ninja-build \ libglib2.0-dev zlib1g-dev flex bison && \ pip3 install meson==1.5.2 RUN </usr/local/bin/nvidia-container-cli <<'EOF' #!/usr/bin/env bash set -euo pipefail real_cli="${NVIDIA_CONTAINER_CLI_REAL:-/usr/bin/nvidia-container-cli.real}" has_no_persistenced=0 for arg in "$@"; do if [ "$arg" = "--no-persistenced" ]; then has_no_persistenced=1 break fi done if [ "$has_no_persistenced" -eq 0 ]; then args=() inserted=0 for arg in "$@"; do args+=("$arg") if [ "$arg" = "configure" ]; then args+=("--no-persistenced") inserted=1 fi done if [ "$inserted" -eq 1 ]; then exec "$real_cli" "${args[@]}" fi fi exec "$real_cli" "$@" EOF chmod +x /usr/local/bin/nvidia-container-cli ln -s /usr/local/bin/nvidia-container-cli /usr/bin/nvidia-container-cli EOT RUN apt-get update && apt-get install -y fuse3 libfuse2 libfuse3-dev libfuse-dev bash-completion # buildah run --network=private builds its bridge from the CNI plugins. RUN apt-get install -y libbtrfs-dev libgpgme11-dev containernetworking-plugins RUN mkdir -p /etc/containers/registries.conf.d RUN curl -L https://raw.githubusercontent.com/containers/shortnames/refs/heads/main/shortnames.conf \ -o /etc/containers/registries.conf.d/shortnames.conf RUN echo 'unqualified-search-registries = ["docker.io"]' > /etc/containers/registries.conf ARG CRIU_COMMIT=b47c692bb3a73ae45ee1c4ab215a8f6869d40efd COPY docker/patches/criu/criu-network-remap.patch /tmp/criu-network-remap.patch COPY docker/patches/criu/criu-skip-non-cuda-resume.patch /tmp/criu-skip-non-cuda-resume.patch COPY docker/patches/criu/criu-skip-fresh-zero-pages.patch /tmp/criu-skip-fresh-zero-pages.patch COPY docker/patches/criu/criu-ignore-erms-compat.patch /tmp/criu-ignore-erms-compat.patch RUN < /etc/criu/runc.conf # Hard-disable any AMDGPU plugin that might exist from base layers or future package updates RUN mkdir -p /usr/lib/criu/plugins.disabled && \ if [ -e /usr/lib/criu/amdgpu_plugin.so ]; then \ mv /usr/lib/criu/amdgpu_plugin.so /usr/lib/criu/plugins.disabled/ ; \ fi && \ true ENV MOUNT_S3_URL_ARM64="https://s3.amazonaws.com/mountpoint-s3-release/1.8.0/arm64/mount-s3-1.8.0-arm64.tar.gz" ENV MOUNT_S3_URL_AMD64="https://s3.amazonaws.com/mountpoint-s3-release/1.8.0/x86_64/mount-s3-1.8.0-x86_64.tar.gz" RUN MOUNT_S3_URL=$(if [ "$TARGETARCH" = "arm64" ]; then echo $MOUNT_S3_URL_ARM64; else echo $MOUNT_S3_URL_AMD64; fi) && \ curl -O $MOUNT_S3_URL && \ TARBALL=$(basename $MOUNT_S3_URL) && \ mkdir mount-s3 && \ tar -xzf $TARBALL -C mount-s3 && \ mv mount-s3/bin/mount-s3 /usr/local/bin/ms3 && chmod +x /usr/local/bin/ms3 && \ rm -rf mount-s3 $TARBALL ARG CUDA_CHECKPOINT_COMMIT=00d5cce84c628088d6caa203fc4af40c1538b6f7 ARG CUDA_CHECKPOINT_SHA256=707fa7f54136824d6c1d6dd724b9b1717610f831033c00d06da474de363a06db RUN < /workspace/etc/resolv.conf RUN echo '127.0.0.1 localhost' > /workspace/etc/hosts RUN echo 'hosts: files dns' > /workspace/etc/nsswitch.conf COPY ./bin/beta9-cli /usr/local/bin/beta9 RUN chmod +x /usr/local/bin/beta9 COPY ./bin/snapshot /usr/local/bin/snapshot RUN chmod +x /usr/local/bin/snapshot COPY --from=runc /usr/local/sbin/runc /usr/local/sbin/runc COPY --from=runc /usr/local/bin/buildah /usr/local/bin/buildah COPY --from=runc /usr/local/bin/skopeo /usr/local/bin/skopeo COPY --from=runc /workspace/skopeo/default-policy.json /etc/containers/policy.json COPY --from=gvisor /usr/local/bin/runsc /usr/local/bin/runsc COPY --from=qemu /usr/local/bin/qemu-storage-daemon /usr/bin/qemu-storage-daemon COPY --from=nvidia-container-toolkit /workspace/nvidia-container-runtime* /usr/bin/ # LD_PRELOAD libraries COPY ./bin/volume_cache_x86.so /usr/local/lib/volume_cache_x86.so COPY ./bin/volume_cache_arm.so /usr/local/lib/volume_cache_arm.so RUN if [ "$(uname -m)" = "x86_64" ]; then \ cp /usr/local/lib/volume_cache_x86.so /usr/local/lib/volume_cache.so; \ else \ cp /usr/local/lib/volume_cache_arm.so /usr/local/lib/volume_cache.so; \ fi COPY --from=worker /usr/local/bin/worker /usr/local/bin/worker COPY --from=worker /usr/local/bin/worker-debug /usr/local/bin/worker-debug COPY --from=worker /usr/local/bin/agent /usr/local/bin/agent COPY --from=worker /usr/local/bin/agent /usr/local/bin/beam-agent COPY --from=worker /usr/local/bin/beam-vminit /usr/local/bin/beam-vminit COPY --from=microvm /microvm/bin/ /usr/local/bin/ COPY --from=microvm /microvm/share/ /usr/local/share/beam/microvm/ COPY ./sdk/src/beta9 /workspace/sdk COPY --from=uv /root/.local/bin/uv /usr/local/bin/uv COPY --from=dropbear /usr/local/bin/dropbear /usr/local/bin/dropbear RUN mkdir -p /etc/criu RUN touch /etc/criu/default.conf # add the following options to the default.conf file on new lines RUN echo "verbosity 4" >> /etc/criu/default.conf RUN echo "display-stats" >> /etc/criu/default.conf RUN echo "timeout 60" >> /etc/criu/default.conf # Create gVisor runtime directories RUN mkdir -p /run/gvisor ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics,ngx,video ENV _BUILDAH_STARTED_IN_USERNS="" \ BUILDAH_ISOLATION=oci # Configure buildah/containers for better concurrency # image_parallel_copies controls how many layers can be pushed/pulled simultaneously RUN mkdir -p /etc/containers && \ echo '[engine]' > /etc/containers/containers.conf && \ echo 'image_parallel_copies = 8' >> /etc/containers/containers.conf