1# ===== Rust builder =====2FROM ubuntu:22.04 as rust-builder3LABEL maintainer="Unique.Network"45ENV CARGO_HOME="/cargo-home"6ENV PATH="/cargo-home/bin:$PATH"7ENV TZ=UTC8RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone910RUN apt-get update && \11 apt-get install -y curl cmake pkg-config libssl-dev git clang llvm libudev-dev protobuf-compiler && \12 apt-get clean && \13 rm -r /var/lib/apt/lists/*1415RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none1617ARG RUST_TOOLCHAIN18RUN echo "Using Rust '$RUST_TOOLCHAIN'" && \19 rustup toolchain install $RUST_TOOLCHAIN && \20 rustup target add wasm32-unknown-unknown --toolchain ${RUST_TOOLCHAIN} && \21 rustup default $RUST_TOOLCHAIN && \22 rustup component add --toolchain $RUST_TOOLCHAIN rust-src && \23 rustup target list --installed && \24 rustup show2526RUN mkdir /unique_parachain27WORKDIR /unique_parachain2829# ===== BUILD UNIQUE =====30FROM rust-builder as builder-polkadot-bin3132WORKDIR /unique_parachain3334COPY . unique-chain/3536ARG RUNTIME_FEATURES37# registry for Updating registry. It is safe to cache it, because it only contains references to the dependency files,38# and the caches for the files themselves are set in Cargo.lock, which won't be updated because of --locked flag39# git for Updating git repository. It is safe to cache it, because git dependencies are cached by revision,40# revision is locked in Cargo.lock, and it is forbidden to update the Cargo.lock, because of --locked flag41# passed to cargo build42# target for built dependencies. Technically, it may be unsafe to cache it, but there was no bugs in the caching logic43# of it to this day (Ignoring incremental compilation, which is explicitly disabled by CARGO_INCREMENTAL=0). Only the44# fully built crates will be cached depending on the crate source, version and feature set, which are locked by45# Cargo.lock, which can't be updated because of the --locked flag.46RUN --mount=type=cache,target=/cargo-home/registry \47 --mount=type=cache,target=/cargo-home/git \48 --mount=type=cache,target=/unique_parachain/unique-chain/target \49 cd unique-chain && \50 echo "Using runtime features '$RUNTIME_FEATURES'" && \51 CARGO_INCREMENTAL=0 cargo build --profile integration-tests --features=fast-inflation,"$RUNTIME_FEATURES" --locked && \52 mv ./target/integration-tests/unique-collator /unique_parachain/unique-chain/ && \53 cd target/integration-tests/wbuild && find . -name "*.wasm" -exec sh -c 'mkdir -p "../../../wasm/$(dirname {})"; cp {} "../../../wasm/{}"' \;5455# ===== BIN ======5657FROM ubuntu:22.04 as builder-polkadot5859COPY --from=builder-polkadot-bin /unique_parachain/unique-chain/unique-collator /bin/unique-collator60COPY --from=builder-polkadot-bin /unique_parachain/unique-chain/wasm /wasm61ENTRYPOINT ["/bin/unique-collator"]