Skip to content

Commit bc15020

Browse files
committed
completely revamp Dockerfile to be better :O
1 parent a0a4652 commit bc15020

File tree

2 files changed

+20
-36
lines changed

2 files changed

+20
-36
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

Dockerfile

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
ARG BASE_IMAGE=ubuntu:20.04
32

43
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]" \
@@ -15,51 +14,35 @@ LABEL ai.opentensor.image.authors="[email protected]" \
1514
ai.opentensor.image.created="${BUILD_DATE}" \
1615
ai.opentensor.image.documentation="https://docs.bittensor.com"
1716

18-
# show backtraces
17+
# Set up Rust environment
1918
ENV RUST_BACKTRACE 1
20-
21-
# Necessary libraries for Rust execution
2219
RUN apt-get update && \
2320
apt-get install -y curl build-essential protobuf-compiler clang git && \
2421
rm -rf /var/lib/apt/lists/*
2522

26-
# Install cargo and Rust
2723
RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
2824
ENV PATH="/root/.cargo/bin:${PATH}"
2925

30-
RUN mkdir -p /subtensor && \
31-
mkdir /subtensor/scripts
32-
33-
# Scripts
34-
COPY ./scripts/init.sh /subtensor/scripts/
26+
RUN rustup update nightly
27+
RUN rustup update stable
28+
RUN rustup target add wasm32-unknown-unknown --toolchain nightly
3529

36-
# Capture dependencies
37-
COPY Cargo.lock Cargo.toml /subtensor/
30+
# Copy entire repository
31+
COPY . /build
32+
WORKDIR /build
3833

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
34+
# Build the project
35+
RUN cargo build -p node-subtensor --profile production --features runtime-benchmarks --locked
4336

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

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
5740
EXPOSE 30333 9933 9944
5841

59-
6042
FROM $BASE_IMAGE AS subtensor
6143

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
44+
# Copy all chainspec files
45+
COPY --from=builder /build/*.json /
46+
47+
# Copy final binary
48+
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin

0 commit comments

Comments
 (0)