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 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 49f20116f0..71385db116 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,12 +1,8 @@ -name: Openmina Docker Build +name: OpenMina Docker Build on: workflow_dispatch: {} push: - branches: [ main, develop ] - tags: [ "*" ] paths-ignore: - # - ".github/**" - - ".drone.yml" - "helm/**" - "*.md" - "docs/**" @@ -41,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 }} @@ -48,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: @@ -56,6 +53,15 @@ 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=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 @@ -74,6 +80,7 @@ jobs: merge-openmina-node-image: runs-on: ubuntu-latest + 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: @@ -140,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 }} @@ -147,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: @@ -157,6 +165,17 @@ 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=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 @@ -178,11 +197,8 @@ jobs: matrix: configuration: - build_configuration: production - # - build_configuration: compose - # tag_suffix: "" - # - build_configuration: staging - # tag_suffix: "" runs-on: ubuntu-latest + 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: @@ -201,9 +217,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 diff --git a/Dockerfile b/Dockerfile index 984165b045..d91ce80feb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,24 +3,30 @@ 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 \ - --mount=type=cache,target=/openmina/target,id=rust-target \ - cargo build --release --package=cli --bin=openmina && \ - cp -r /openmina/target/release /openmina/release-bin/ - -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/ + +RUN make build-release && \ + mkdir -p /openmina/release-bin && \ + cp /openmina/target/release/openmina /openmina/release-bin/openmina + +RUN make build-testing && \ + mkdir -p /openmina/testing-release-bin && \ + cp /openmina/target/release/openmina-node-testing \ + /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 diff --git a/Makefile b/Makefile index 30b23cbb38..afffbe2609 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,11 @@ 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-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 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"