From 6ff0a423189a5e041b42034e414ece33dbb78e3f Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Wed, 3 Aug 2022 19:43:32 -0400 Subject: [PATCH] refactor(build): use FHS for deployments and artifacts (#4786) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- 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 5bb39b963..17a1620b3 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 9dbe46f1f..b3d5d7613 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 c441e1719..1036a2be4 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