ARG BASE_IMAGE=ubuntu:latest FROM $BASE_IMAGE AS builder SHELL ["/bin/bash", "-c"] # Set noninteractive mode for apt-get ARG DEBIAN_FRONTEND=noninteractive LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ ai.opentensor.image.vendor="Opentensor Foundation" \ ai.opentensor.image.title="opentensor/subtensor-localnet" \ ai.opentensor.image.description="Opentensor Subtensor Blockchain" \ ai.opentensor.image.documentation="https://docs.bittensor.com" # Copy repo first (you want this *before* RUN to enable layer cache reuse) COPY . /build WORKDIR /build # Set up env var ARG BUILT_IN_CI ARG TARGETARCH ENV BUILT_IN_CI=${BUILT_IN_CI} ENV RUST_BACKTRACE=1 ENV PATH="/root/.cargo/bin:${PATH}" ## Ubdate certificates RUN apt-get update && apt-get install -y ca-certificates # Install requirements RUN chmod +x ./scripts/install_build_env.sh RUN ./scripts/install_build_env.sh ## Build fast-runtime node RUN ./scripts/localnet.sh --build-only # Build non-fast-runtime RUN ./scripts/localnet.sh False --build-only # We will prepare the necessary binaries if they are created in CI RUN chmod +x ./scripts/install_prebuilt_binaries.sh RUN ./scripts/install_prebuilt_binaries.sh # Verify the binaries was produced RUN test -e /build/target/fast-runtime/release/node-subtensor RUN test -e /build/target/non-fast-runtime/release/node-subtensor FROM $BASE_IMAGE AS subtensor-localnet # Copy binaries COPY --from=builder /build/target/fast-runtime/release/node-subtensor target/fast-runtime/release/node-subtensor RUN chmod +x target/fast-runtime/release/node-subtensor COPY --from=builder /build/target/non-fast-runtime/release/node-subtensor target/non-fast-runtime/release/node-subtensor RUN chmod +x target/non-fast-runtime/release/node-subtensor COPY --from=builder /build/snapshot.json /snapshot.json COPY --from=builder /build/scripts/localnet.sh scripts/localnet.sh RUN chmod +x /scripts/localnet.sh # Copy WebAssembly artifacts COPY --from=builder /build/target/fast-runtime/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm target/fast-runtime/release/node_subtensor_runtime.compact.compressed.wasm COPY --from=builder /build/target/non-fast-runtime/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm target/non-fast-runtime/release/node_subtensor_runtime.compact.compressed.wasm # Update certificates for next layer RUN apt-get update && apt-get install -y ca-certificates # Do not build (just run) ENV BUILD_BINARY=0 # Switch to local run with IP 0.0.0.0 within docker image ENV RUN_IN_DOCKER=1 # Expose ports EXPOSE 30334 30335 9944 9945 ENTRYPOINT ["/scripts/localnet.sh"] # Fast blocks defaults to True, you can disable it by passing False to the docker command, e.g.: # docker run ghcr.io/opentensor/subtensor-localnet False CMD ["True"]