From 54e17d40acf79308f8bd0cb79e0545d1b1fca114 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Mon, 18 Jul 2022 16:32:32 -0400 Subject: [PATCH 1/2] refactor(build): use FHS for deployments and artifacts --- docker/Dockerfile | 8 ++++---- docker/zcash-lightwalletd/Dockerfile | 4 ++-- docker/zcash-params/Dockerfile | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5bb39b96361..17a1620b36a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,7 @@ # This stage implements cargo-chef for docker layer caching FROM rust:bullseye as chef RUN cargo install cargo-chef --locked -WORKDIR /app +WORKDIR /opt/zebrad # Analyze the current project to determine the minimum subset of files # (Cargo.lock and Cargo.toml manifests) required to build it and cache dependencies @@ -25,7 +25,7 @@ RUN cargo chef prepare --recipe-path recipe.json # We set defaults for the arguments, in case the build does not include this information. FROM chef AS deps SHELL ["/bin/bash", "-xo", "pipefail", "-c"] -COPY --from=planner /app/recipe.json recipe.json +COPY --from=planner /opt/zebrad/recipe.json recipe.json # Install zebra build deps RUN apt-get -qq update && \ @@ -82,7 +82,7 @@ ENV CHECKPOINT_SYNC ${CHECKPOINT_SYNC:-true} ARG NETWORK ENV NETWORK ${NETWORK:-Mainnet} -ENV CARGO_HOME /app/.cargo/ +ENV CARGO_HOME /opt/zebrad/.cargo/ # In this stage we build tests (without running then) # @@ -129,7 +129,7 @@ RUN cargo build --locked --release --features sentry --package zebrad --bin zebr # To save space, this step starts from scratch using debian, and only adds the resulting # binary from the `release` stage, and the Zcash Sprout & Sapling parameters from ZCash FROM debian:bullseye-slim AS runtime -COPY --from=release /app/target/release/zebrad /usr/local/bin +COPY --from=release /opt/zebrad/target/release/zebrad /usr/local/bin COPY --from=us-docker.pkg.dev/zealous-zebra/zebra/zcash-params /root/.zcash-params /root/.zcash-params RUN apt-get update && \ diff --git a/docker/zcash-lightwalletd/Dockerfile b/docker/zcash-lightwalletd/Dockerfile index 9dbe46f1f34..b3d5d761324 100644 --- a/docker/zcash-lightwalletd/Dockerfile +++ b/docker/zcash-lightwalletd/Dockerfile @@ -24,7 +24,7 @@ RUN go mod download COPY . ./ # Build and install the binary. -RUN go build -v -o /lightwalletd +RUN go build -v -o /opt/lightwalletd ARG ZCASHD_CONF_PATH @@ -51,7 +51,7 @@ ARG LWD_HTTP_PORT WORKDIR / -COPY --from=build /lightwalletd /usr/local/bin +COPY --from=build /opt/lightwalletd /usr/local/bin COPY --from=build $ZCASHD_CONF_PATH ./ EXPOSE 9067 diff --git a/docker/zcash-params/Dockerfile b/docker/zcash-params/Dockerfile index c441e171951..1036a2be40b 100644 --- a/docker/zcash-params/Dockerfile +++ b/docker/zcash-params/Dockerfile @@ -2,14 +2,14 @@ # This image is for caching Zcash Sprout and Sapling parameters FROM rust:bullseye as chef RUN cargo install cargo-chef --locked -WORKDIR /app +WORKDIR /opt/zebrad FROM chef AS planner COPY . . RUN cargo chef prepare --recipe-path recipe.json FROM chef AS release -COPY --from=planner /app/recipe.json recipe.json +COPY --from=planner /opt/zebrad/recipe.json recipe.json # Install zebra build deps RUN apt-get -qq update && \ @@ -21,7 +21,7 @@ RUN apt-get -qq update && \ ; \ rm -rf /var/lib/apt/lists/* /tmp/* -ENV CARGO_HOME /app/.cargo/ +ENV CARGO_HOME /opt/zebrad/.cargo/ # Build dependencies - this is the caching Docker layer! RUN cargo chef cook --release --features sentry --package zebrad --recipe-path recipe.json From 8ccfc56c22e92cabf038711ee3f34da51dd3c7e8 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 20 Jul 2022 13:17:53 +1000 Subject: [PATCH 2/2] Enable a transitive feature that speeds up compilation --- Cargo.lock | 7 +++++++ tower-batch/Cargo.toml | 4 ++++ zebra-chain/Cargo.toml | 4 +++- zebra-consensus/Cargo.toml | 4 ++++ zebra-state/Cargo.toml | 4 ++++ zebra-test/Cargo.toml | 4 ++++ zebra-utils/Cargo.toml | 6 +++++- zebrad/Cargo.toml | 4 ++++ 8 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8dab1379d56..92c69501f23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5448,6 +5448,7 @@ dependencies = [ "pin-project 1.0.11", "rand 0.8.5", "rayon", + "tinyvec", "tokio", "tokio-test", "tokio-util 0.7.3", @@ -6332,6 +6333,7 @@ dependencies = [ "static_assertions", "subtle", "thiserror", + "tinyvec", "tokio", "tracing", "uint", @@ -6375,6 +6377,7 @@ dependencies = [ "serde", "spandoc", "thiserror", + "tinyvec", "tokio", "tower", "tower-batch", @@ -6506,6 +6509,7 @@ dependencies = [ "spandoc", "tempfile", "thiserror", + "tinyvec", "tokio", "tower", "tracing", @@ -6531,6 +6535,7 @@ dependencies = [ "spandoc", "tempfile", "thiserror", + "tinyvec", "tokio", "tower", "tracing", @@ -6546,6 +6551,7 @@ dependencies = [ "hex", "serde_json", "structopt", + "tinyvec", "tracing-error", "tracing-subscriber 0.3.11", "zebra-chain", @@ -6592,6 +6598,7 @@ dependencies = [ "serde_json", "tempfile", "thiserror", + "tinyvec", "tokio", "tokio-stream", "toml", diff --git a/tower-batch/Cargo.toml b/tower-batch/Cargo.toml index 915cd66b602..465c5e6e77a 100644 --- a/tower-batch/Cargo.toml +++ b/tower-batch/Cargo.toml @@ -18,6 +18,10 @@ tracing-futures = "0.2.5" [dev-dependencies] color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + ed25519-zebra = "3.0.0" rand = { version = "0.8.5", package = "rand" } diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index 9c310937894..838e175e5ee 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -85,12 +85,14 @@ tokio = { version = "1.20.0", features = ["tracing"], optional = true } zebra-test = { path = "../zebra-test/", optional = true } [dev-dependencies] - # Benchmarks criterion = { version = "0.3.5", features = ["html_reports"] } # Error Handling & Formatting color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } spandoc = "0.2.2" tracing = "0.1.31" diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index 5af30a29dc6..4f0b80ace2e 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -52,6 +52,10 @@ proptest-derive = { version = "0.3.0", optional = true } [dev-dependencies] color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + hex = "0.4.3" proptest = "0.10.1" proptest-derive = "0.3.0" diff --git a/zebra-state/Cargo.toml b/zebra-state/Cargo.toml index 88212e191a0..a80bb8e2a2b 100644 --- a/zebra-state/Cargo.toml +++ b/zebra-state/Cargo.toml @@ -39,6 +39,10 @@ proptest-derive = { version = "0.3.0", optional = true } [dev-dependencies] color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + once_cell = "1.12.0" spandoc = "0.2.2" diff --git a/zebra-test/Cargo.toml b/zebra-test/Cargo.toml index 960e99d4aa5..d7f31292dff 100644 --- a/zebra-test/Cargo.toml +++ b/zebra-test/Cargo.toml @@ -22,6 +22,10 @@ tower = { version = "0.4.13", features = ["util"] } futures = "0.3.21" color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + owo-colors = "3.4.0" spandoc = "0.2.2" thiserror = "1.0.31" diff --git a/zebra-utils/Cargo.toml b/zebra-utils/Cargo.toml index a65077368bc..02edbac7775 100644 --- a/zebra-utils/Cargo.toml +++ b/zebra-utils/Cargo.toml @@ -8,8 +8,12 @@ edition = "2021" publish = false [dependencies] -structopt = "0.3.26" color-eyre = "0.6.1" +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + +structopt = "0.3.26" hex = "0.4.3" serde_json = "1.0.81" tracing-error = "0.2.0" diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 4f2eb0ccbba..5e137efe31d 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -92,6 +92,10 @@ tower = { version = "0.4.13", features = ["hedge", "limit"] } pin-project = "1.0.10" color-eyre = { version = "0.6.1", default_features = false, features = ["issue-url"] } +# This is a transitive dependency via color-eyre. +# Enable a feature that makes tinyvec compile much faster. +tinyvec = { version = "1.5.1", features = ["rustc_1_55"] } + thiserror = "1.0.31" tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }