diff --git a/Dockerfile b/Dockerfile index 1a6aac6..5e8d7e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ARG APT_UPDATE_SNAPSHOT=${NOBLE_DATE}T030400Z ################################################################################ # cross base stage -FROM ubuntu:noble-${NOBLE_DATE} AS base-build-stage +FROM --platform=$BUILDPLATFORM ubuntu:noble-${NOBLE_DATE} AS base-build-stage ARG APT_UPDATE_SNAPSHOT ARG DEBIAN_FRONTEND=noninteractive @@ -20,7 +20,7 @@ EOF ################################################################################ # riscv64 base stage -FROM --platform=linux/riscv64 ubuntu:noble-${NOBLE_DATE} AS base-target-stage +FROM --platform=$TARGETPLATFORM ubuntu:noble-${NOBLE_DATE} AS base-target-stage ARG APT_UPDATE_SNAPSHOT ARG DEBIAN_FRONTEND=noninteractive @@ -31,6 +31,7 @@ apt install -y --no-install-recommends ca-certificates apt update --snapshot=${APT_UPDATE_SNAPSHOT} EOF + ################################################################################ # cross build stage FROM base-build-stage AS build-stage @@ -110,43 +111,64 @@ make LDFLAGS=-static EOF ################################################################################ -# runtime stage: produces final image that will be executed -FROM base-target-stage +# generate chiselled rootfs +FROM base-build-stage AS chiselled-rootfs +WORKDIR /rootfs -LABEL io.cartesi.sdk_version=0.9.0 -LABEL io.cartesi.rollups.ram_size=128Mi -LABEL io.cartesi.rollups.data_size=128Mb +ARG MACHINE_EMULATOR_TOOLS_VERSION=0.14.1 +ADD https://github.com/cartesi/machine-emulator-tools/releases/download/v${MACHINE_EMULATOR_TOOLS_VERSION}/machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb / +RUN dpkg -x /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb /rootfs + +# Get chisel binary +ARG CHISEL_VERSION=0.10.0 +ADD "https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_riscv64.tar.gz" chisel.tar.gz +RUN tar -xvf chisel.tar.gz -C /usr/bin/ + +ADD "https://github.com/cartesi/chisel-releases.git#24.04/bug-buster-dependencies" /chisel-24.04 +RUN chisel cut \ + --release /chisel-24.04 \ + --root /rootfs \ + --arch=riscv64 \ + # base rootfs dependencies + base-files_base \ + base-files_release-info \ + base-passwd_data \ + # machine-emulator-tools dependencies + libgcc-s1_libs \ + busybox-static_bins \ + # bug-buster + libasan6_libs \ + libasan8_libs \ + xz-utils_bins -ARG DEBIAN_FRONTEND=noninteractive RUN < /sys/fs/cgroup/cgroup.subtree_control fi +# execute scripts in cartesi-init.d +[ -d /etc/cartesi-init.d ] && for f in /etc/cartesi-init.d/*; do [ -x $f ] && . $f; done + # execute init from device tree when available [ -f /proc/device-tree/cartesi-machine/init ] && . /proc/device-tree/cartesi-machine/init