From 6cd957b48e225ef9ad5bbe0dc1e0dd821d917159 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Fri, 27 Sep 2024 11:05:55 -0300 Subject: [PATCH] feat: use apt --snapshot for reproducibility --- cpp-low-level/Dockerfile | 36 ++++++++++----- cpp/3rdparty/Makefile | 4 +- cpp/Dockerfile | 36 ++++++++++----- go/Dockerfile | 59 ++++++++++++++++++------- lua/Dockerfile | 38 +++++++++++----- ruby/Dockerfile | 33 +++++++++++--- rust/Dockerfile | 95 ++++++++++++++++++++++++++-------------- 7 files changed, 215 insertions(+), 86 deletions(-) diff --git a/cpp-low-level/Dockerfile b/cpp-low-level/Dockerfile index 1b628fa..c13c862 100644 --- a/cpp-low-level/Dockerfile +++ b/cpp-low-level/Dockerfile @@ -1,21 +1,35 @@ # syntax=docker.io/docker/dockerfile:1 -FROM --platform=linux/riscv64 ubuntu:24.04 AS base -RUN apt-get update +# This enforces that the packages downloaded from the repositories are the same +# for the defined date, no matter when the image is built. +ARG UBUNTU_TAG=noble-20240827.1 +ARG APT_UPDATE_SNAPSHOT=20240827T030400Z +################################################################################ +# riscv64 base stage +FROM --platform=linux/riscv64 ubuntu:${UBUNTU_TAG} AS base + +ARG APT_UPDATE_SNAPSHOT +ARG DEBIAN_FRONTEND=noninteractive +RUN <&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ - esac; \ - url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \ - wget "$url"; \ - echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ - chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ - rm rustup-init; \ - chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ - rustup --version; \ - cargo --version; \ - rustc --version; +RUN <&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; +esac +url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init" +curl -fsSL -O "$url" +echo "${rustupSha256} *rustup-init" | sha256sum -c - +chmod +x rustup-init +./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch} +rm rustup-init +chmod -R a+w $RUSTUP_HOME $CARGO_HOME +rustup --version +cargo --version +rustc --version +EOF RUN rustup target add riscv64gc-unknown-linux-gnu @@ -43,11 +76,9 @@ WORKDIR /opt/cartesi/dapp COPY . . RUN cargo build --release -FROM --platform=linux/riscv64 ubuntu:24.04 AS base - -RUN apt-get update - -FROM base +################################################################################ +# runtime stage: produces final image that will be executed +FROM base-riscv64 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 / @@ -61,7 +92,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN <