Containerization is a software distribution process that bundles an application's code with all the necessary files and libraries required to run it on any infrastructure. InfraBlockchain also supports containerization for all chains within it, and the relevant methods are described below.
Creating a Container Image
Let's explore how to create a Docker container image.
To create a container image, you need a 'Dockerfile'. Here, we'll explain how to create a container image for the Relay Chain. If you want to create a container image for a different chain, please visit the link below and check the desired chain repository.
FROM ubuntu:jammy AS builder# The node will be built in this directoryWORKDIR /infra-relay-chainRUN apt -y update && \ apt install -y --no-install-recommends \ software-properties-common llvm curl git file binutils binutils-dev \ make cmake ca-certificates clang g++ zip dpkg-dev openssl gettext \ build-essential pkg-config libssl-dev libudev-dev time clang protobuf-compiler# install rustupRUN curl https://sh.rustup.rs -sSf | sh -s -- -y# rustup directoryENV PATH /root/.cargo/bin:$PATH# setup rust nightly channel, pinning specific version as newer versions have a regressionRUN rustup install nightly-2023-05-21RUN rustup default nightly-2023-05-21# install wasm toolchain for substrateRUN rustup target add wasm32-unknown-unknown --toolchain nightly-2023-02-20#compiler ENVENV CC clangENV CXX g++# Copy code to build directory, instead of only using .dockerignore, we copy elements# explicitly. This lets us cache build results while iterating on scripts.COPY . .RUN echo 'Building in release mode.' ; \ cargo build --release ; \ mv /infra-relay-chain/target/release/infra-relaychain /infra-relay-chain/target/; # Final stage. Copy the node executable and the scriptFROM ubuntu:jammyWORKDIR /infra-relay-chainCOPY --from=builder /infra-relay-chain/target/infrablockspace .# curl is required for uploading to keystore# note: `subkey insert` is a potential alternarve to curlRUN apt -y update \ && apt install -y --no-install-recommends curl \ && rm -rf /var/lib/apt/lists/*# expose node portsEXPOSE 30333 9933 9944ENV RUST_BACKTRACE 1ENTRYPOINT ["./infrablockspace"]CMD []
Once you have completed writing the relevant files, use the following command to generate the container image:
dockerbuild-t<tagname>:<version>.
The ways to utilize the generated image are mentioned in the deployment section.