diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33519d2ce..67bb7a611 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,8 +126,58 @@ jobs: - name: Run tests run: cargo test + build-ci-base : + runs-on: ubuntu-22.04 + outputs: + output: ${{ steps.docker_build.outputs.image_tag }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: | + name=ghcr.io/cartesi/rollups-node-ci-base + tags: | + type=semver,pattern={{version}} + type=ref,event=branch + type=ref,event=pr + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: depot/setup-action@v1 + - name: Build and push docker image + id: docker_build + uses: depot/bake-action@v1 + with: + files: | + ./docker-bake.hcl + ${{ steps.docker_meta.outputs.bake-file }} + ./docker-bake.platforms.hcl + targets: rollups-node-ci-base + push: true + project: ${{ vars.DEPOT_PROJECT }} + workdir: build + + - name: Export Image Tag + id : export_tag + run : echo "image_tag=${{steps.docker_meta.outputs.tag}}" >> "$GITHUB_OUTPUT" + + test-go: runs-on: ubuntu-22.04 + container: + image: ghcr.io/cartesi/rollups-node-ci-base:${{needs.build-ci-base.outputs.output}} + needs: + - build-ci-base steps: - uses: actions/checkout@v4 with: diff --git a/build/Dockerfile b/build/Dockerfile index 0c33b1b31..6a4761237 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -331,3 +331,65 @@ USER cartesi # Set the Go supervisor as the command. CMD [ "cartesi-rollups-node" ] + + + +# STAGE: rollups-ci-base +# +# This stage prepares the base CI image +FROM rust:${RUST_VERSION}-bookworm as rollups-node-ci-base + +ARG RUST_VERSION +ARG GO_VERSION +ARG MACHINE_EMULATOR_VERSION + +# Install git +RUN apt update && apt install -y git-all + +# Install docker +RUN < /dev/null + apt-get update + apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +EOF + + +# Install Protoc +RUN su - && apt update && apt install -y protobuf-compiler libprotobuf-dev + +# Install Cartesi Machine +RUN <