forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: add dockerfile for building a number of sui binaries (MystenL…
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
FROM rust:1.60.0 AS chef | ||
WORKDIR sui | ||
RUN apt-get update && apt-get install -y cmake clang | ||
|
||
# Plan out the 3rd-party dependencies that need to be built. | ||
# | ||
# This is done by: | ||
# 1. Copy in Cargo.toml, Cargo.lock, and the workspace-hack crate | ||
# 2. Removing all workspace crates, other than the workpsace-hack | ||
# crate, from the workspace Cargo.toml file. | ||
# 3. Update the lockfile in order to reflect the changes to the | ||
# root Cargo.toml file. | ||
FROM chef AS planner | ||
COPY Cargo.toml Cargo.lock . | ||
COPY crates/workspace-hack crates/workspace-hack | ||
RUN sed -i '/crates\/workspace-hack/b; /crates/d' Cargo.toml \ | ||
&& cargo metadata -q >/dev/null | ||
|
||
# Build and cache all dependencies. | ||
# | ||
# In a fresh layer, copy in the "plan" generated by the planner | ||
# and run `cargo build` in order to create a caching Docker layer | ||
# with all dependencies built. | ||
FROM chef AS builder | ||
COPY --from=planner /sui/Cargo.toml Cargo.toml | ||
COPY --from=planner /sui/Cargo.lock Cargo.lock | ||
COPY --from=planner /sui/crates/workspace-hack crates/workspace-hack | ||
RUN cargo build --release | ||
|
||
# Build application | ||
# | ||
# Copy in the rest of the crates (and an unmodified Cargo.toml and Cargo.lock) | ||
# and build the application. At this point no dependencies should need to be | ||
# built as they were built and cached by the previous layer. | ||
COPY Cargo.toml Cargo.lock . | ||
COPY crates crates | ||
RUN cargo build --release \ | ||
--bin sui-node \ | ||
--bin sui \ | ||
--bin wallet \ | ||
--bin sui-move | ||
|
||
# Production Image | ||
FROM debian:bullseye-slim AS runtime | ||
WORKDIR sui | ||
COPY --from=builder /sui/target/release/sui-node /usr/local/bin | ||
COPY --from=builder /sui/target/release/sui /usr/local/bin | ||
COPY --from=builder /sui/target/release/wallet /usr/local/bin | ||
COPY --from=builder /sui/target/release/sui-move /usr/local/bin | ||
|
||
ARG BUILD_DATE | ||
ARG GIT_REVISION | ||
LABEL build-date=$BUILD_DATE | ||
LABEL git-revision=$GIT_REVISION |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2022, Mysten Labs, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# fast fail. | ||
set -eo pipefail | ||
|
||
DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
DOCKERFILE="$DIR/Dockerfile" | ||
GIT_REVISION="$(git describe --always --dirty)" | ||
BUILD_DATE="$(date -u +'%Y-%m-%d')" | ||
|
||
echo | ||
echo "Building sui-node docker image" | ||
echo "Dockerfile: \t$DOCKERFILE" | ||
echo "docker context: $REPO_ROOT" | ||
echo "build date: \t$BUILD_DATE" | ||
echo "git revision: \t$GIT_REVISION" | ||
echo | ||
|
||
docker build -f "$DOCKERFILE" "$REPO_ROOT" \ | ||
--build-arg GIT_REVISION="$GIT_REVISION" \ | ||
--build-arg BUILD_DATE="$BUILD_DATE" \ | ||
"$@" |