From 5151a24d379308158055c5d4363fd6a6454f4c87 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 21:40:21 +0200 Subject: [PATCH 01/12] Rename rust-toolchain into rust-toolchain.toml --- rust-toolchain | 1 - rust-toolchain.toml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 40671b9085..0000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.84 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..9db33c0e40 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.84" From 60df9ed3429fbf5c114ad02a0e9c6b2402611d4e Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 21:44:54 +0200 Subject: [PATCH 02/12] Dockerfile/openmina: use Rust version from rust-toolchain.toml --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 984165b045..c769f85cfd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,15 @@ FROM rust:bullseye AS build RUN apt-get update && \ apt-get install -y --no-install-recommends protobuf-compiler && \ apt-get clean -RUN rustup default 1.84 && rustup component add rustfmt WORKDIR /openmina + +COPY rust-toolchain.toml . + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \ + sed 's/channel = "\(.*\)"/\1/') && \ + rustup default "$RUST_VERSION" && \ + rustup component add rustfmt COPY . . # Build with cache mount RUN --mount=type=cache,target=/usr/local/cargo/registry \ From bb7e8e9a437ae76cff0fdc1e9c0c7baceba6a86c Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 21:45:25 +0200 Subject: [PATCH 03/12] Dockerfile/openmina: simple spaces --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c769f85cfd..4199ba1dcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM rust:bullseye AS build RUN apt-get update && \ apt-get install -y --no-install-recommends protobuf-compiler && \ apt-get clean + WORKDIR /openmina COPY rust-toolchain.toml . @@ -12,6 +13,7 @@ RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \ sed 's/channel = "\(.*\)"/\1/') && \ rustup default "$RUST_VERSION" && \ rustup component add rustfmt + COPY . . # Build with cache mount RUN --mount=type=cache,target=/usr/local/cargo/registry \ From 509f72792ef2cdd76af30b7c2ab2c3098bda7885 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:17:22 +0200 Subject: [PATCH 04/12] CI/docker: rename workflow title --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 49f20116f0..1f41c20ca0 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,4 +1,4 @@ -name: Openmina Docker Build +name: OpenMina Docker Build on: workflow_dispatch: {} push: From ee969b011acedbcb81176525bddeea32c16d4413 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:17:39 +0200 Subject: [PATCH 05/12] CI/docker: ignore old paths --- .github/workflows/docker.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 1f41c20ca0..8120c627c1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -5,8 +5,6 @@ on: branches: [ main, develop ] tags: [ "*" ] paths-ignore: - # - ".github/**" - - ".drone.yml" - "helm/**" - "*.md" - "docs/**" From 0d0108d68b1f18923b757cc8c3b5828462fa95f8 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:17:59 +0200 Subject: [PATCH 06/12] Makefile: specify package where openmina binary lives --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 30b23cbb38..f2a9608637 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ build-ledger: download-circuits ## Build the ledger binary and library, requires .PHONY: build-release build-release: ## Build the project in release mode - cargo build --release --bin openmina + cargo build --release --package=cli --bin openmina .PHONY: build-tests-webrtc build-tests-webrtc: ## Build tests for WebRTC From fecacc3331228eaa6754c3512d9957db24feb68a Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:18:18 +0200 Subject: [PATCH 07/12] Makefile: add target to build openmina-node-testing --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f2a9608637..afffbe2609 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ build-ledger: download-circuits ## Build the ledger binary and library, requires build-release: ## Build the project in release mode cargo build --release --package=cli --bin openmina +.PHONY: build-testing +build-testing: ## Build the testing binary with scenario generators + cargo build --release --features scenario-generators --bin openmina-node-testing + .PHONY: build-tests-webrtc build-tests-webrtc: ## Build tests for WebRTC @mkdir -p target/release/tests From 2db9d82db4d49385889bcbc7cb92d85d2686f995 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:23:57 +0200 Subject: [PATCH 08/12] Dockerfile/openmina: use Makefile targets --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4199ba1dcc..ef36498e29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,17 +15,18 @@ RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \ rustup component add rustfmt COPY . . + # Build with cache mount RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/openmina/target,id=rust-target \ - cargo build --release --package=cli --bin=openmina && \ - cp -r /openmina/target/release /openmina/release-bin/ + make build-release && \ + cp /openmina/target/release/openmina /openmina/release-bin/openmina RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/openmina/target,id=rust-target \ - cargo build --release --features scenario-generators \ - --bin openmina-node-testing && \ - cp -r /openmina/target/release /openmina/testing-release-bin/ + make build-testing && \ + cp /openmina/target/release/openmina-node-testing \ + /openmina/testing-release-bin/ # necessary for proof generation when running a block producer. RUN git clone --depth 1 \ From d6b9070b0f2b8dfb47883e5bade2c9cbc3f475e5 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:24:13 +0200 Subject: [PATCH 09/12] Docker: add more files to ignore while copying into docker image --- .dockerignore | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.dockerignore b/.dockerignore index fec7622b6c..4f7b582539 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,3 +14,20 @@ tools/heartbeats-processor/credentials/ tools/heartbeats-processor/*.db # Ensure .sqlx files are included !tools/heartbeats-processor/.sqlx/ + +# Will be copied on demand in the Docker image, if necessary +circuit-blobs + +# GH workflows +.github +.idea + +# Infrastructure +helm + +# Output of build-wasm +pkg + +# Outputs of build-tests-webrtc +cargo-build-test.json +tests.tsv \ No newline at end of file From 0a7ead96ce65bcca9b905bcb253a875857d235f4 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:33:58 +0200 Subject: [PATCH 10/12] Dockerfile/openmina: remove mount caches, failing on user machine --- Dockerfile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef36498e29..d91ce80feb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,21 +16,17 @@ RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \ COPY . . -# Build with cache mount -RUN --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=/openmina/target,id=rust-target \ - make build-release && \ +RUN make build-release && \ + mkdir -p /openmina/release-bin && \ cp /openmina/target/release/openmina /openmina/release-bin/openmina -RUN --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=/openmina/target,id=rust-target \ - make build-testing && \ +RUN make build-testing && \ + mkdir -p /openmina/testing-release-bin && \ cp /openmina/target/release/openmina-node-testing \ - /openmina/testing-release-bin/ + /openmina/testing-release-bin/openmina-node-testing # necessary for proof generation when running a block producer. -RUN git clone --depth 1 \ - https://github.com/openmina/circuit-blobs.git && \ +RUN make download-circuits && \ rm -rf circuit-blobs/berkeley_rc1 circuit-blobs/*/tests FROM debian:bullseye From c98971f65ec179b9baea98fdbfbcd1db068fa18c Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:45:15 +0200 Subject: [PATCH 11/12] CI/Docker: push only if main, develop or tag, but always build --- .github/workflows/docker.yaml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 8120c627c1..61f072b963 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -2,8 +2,6 @@ name: OpenMina Docker Build on: workflow_dispatch: {} push: - branches: [ main, develop ] - tags: [ "*" ] paths-ignore: - "helm/**" - "*.md" @@ -54,7 +52,12 @@ jobs: platforms: ${{ matrix.arch.platform }} cache-from: type=gha cache-to: type=gha,mode=max - outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=true + # :warning: + # Push only if: + # - main + # - develop + # - a tag + outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }} - name: Export digest run: | @@ -72,6 +75,12 @@ jobs: merge-openmina-node-image: runs-on: ubuntu-latest + # :warning: + # Only if: + # - main + # - develop + # - a tag + if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') needs: - build-openmina-node-image steps: @@ -155,7 +164,11 @@ jobs: BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }} cache-from: type=gha cache-to: type=gha,mode=max - outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=true + # Only if: + # - main + # - develop + # - a tag + outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }} - name: Export digest run: | @@ -176,11 +189,8 @@ jobs: matrix: configuration: - build_configuration: production - # - build_configuration: compose - # tag_suffix: "" - # - build_configuration: staging - # tag_suffix: "" runs-on: ubuntu-latest + if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') needs: - build-openmina-frontend-image steps: @@ -199,9 +209,6 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_FRONTEND_IMAGE }} - # flavor: | - # suffix=${{ matrix.configuration.tag_suffix }},onlatest=true - # generate Docker tags based on the following events/attributes tags: | type=ref,event=branch type=sha,format=short From 191ed99eae2f4aaba3255a15254774ce86bdcd41 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 16 Jul 2025 22:50:52 +0200 Subject: [PATCH 12/12] CI/Docker: split in two steps the build & publish --- .github/workflows/docker.yaml | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 61f072b963..71385db116 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -37,6 +37,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} @@ -44,7 +45,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest + - name: Build Docker image id: build uses: docker/build-push-action@v6 with: @@ -52,12 +53,16 @@ jobs: platforms: ${{ matrix.arch.platform }} cache-from: type=gha cache-to: type=gha,mode=max - # :warning: - # Push only if: - # - main - # - develop - # - a tag - outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }} + outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=false + + - name: Push Docker image by digest + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.arch.platform }} + cache-from: type=gha + outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | @@ -75,12 +80,7 @@ jobs: merge-openmina-node-image: runs-on: ubuntu-latest - # :warning: - # Only if: - # - main - # - develop - # - a tag - if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} needs: - build-openmina-node-image steps: @@ -147,6 +147,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} @@ -154,7 +155,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest + - name: Build Docker image id: build uses: docker/build-push-action@v6 with: @@ -164,11 +165,18 @@ jobs: BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }} cache-from: type=gha cache-to: type=gha,mode=max - # Only if: - # - main - # - develop - # - a tag - outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }} + outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=false + + - name: Push Docker image by digest + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} + uses: docker/build-push-action@v6 + with: + context: ./frontend + platforms: ${{ matrix.arch.platform }} + build-args: | + BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }} + cache-from: type=gha + outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | @@ -190,7 +198,7 @@ jobs: configuration: - build_configuration: production runs-on: ubuntu-latest - if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') + if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }} needs: - build-openmina-frontend-image steps: