This repository has been archived by the owner on Aug 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dockerfile): multi-stage meta-node docker build (#163)
<!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: > Experimental As per the title. This PR adds multi-stage Docker build for `./meta-node`. All docker images now utilize Docker to build. Fixes #61 Signed-off-by: Fuxing Loh <[email protected]> Co-authored-by: Diehard073055 <[email protected]>
- Loading branch information
1 parent
a12ecd6
commit 419304b
Showing
2 changed files
with
27 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
FROM ubuntu:22.04 | ||
FROM ubuntu:22.04 AS builder | ||
|
||
WORKDIR /metachain | ||
RUN apt update && apt upgrade -y | ||
RUN apt install -y curl | ||
|
||
# Requires copy the binary to `build` folder beforehand | ||
COPY build/* /metachain | ||
WORKDIR /metachain | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none --profile minimal -y | ||
|
||
# 30333 for p2p traffic | ||
# 9933 for RPC call | ||
# 9944 for Websocket | ||
# 9615 for Prometheus (metrics) | ||
EXPOSE 30333 9933 9944 | ||
ENV PATH=$PATH:/root/.cargo/bin | ||
RUN apt install -y cmake clang | ||
|
||
COPY rust-toolchain.toml Cargo.toml Cargo.lock ./ | ||
# TODO: docker layer cache, blocked by https://github.com/rust-lang/cargo/issues/2644 | ||
# RUN cargo fetch | ||
|
||
COPY meta ./meta | ||
ARG PROFILE=release | ||
ENV PROFILE ${PROFILE} | ||
RUN cargo build --$PROFILE --all | ||
|
||
VOLUME ["/data"] | ||
|
||
FROM ubuntu:22.04 AS runner | ||
WORKDIR /metachain | ||
COPY --from=builder /metachain/target/release/meta-node . | ||
|
||
# Ports to open from https://github.com/DeFiCh/metachain/blob/d3f4a9b36eb25d7340a8b138795882cada7c60e5/packages/network/src/NetworkConfig.ts | ||
EXPOSE 30333 9333 9944 9615 39333 19933 19944 | ||
|
||
VOLUME ["/data"] | ||
ENTRYPOINT ["/metachain/meta-node"] |