Skip to content

Commit 12140e4

Browse files
authored
Merge pull request #768 from opentensor/chore/devnet_merge_conflic
Fix docker, merge conflicts and publish docker images on tag
2 parents bdaf7d0 + bb932e2 commit 12140e4

File tree

5 files changed

+47
-65
lines changed

5 files changed

+47
-65
lines changed

.dockerignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.devcontainer
22
.github
33
.vscode
4-
!scripts/init.sh
5-
target
4+
target/
5+
.dockerignore
6+
Dockerfile

.github/workflows/docker.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,42 @@
11
name: Publish Docker Image
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
tags:
8-
- '*'
9-
pull_request:
10-
branches:
11-
- main
12-
workflow_dispatch:
4+
release:
5+
types: [published]
136

147
permissions:
15-
contents: read
16-
packages: write
17-
actions: read
18-
security-events: write
8+
contents: read
9+
packages: write
10+
actions: read
11+
security-events: write
1912

2013
jobs:
2114
publish:
2215
runs-on: SubtensorCI
23-
16+
2417
steps:
2518
- name: Checkout code
2619
uses: actions/checkout@v4
27-
20+
2821
- name: Set up QEMU
2922
uses: docker/setup-qemu-action@v2
30-
23+
3124
- name: Set up Docker Buildx
3225
uses: docker/setup-buildx-action@v2
33-
26+
3427
- name: Login to GHCR
3528
uses: docker/login-action@v2
3629
with:
3730
registry: ghcr.io
3831
username: ${{ github.actor }}
3932
password: ${{ secrets.GITHUB_TOKEN }}
40-
33+
4134
- name: Extract metadata (tags, labels) for Docker
4235
id: meta
4336
uses: docker/metadata-action@v4
4437
with:
4538
images: ghcr.io/${{ github.repository }}
46-
39+
4740
- name: Build and push Docker image
4841
uses: docker/build-push-action@v4
4942
with:
@@ -52,4 +45,4 @@ jobs:
5245
tags: |
5346
${{ steps.meta.outputs.tags }}
5447
ghcr.io/${{ github.repository }}:latest
55-
labels: ${{ steps.meta.outputs.labels }}
48+
labels: ${{ steps.meta.outputs.labels }}

Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,12 @@ codegen-units = 1
167167

168168
[features]
169169
default = []
170-
try-runtime = ["node-subtensor/try-runtime", "node-subtensor-runtime/try-runtime"]
171-
runtime-benchmarks = ["node-subtensor/runtime-benchmarks", "node-subtensor-runtime/runtime-benchmarks"]
170+
try-runtime = [
171+
"node-subtensor/try-runtime",
172+
"node-subtensor-runtime/try-runtime",
173+
]
174+
runtime-benchmarks = [
175+
"node-subtensor/runtime-benchmarks",
176+
"node-subtensor-runtime/runtime-benchmarks",
177+
]
178+
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

Dockerfile

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,44 @@
1-
21
ARG BASE_IMAGE=ubuntu:20.04
32

4-
FROM $BASE_IMAGE as builder
3+
FROM $BASE_IMAGE AS builder
54
SHELL ["/bin/bash", "-c"]
65

7-
# This is being set so that no interactive components are allowed when updating.
6+
# Set noninteractive mode for apt-get
87
ARG DEBIAN_FRONTEND=noninteractive
98

109
LABEL ai.opentensor.image.authors="[email protected]" \
1110
ai.opentensor.image.vendor="Opentensor Foundation" \
1211
ai.opentensor.image.title="opentensor/subtensor" \
1312
ai.opentensor.image.description="Opentensor Subtensor Blockchain" \
14-
ai.opentensor.image.revision="${VCS_REF}" \
15-
ai.opentensor.image.created="${BUILD_DATE}" \
1613
ai.opentensor.image.documentation="https://docs.bittensor.com"
1714

18-
# show backtraces
19-
ENV RUST_BACKTRACE 1
20-
21-
# Necessary libraries for Rust execution
15+
# Set up Rust environment
16+
ENV RUST_BACKTRACE=1
2217
RUN apt-get update && \
2318
apt-get install -y curl build-essential protobuf-compiler clang git && \
2419
rm -rf /var/lib/apt/lists/*
2520

26-
# Install cargo and Rust
2721
RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
2822
ENV PATH="/root/.cargo/bin:${PATH}"
23+
RUN rustup update stable
24+
RUN rustup target add wasm32-unknown-unknown --toolchain stable
2925

30-
RUN mkdir -p /subtensor && \
31-
mkdir /subtensor/scripts
32-
33-
# Scripts
34-
COPY ./scripts/init.sh /subtensor/scripts/
35-
36-
# Capture dependencies
37-
COPY Cargo.lock Cargo.toml /subtensor/
26+
# Copy entire repository
27+
COPY . /build
28+
WORKDIR /build
3829

39-
# Specs
40-
COPY ./snapshot.json /subtensor/snapshot.json
41-
COPY ./raw_spec_testfinney.json /subtensor/raw_spec_testfinney.json
42-
COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json
30+
# Build the project
31+
RUN cargo build -p node-subtensor --profile production --features="runtime-benchmarks metadata-hash" --locked
4332

44-
# Copy our sources
45-
COPY ./node /subtensor/node
46-
COPY ./pallets /subtensor/pallets
47-
COPY ./runtime /subtensor/runtime
48-
COPY ./support /subtensor/support
33+
# Verify the binary was produced
34+
RUN test -e /build/target/production/node-subtensor
4935

50-
# Copy our toolchain
51-
COPY rust-toolchain.toml /subtensor/
52-
RUN /subtensor/scripts/init.sh
53-
54-
# Cargo build
55-
WORKDIR /subtensor
56-
RUN cargo build --profile production --features runtime-benchmarks --locked
5736
EXPOSE 30333 9933 9944
5837

59-
6038
FROM $BASE_IMAGE AS subtensor
6139

62-
COPY --from=builder /subtensor/snapshot.json /
63-
COPY --from=builder /subtensor/raw_spec_testfinney.json /
64-
COPY --from=builder /subtensor/raw_spec_finney.json /
65-
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin
40+
# Copy all chainspec files
41+
COPY --from=builder /build/*.json /
42+
43+
# Copy final binary
44+
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin

node/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ runtime-benchmarks = [
9292
"frame-system/runtime-benchmarks",
9393
"sc-service/runtime-benchmarks",
9494
"sp-runtime/runtime-benchmarks",
95-
"pallet-commitments/runtime-benchmarks"
95+
"pallet-commitments/runtime-benchmarks",
9696
]
9797
pow-faucet = []
9898

@@ -103,5 +103,7 @@ try-runtime = [
103103
"frame-system/try-runtime",
104104
"pallet-transaction-payment/try-runtime",
105105
"sp-runtime/try-runtime",
106-
"pallet-commitments/try-runtime"
106+
"pallet-commitments/try-runtime",
107107
]
108+
109+
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

0 commit comments

Comments
 (0)