Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): create Docker hub binary with mining enabled on release #6228

Merged
merged 9 commits into from
Mar 24, 2023
20 changes: 20 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ on:
required: false
type: string
default: info
features:
required: false
type: string
test_features:
required: false
default: "lightwalletd-grpc-tests"
type: string
rpc_port:
required: false
type: string
tag_suffix:
required: false
type: string

outputs:
image_digest:
description: 'The image digest to be used on a caller workflow'
Expand Down Expand Up @@ -72,6 +86,9 @@ jobs:
images: |
us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}
zfnd/zebra,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
# appends inputs.tag_suffix to tags
arya2 marked this conversation as resolved.
Show resolved Hide resolved
flavor: |
suffix=${{ inputs.tag_suffix }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
Expand Down Expand Up @@ -145,6 +162,9 @@ jobs:
ZEBRA_SKIP_IPV6_TESTS=${{ inputs.zebra_skip_ipv6_tests }}
CHECKPOINT_SYNC=${{ inputs.checkpoint_sync }}
RUST_LOG=${{ inputs.rust_log }}
FEATURES=${{ inputs.features }}
TEST_FEATURES=${{ inputs.test_features }}
RPC_PORT=${{ inputs.rpc_port }}
push: true
# To improve build speeds, for each branch we push an additional image to the registry,
# to be used as the caching layer, using the `max` caching mode.
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
# Each time this workflow is executed, a build will be triggered to create a new image
# with the corresponding tags using information from git
#

# The image will be named `zebrad:<semver>`
build:
name: Build Release Docker
Expand All @@ -33,3 +33,23 @@ jobs:
rust_log: info
# This step needs access to Docker Hub secrets to run successfully
secrets: inherit

# The image will be named `zebrad-mining-rpcs-testnet:<semver>`
arya2 marked this conversation as resolved.
Show resolved Hide resolved
build-mining-testnet:
name: Build Release Testnet Mining Docker
uses: ./.github/workflows/build-docker-image.yml
with:
dockerfile_path: ./docker/Dockerfile
dockerfile_target: runtime
image_name: zebrad-mining-rpcs-testnet
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
tag_suffix: .experimental
arya2 marked this conversation as resolved.
Show resolved Hide resolved
network: Testnet
rpc_port: '18232'
features: "getblocktemplate-rpcs"
test_features: ""
checkpoint_sync: true
rust_backtrace: '1'
zebra_skip_ipv6_tests: '1'
rust_log: info
# This step needs access to Docker Hub secrets to run successfully
secrets: inherit
19 changes: 13 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ ENV ZEBRA_SKIP_IPV6_TESTS ${ZEBRA_SKIP_IPV6_TESTS:-1}
ARG CHECKPOINT_SYNC
ENV CHECKPOINT_SYNC ${CHECKPOINT_SYNC:-true}

# Build zebrad with these features
ARG FEATURES
ARG TEST_FEATURES="lightwalletd-grpc-tests"

ARG NETWORK
ENV NETWORK ${NETWORK:-Mainnet}

Expand All @@ -100,10 +104,10 @@ COPY --from=us-docker.pkg.dev/zealous-zebra/zebra/lightwalletd /opt/lightwalletd
# This is the caching Docker layer for Rust!
#
# TODO: is it faster to use --tests here?
RUN cargo chef cook --release --features sentry,lightwalletd-grpc-tests --workspace --recipe-path recipe.json
RUN cargo chef cook --release --features "sentry ${TEST_FEATURES} ${FEATURES}" --workspace --recipe-path recipe.json

COPY . .
RUN cargo test --locked --release --features lightwalletd-grpc-tests --workspace --no-run
RUN cargo test --locked --release --features "${TEST_FEATURES} ${FEATURES}" --workspace --no-run
RUN cp /opt/zebrad/target/release/zebrad /usr/local/bin

COPY ./docker/entrypoint.sh /
Expand All @@ -118,11 +122,11 @@ ENTRYPOINT [ "/entrypoint.sh" ]
# `test` stage. This step is a dependency for the `runtime` stage, which uses the resulting
# zebrad binary from this step.
FROM deps AS release
RUN cargo chef cook --release --features sentry --recipe-path recipe.json
RUN cargo chef cook --release --features "sentry ${FEATURES}" --recipe-path recipe.json

COPY . .
# Build zebra
RUN cargo build --locked --release --features sentry --package zebrad --bin zebrad
RUN cargo build --locked --release --features "sentry ${FEATURES}" --package zebrad --bin zebrad

# This stage is only used when deploying nodes or when only the resulting zebrad binary is needed
#
Expand All @@ -138,6 +142,7 @@ RUN apt-get update && \

ARG CHECKPOINT_SYNC=true
ARG NETWORK=Mainnet
ARG RPC_PORT

# Use a configurable dir and file for the zebrad configuration file
ARG ZEBRA_CONF_DIR=/etc/zebra
Expand Down Expand Up @@ -169,20 +174,22 @@ RUN set -ex; \
{ \
echo "[network]"; \
echo "network = '${NETWORK}'"; \
[ $NETWORK = "Testnet" ] && echo "listen_addr = '127.0.0.1:18233'"; \
arya2 marked this conversation as resolved.
Show resolved Hide resolved
echo "[consensus]"; \
echo "checkpoint_sync = ${CHECKPOINT_SYNC}"; \
echo "[state]"; \
echo "cache_dir = '/zebrad-cache'"; \
echo "[rpc]"; \
echo "#listen_addr = '127.0.0.1:8232'"; \
[ -n "$RPC_PORT" ] && echo "listen_addr = '127.0.0.1:${RPC_PORT}'"; \
echo "parallel_cpu_threads = 0"; \
echo "[metrics]"; \
echo "#endpoint_addr = '127.0.0.1:9999'"; \
echo "[tracing]"; \
echo "#endpoint_addr = '127.0.0.1:3000'"; \
} > "${ZEBRA_CONF_PATH}"

EXPOSE 8233 18233

EXPOSE 8233 18233 $RPC_PORT

ARG SHORT_SHA
ENV SHORT_SHA $SHORT_SHA
Expand Down