-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathDockerfile-localnet
More file actions
79 lines (58 loc) · 2.79 KB
/
Dockerfile-localnet
File metadata and controls
79 lines (58 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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"]