2022-02-08 16:50:13 -08:00
|
|
|
# This steps implement cargo-chef for docker layer caching
|
|
|
|
# We are using four stages:
|
|
|
|
# - chef: installs cargo-chef
|
|
|
|
# - planner: computes the recipe file
|
|
|
|
# - builder: caches our dependencies and builds the binary
|
|
|
|
# - tester: builds and run tests
|
|
|
|
# - runtime: is our runtime environment
|
|
|
|
FROM rust:bullseye as chef
|
|
|
|
RUN cargo install cargo-chef --locked
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
FROM chef AS planner
|
|
|
|
COPY . .
|
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
|
|
|
|
FROM chef AS builder
|
|
|
|
COPY --from=planner /app/recipe.json recipe.json
|
|
|
|
|
|
|
|
# Install zebra build deps
|
|
|
|
RUN apt-get -qq update && \
|
|
|
|
apt-get -qq install -y --no-install-recommends \
|
|
|
|
llvm \
|
|
|
|
libclang-dev \
|
|
|
|
clang \
|
|
|
|
ca-certificates \
|
|
|
|
; \
|
|
|
|
rm -rf /var/lib/apt/lists/* /tmp/*
|
|
|
|
|
|
|
|
# Install google OS Config agent
|
|
|
|
RUN apt-get -qq update && \
|
|
|
|
apt-get -qq install -y --no-install-recommends \
|
|
|
|
curl \
|
|
|
|
lsb-release \
|
|
|
|
; \
|
|
|
|
echo "deb http://packages.cloud.google.com/apt google-compute-engine-$(lsb_release -cs)-stable main" > /etc/apt/sources.list.d/google-compute-engine.list && \
|
|
|
|
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
|
|
|
|
apt-get -qq update && \
|
|
|
|
apt-get -qq install -y --no-install-recommends google-osconfig-agent && \
|
|
|
|
rm -rf /var/lib/apt/lists/* /tmp/*
|
|
|
|
|
|
|
|
# Optimize builds. In particular, regenerate-stateful-test-disks.yml was reaching the
|
|
|
|
# GitHub Actions time limit (6 hours), so we needed to make it faster.
|
|
|
|
ENV RUSTFLAGS -O
|
|
|
|
ENV CARGO_HOME /app/.cargo/
|
|
|
|
# Build dependencies - this is the caching Docker layer!
|
|
|
|
RUN cargo chef cook --release --features enable-sentry --recipe-path recipe.json
|
|
|
|
|
|
|
|
ARG RUST_BACKTRACE=1
|
|
|
|
ENV RUST_BACKTRACE ${RUST_BACKTRACE}
|
2020-11-18 11:41:47 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
COPY . .
|
|
|
|
# Build zebra
|
|
|
|
RUN cargo build --locked --release --features enable-sentry --bin zebrad
|
2020-11-18 11:41:47 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
FROM builder AS tester
|
|
|
|
# Pre-download Zcash Sprout and Sapling parameters
|
|
|
|
# TODO: do not hardcode the user /root/ even though is a safe assumption
|
|
|
|
COPY --from=us-docker.pkg.dev/zealous-zebra/zebra/zcash-params /root/.zcash-params /root/.zcash-params
|
2020-12-03 19:51:42 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
# Skip IPv6 tests by default, as some CI environment don't have IPv6 available
|
|
|
|
ARG ZEBRA_SKIP_IPV6_TESTS=1
|
|
|
|
ENV ZEBRA_SKIP_IPV6_TESTS ${ZEBRA_SKIP_IPV6_TESTS}
|
2020-12-03 19:51:42 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
RUN cargo test --locked --release --features enable-sentry --workspace --no-run
|
2020-11-18 11:41:47 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
CMD ["cargo" "test" "--locked" "--release" "--features" "enable-sentry" "--workspace"]
|
2020-11-18 11:41:47 -08:00
|
|
|
|
|
|
|
# Runner image
|
2022-02-08 16:50:13 -08:00
|
|
|
FROM debian:bullseye-slim AS runtime
|
|
|
|
COPY --from=builder /app/target/release/zebrad /usr/local/bin
|
|
|
|
COPY --from=us-docker.pkg.dev/zealous-zebra/zebra/zcash-params /root/.zcash-params /root/.zcash-params
|
2020-11-18 11:41:47 -08:00
|
|
|
|
2020-12-04 02:54:18 -08:00
|
|
|
RUN apt-get update && \
|
2022-02-08 16:50:13 -08:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
ca-certificates
|
2020-11-18 11:41:47 -08:00
|
|
|
|
|
|
|
ARG CHECKPOINT_SYNC=true
|
|
|
|
ARG NETWORK=Mainnet
|
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
RUN set -ex; \
|
|
|
|
{ \
|
|
|
|
echo "[consensus]"; \
|
|
|
|
echo "checkpoint_sync = ${CHECKPOINT_SYNC}"; \
|
|
|
|
echo "[metrics]"; \
|
|
|
|
echo "endpoint_addr = '0.0.0.0:9999'"; \
|
|
|
|
echo "[network]"; \
|
|
|
|
echo "network = '${NETWORK}'"; \
|
|
|
|
echo "[state]"; \
|
|
|
|
echo "cache_dir = '/zebrad-cache'"; \
|
|
|
|
echo "[tracing]"; \
|
|
|
|
echo "endpoint_addr = '0.0.0.0:3000'"; \
|
|
|
|
} > "zebrad.toml"
|
2021-11-19 15:02:56 -08:00
|
|
|
|
2020-11-18 11:41:47 -08:00
|
|
|
EXPOSE 3000 8233 18233
|
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
ARG SHORT_SHA
|
|
|
|
ENV SHORT_SHA $SHORT_SHA
|
|
|
|
|
|
|
|
ARG SENTRY_DSN
|
|
|
|
ENV SENTRY_DSN ${SENTRY_DSN}
|
2020-11-22 18:19:08 -08:00
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
CMD [ "zebrad", "-c", "zebrad.toml", "start" ]
|