From eced179b095a8c4128e104977cc09758089bb407 Mon Sep 17 00:00:00 2001 From: undercover-cactus Date: Wed, 22 Oct 2025 13:36:30 +0200 Subject: [PATCH] misc: simplify Dockerfile to speed up build (#216) This PR remove the `cargo chef` step used to build the docker image used in deployment. We noticed that `cargo chef` was adding more time to the build and that removing it was saving us 40min. Also in this PR, we removed the base image from parity which was really heavy and was filling the rest of the disk space. This broke the build. After some investigation it doesn't seem to add a lot to the build. It has been replace with the official rust image as a base to build our node. The image used to run the image has been replaced with `debian:trixie-slim`. In the end those changed **should not** break any of the current behavior and makes save a bit of CI time. --- .github/workflows/CI.yml | 2 +- contracts/src/DataHavenServiceManager.sol | 4 +- docker/datahaven-build.Dockerfile | 55 +++-------------------- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8f5b4925..d05c6cee 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -69,4 +69,4 @@ jobs: uses: ./.github/workflows/task-e2e.yml secrets: inherit with: - image-tag: ${{ needs.docker-build-ci.outputs.image-tag }} \ No newline at end of file + image-tag: ${{ needs.docker-build-ci.outputs.image-tag }} diff --git a/contracts/src/DataHavenServiceManager.sol b/contracts/src/DataHavenServiceManager.sol index 31445ca5..be5e695c 100644 --- a/contracts/src/DataHavenServiceManager.sol +++ b/contracts/src/DataHavenServiceManager.sol @@ -99,9 +99,7 @@ contract DataHavenServiceManager is ServiceManagerBase, IDataHavenServiceManager ) external payable onlyOwner { // Send the new validator set message to the Snowbridge Gateway bytes memory message = buildNewValidatorSetMessage(); - _snowbridgeGateway.v2_sendMessage{ - value: msg.value - }( + _snowbridgeGateway.v2_sendMessage{value: msg.value}( message, new bytes[](0), // No assets to send bytes(""), // No claimer diff --git a/docker/datahaven-build.Dockerfile b/docker/datahaven-build.Dockerfile index d93614ec..5fc55325 100644 --- a/docker/datahaven-build.Dockerfile +++ b/docker/datahaven-build.Dockerfile @@ -1,5 +1,5 @@ # --- Setup Build Environment --- -FROM docker.io/paritytech/ci-unified:bullseye-1.88.0 AS base +FROM rust:latest AS base ARG MOLD_VERSION=2.40.4 ARG PROTOC_VER=21.12 @@ -10,42 +10,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ xz-utils \ clang \ libpq-dev \ - && echo "Installing mold v${MOLD_VERSION}..." \ - && curl -Lo mold.tar.gz "https://github.com/rui314/mold/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-x86_64-linux.tar.gz" \ - && tar -xf mold.tar.gz --strip-components=1 -C /usr/local \ - && rm mold.tar.gz \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && echo "Installing protoc v${PROTOC_VER}..." \ && curl -Lo protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/protoc-${PROTOC_VER}-linux-x86_64.zip" \ && unzip -q protoc.zip -d /usr/local/ \ - && rm protoc.zip \ - && echo "Installing sccache v${SCCACHE_VERSION}..." \ - && curl -Lo sccache.tar.gz "https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" \ - && tar -xf sccache.tar.gz --strip-components=1 -C /usr/local/bin sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache \ - && rm sccache.tar.gz - -RUN cargo install cargo-chef --version 0.1.72 --locked - -ENV RUSTC_WRAPPER=sccache \ - SCCACHE_DIR=/usr/local/sccache \ - SCCACHE_CACHE_SIZE=25G \ - RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=/usr/local/bin/mold" - -# --- Prepare build plan with cargo-chef --- -FROM base AS planner -WORKDIR /datahaven -COPY . . -RUN cargo chef prepare --recipe-path recipe.json + && rm protoc.zip # --- Build dependencies using cargo-chef --- FROM base AS builder WORKDIR /datahaven -COPY --from=planner /datahaven/recipe.json recipe.json -RUN --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=/usr/local/cargo/git \ - cargo chef cook --recipe-path recipe.json --release -COPY . . + +COPY . /datahaven RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ if [ "$FAST_RUNTIME" = "TRUE" ]; then \ @@ -55,30 +31,11 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ fi # --- Create final lightweight runtime image --- -FROM docker.io/parity/base-bin:latest - -# Copy CA certificates and shared libraries from builder -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=builder \ - /lib/x86_64-linux-gnu/libpq.so.5 \ - /lib/x86_64-linux-gnu/libssl.so.3 \ - /lib/x86_64-linux-gnu/libcrypto.so.3 \ - /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 \ - /lib/x86_64-linux-gnu/libldap.so.2 \ - /lib/x86_64-linux-gnu/libz.so.1 \ - /lib/x86_64-linux-gnu/libzstd.so.1 \ - /lib/x86_64-linux-gnu/libkrb5.so.3 \ - /lib/x86_64-linux-gnu/libk5crypto.so.3 \ - /lib/x86_64-linux-gnu/libcom_err.so.2 \ - /lib/x86_64-linux-gnu/libkrb5support.so.0 \ - /lib/x86_64-linux-gnu/liblber.so.2 \ - /lib/x86_64-linux-gnu/libsasl2.so.2 \ - /lib/x86_64-linux-gnu/libkeyutils.so.1 \ - /lib/x86_64-linux-gnu/ - +FROM debian:trixie-slim COPY --from=builder /datahaven/target/release/datahaven-node /usr/local/bin USER root +RUN apt-get update && apt-get install -y gcc libc6-dev libpq-dev && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1001 -U -s /bin/sh -d /datahaven datahaven && \ mkdir -p /data /datahaven/.local/share && \ chown -R datahaven:datahaven /data && \