forked from linera-io/linera-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
87 lines (65 loc) · 3.24 KB
/
Dockerfile
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
80
81
82
83
84
85
86
87
##############################################################################
################## Meant to be run with Google Cloud Build ##################
##############################################################################
# From the root of the repo, use the following command to run:
# gcloud builds submit --tag us-docker.pkg.dev/linera-io-dev/linera-docker-repo/<PACKAGE_NAME>:<VERSION_TAG> --timeout="3h" --machine-type=e2-highcpu-32
# The package name needs that prefix so it stores it in the proper Docker container registry on GCP (Google Cloud Platform).
# Make sure you specify the <PACKAGE_NAME> and <VERSION_TAG> you want though.
# The --timeout and --machine-type flags are optional, but building with the default machine type
# takes considerably longer. The default timeout is 1h, which you'll likely hit if you run with
# the default machine type.
# Stage 1 - Generate recipe file for dependencies
FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef
RUN mkdir -p /opt/linera/build
WORKDIR /opt/linera/build
FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Stage 2 - Build dependencies
FROM chef AS cacher
COPY . .
COPY --from=planner /opt/linera/build/recipe.json recipe.json
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
protobuf-compiler \
clang
RUN cargo chef cook --release --recipe-path recipe.json --target x86_64-unknown-linux-gnu --features kube
# Stage 3 - Do actual build
FROM chef as builder
COPY . .
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
protobuf-compiler \
clang
COPY --from=cacher /opt/linera/build/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
RUN cargo build --release --target x86_64-unknown-linux-gnu --bin linera --bin linera-proxy --bin linera-server --features kube \
&& strip target/x86_64-unknown-linux-gnu/release/linera \
&& strip target/x86_64-unknown-linux-gnu/release/linera-proxy \
&& strip target/x86_64-unknown-linux-gnu/release/linera-server
# Stage 4 - Setup running environment for container
FROM debian:latest
WORKDIR /opt/linera
RUN apt-get update && apt-get install -y libssl-dev
ENV BUILD_PATH=/opt/linera/build
# Copying binaries
COPY --from=builder $BUILD_PATH/target/x86_64-unknown-linux-gnu/release/linera ./
COPY --from=builder $BUILD_PATH/target/x86_64-unknown-linux-gnu/release/linera-server ./
COPY --from=builder $BUILD_PATH/target/x86_64-unknown-linux-gnu/release/linera-proxy ./
# Copying configuration files
COPY --from=builder $BUILD_PATH/configuration/prod/validator_1.toml ./
# Create configuration files for the validator according to the validator's config file.
# * Private server states are stored in `server*.json`.
# * `committee.json` is the public description of the Linera committee.
RUN ./linera-server generate --validators validator_1.toml --committee committee.json
# Create configuration files for 1000 user chains.
# * Private chain states are stored in one local wallet `wallet.json`.
# * `genesis.json` will contain the initial balances of chains as well as the initial committee.
RUN ./linera \
--wallet wallet.json \
create-genesis-config 1000 \
--genesis genesis.json \
--initial-funding 100 \
--committee committee.json