|
1 | | -ARG BASE_IMAGE=ubuntu:latest |
2 | | - |
3 | | -FROM $BASE_IMAGE AS builder |
4 | | -SHELL ["/bin/bash", "-c"] |
5 | | - |
6 | | -# Set noninteractive mode for apt-get |
7 | | -ARG DEBIAN_FRONTEND=noninteractive |
| 1 | +ARG BASE_IMAGE=rust:1.83 |
| 2 | +FROM $BASE_IMAGE AS base_builder |
8 | 3 |
|
9 | 4 | LABEL ai.opentensor.image.authors= "[email protected]" \ |
10 | 5 | ai.opentensor.image.vendor="Opentensor Foundation" \ |
11 | 6 | ai.opentensor.image.title="opentensor/subtensor" \ |
12 | 7 | ai.opentensor.image.description="Opentensor Subtensor Blockchain" \ |
13 | 8 | ai.opentensor.image.documentation="https://docs.bittensor.com" |
14 | 9 |
|
| 10 | +RUN rustup update stable |
| 11 | +RUN rustup target add wasm32-unknown-unknown --toolchain stable |
| 12 | + |
| 13 | + |
15 | 14 | # Set up Rust environment |
16 | 15 | ENV RUST_BACKTRACE=1 |
17 | | -RUN apt-get update && \ |
18 | | - apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev && \ |
19 | | - rm -rf /var/lib/apt/lists/* |
| 16 | +RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev |
| 17 | +RUN rm -rf /var/lib/apt/lists/* |
20 | 18 |
|
21 | 19 | # Copy entire repository |
22 | 20 | COPY . /build |
23 | 21 | WORKDIR /build |
24 | 22 |
|
25 | | -# Install Rust |
26 | | -RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y |
27 | | -ENV PATH="/root/.cargo/bin:${PATH}" |
28 | | -RUN rustup toolchain install |
29 | | -RUN rustup target add wasm32-unknown-unknown |
30 | | - |
| 23 | +# |
| 24 | +# Image for building prod |
| 25 | +# |
| 26 | +FROM base_builder AS prod_builder |
31 | 27 | # Build the project |
32 | 28 | RUN cargo build -p node-subtensor --profile production --features="metadata-hash" --locked |
33 | | - |
34 | | -# Slim down image |
35 | | -RUN rm -rf /root/.cargo |
36 | | - |
37 | 29 | # Verify the binary was produced |
38 | 30 | RUN test -e /build/target/production/node-subtensor |
39 | | - |
40 | 31 | EXPOSE 30333 9933 9944 |
41 | 32 |
|
| 33 | +# |
| 34 | +# Final prod image |
| 35 | +# |
42 | 36 | FROM $BASE_IMAGE AS subtensor |
43 | | - |
44 | 37 | # Copy all chainspec files |
45 | | -COPY --from=builder /build/chainspecs/*.json / |
| 38 | +COPY --from=prod_builder /build/*.json / |
| 39 | +# Copy final binary |
| 40 | +COPY --from=prod_builder /build/target/production/node-subtensor /usr/local/bin |
| 41 | + |
| 42 | + |
| 43 | +# |
| 44 | +# Image for building local |
| 45 | +# |
| 46 | +FROM base_builder AS local_builder |
| 47 | +# Build the project |
| 48 | +RUN cargo build --workspace --profile release --features="pow-faucet" |
| 49 | +# Verify the binary was produced |
| 50 | +RUN test -e /build/target/release/node-subtensor |
| 51 | +EXPOSE 30333 9933 9944 |
46 | 52 |
|
| 53 | + |
| 54 | +# |
| 55 | +# Final local image |
| 56 | +# |
| 57 | +FROM $BASE_IMAGE AS subtensor-local |
| 58 | +# Copy all chainspec files |
| 59 | +COPY --from=local_builder /build/*.json / |
47 | 60 | # Copy final binary |
48 | | -COPY --from=builder /build/target/production/node-subtensor /usr/local/bin |
| 61 | +COPY --from=local_builder /build/target/release/node-subtensor /usr/local/bin |
| 62 | +RUN "node-subtensor" build-spec --disable-default-bootnode --raw --chain local > /localnet.json |
0 commit comments