From bb932e24c4d5f8f465b614f59d863a821ead3d1a Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Wed, 28 Aug 2024 22:30:20 +0400 Subject: [PATCH] chore: add metadatahash, build images only on publish tags --- .github/workflows/docker.yml | 33 +++++++++++++-------------------- Cargo.toml | 11 +++++++++-- Dockerfile | 12 ++++-------- node/Cargo.toml | 6 ++++-- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 19bda7463..72e3f1b12 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,49 +1,42 @@ name: Publish Docker Image on: - push: - branches: - - main - tags: - - '*' - pull_request: - branches: - - main - workflow_dispatch: + release: + types: [published] permissions: - contents: read - packages: write - actions: read - security-events: write + contents: read + packages: write + actions: read + security-events: write jobs: publish: runs-on: SubtensorCI - + steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - + - name: Login to GHCR uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4 with: images: ghcr.io/${{ github.repository }} - + - name: Build and push Docker image uses: docker/build-push-action@v4 with: @@ -52,4 +45,4 @@ jobs: tags: | ${{ steps.meta.outputs.tags }} ghcr.io/${{ github.repository }}:latest - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/Cargo.toml b/Cargo.toml index e3c2814ff..f9a7968b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,5 +167,12 @@ codegen-units = 1 [features] default = [] -try-runtime = ["node-subtensor/try-runtime", "node-subtensor-runtime/try-runtime"] -runtime-benchmarks = ["node-subtensor/runtime-benchmarks", "node-subtensor-runtime/runtime-benchmarks"] +try-runtime = [ + "node-subtensor/try-runtime", + "node-subtensor-runtime/try-runtime", +] +runtime-benchmarks = [ + "node-subtensor/runtime-benchmarks", + "node-subtensor-runtime/runtime-benchmarks", +] +metadata-hash = ["node-subtensor-runtime/metadata-hash"] diff --git a/Dockerfile b/Dockerfile index e4bc5e9ee..2dd2e2370 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG BASE_IMAGE=ubuntu:20.04 -FROM $BASE_IMAGE as builder +FROM $BASE_IMAGE AS builder SHELL ["/bin/bash", "-c"] # Set noninteractive mode for apt-get @@ -10,29 +10,25 @@ LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ ai.opentensor.image.vendor="Opentensor Foundation" \ ai.opentensor.image.title="opentensor/subtensor" \ ai.opentensor.image.description="Opentensor Subtensor Blockchain" \ - ai.opentensor.image.revision="${VCS_REF}" \ - ai.opentensor.image.created="${BUILD_DATE}" \ ai.opentensor.image.documentation="https://docs.bittensor.com" # Set up Rust environment -ENV RUST_BACKTRACE 1 +ENV RUST_BACKTRACE=1 RUN apt-get update && \ apt-get install -y curl build-essential protobuf-compiler clang git && \ rm -rf /var/lib/apt/lists/* RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" - -RUN rustup update nightly RUN rustup update stable -RUN rustup target add wasm32-unknown-unknown --toolchain nightly +RUN rustup target add wasm32-unknown-unknown --toolchain stable # Copy entire repository COPY . /build WORKDIR /build # Build the project -RUN cargo build -p node-subtensor --profile production --features runtime-benchmarks --locked +RUN cargo build -p node-subtensor --profile production --features="runtime-benchmarks metadata-hash" --locked # Verify the binary was produced RUN test -e /build/target/production/node-subtensor diff --git a/node/Cargo.toml b/node/Cargo.toml index 0e1a418a3..3c5c91b92 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -92,7 +92,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-commitments/runtime-benchmarks" + "pallet-commitments/runtime-benchmarks", ] pow-faucet = [] @@ -103,5 +103,7 @@ try-runtime = [ "frame-system/try-runtime", "pallet-transaction-payment/try-runtime", "sp-runtime/try-runtime", - "pallet-commitments/try-runtime" + "pallet-commitments/try-runtime", ] + +metadata-hash = ["node-subtensor-runtime/metadata-hash"]