feat(release): create Docker hub binary with mining enabled on release (#6228)
* Duplicates Dockerfile * updates mining-testnet Dockerfile with getblocktemplate-rpcs feature, Testnet by default, and an RPC port * renames mining-testnet.Dockerfile and adds workflow for publishing images on release * replaces space-seperated features with commas * Adds .experimental tag suffix, removes new dockerfile, makes lightwalletd tests conditional * updates build-args to pass on features directly * adds "lightwalletd-grpc-tests" as default test_features in build-docker-image * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> * adds tag suffix to cache keys --------- Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
571cbfba7a
commit
671420bd84
|
|
@ -37,6 +37,20 @@ on:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: info
|
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:
|
outputs:
|
||||||
image_digest:
|
image_digest:
|
||||||
description: 'The image digest to be used on a caller workflow'
|
description: 'The image digest to be used on a caller workflow'
|
||||||
|
|
@ -72,6 +86,9 @@ jobs:
|
||||||
images: |
|
images: |
|
||||||
us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}
|
us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}
|
||||||
zfnd/zebra,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
|
zfnd/zebra,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
|
||||||
|
# appends inputs.tag_suffix to image tags/names
|
||||||
|
flavor: |
|
||||||
|
suffix=${{ inputs.tag_suffix }}
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=schedule
|
type=schedule
|
||||||
|
|
@ -145,6 +162,9 @@ jobs:
|
||||||
ZEBRA_SKIP_IPV6_TESTS=${{ inputs.zebra_skip_ipv6_tests }}
|
ZEBRA_SKIP_IPV6_TESTS=${{ inputs.zebra_skip_ipv6_tests }}
|
||||||
CHECKPOINT_SYNC=${{ inputs.checkpoint_sync }}
|
CHECKPOINT_SYNC=${{ inputs.checkpoint_sync }}
|
||||||
RUST_LOG=${{ inputs.rust_log }}
|
RUST_LOG=${{ inputs.rust_log }}
|
||||||
|
FEATURES=${{ inputs.features }}
|
||||||
|
TEST_FEATURES=${{ inputs.test_features }}
|
||||||
|
RPC_PORT=${{ inputs.rpc_port }}
|
||||||
push: true
|
push: true
|
||||||
# To improve build speeds, for each branch we push an additional image to the registry,
|
# 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.
|
# to be used as the caching layer, using the `max` caching mode.
|
||||||
|
|
@ -157,7 +177,7 @@ jobs:
|
||||||
# The caches are tried in top-down order, the first available cache is used:
|
# The caches are tried in top-down order, the first available cache is used:
|
||||||
# https://github.com/moby/moby/pull/26839#issuecomment-277383550
|
# https://github.com/moby/moby/pull/26839#issuecomment-277383550
|
||||||
cache-from: |
|
cache-from: |
|
||||||
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache
|
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:${{ env.GITHUB_REF_SLUG_URL }}-cache
|
||||||
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:main-cache
|
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:main-cache
|
||||||
cache-to: |
|
cache-to: |
|
||||||
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache,mode=max
|
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:${{ env.GITHUB_REF_SLUG_URL }}-cache,mode=max
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
# Each time this workflow is executed, a build will be triggered to create a new image
|
# Each time this workflow is executed, a build will be triggered to create a new image
|
||||||
# with the corresponding tags using information from git
|
# with the corresponding tags using information from git
|
||||||
#
|
|
||||||
# The image will be named `zebrad:<semver>`
|
# The image will be named `zebrad:<semver>`
|
||||||
build:
|
build:
|
||||||
name: Build Release Docker
|
name: Build Release Docker
|
||||||
|
|
@ -33,3 +33,24 @@ jobs:
|
||||||
rust_log: info
|
rust_log: info
|
||||||
# This step needs access to Docker Hub secrets to run successfully
|
# This step needs access to Docker Hub secrets to run successfully
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
|
# The image will be named `zebrad-mining-rpcs-testnet:<semver>.experimental`
|
||||||
|
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
|
||||||
|
# TODO: change this to `-experimental` when we release Zebra `1.0.0`
|
||||||
|
tag_suffix: .experimental
|
||||||
|
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
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,10 @@ ENV ZEBRA_SKIP_IPV6_TESTS ${ZEBRA_SKIP_IPV6_TESTS:-1}
|
||||||
ARG CHECKPOINT_SYNC
|
ARG CHECKPOINT_SYNC
|
||||||
ENV CHECKPOINT_SYNC ${CHECKPOINT_SYNC:-true}
|
ENV CHECKPOINT_SYNC ${CHECKPOINT_SYNC:-true}
|
||||||
|
|
||||||
|
# Build zebrad with these features
|
||||||
|
ARG FEATURES
|
||||||
|
ARG TEST_FEATURES="lightwalletd-grpc-tests"
|
||||||
|
|
||||||
ARG NETWORK
|
ARG NETWORK
|
||||||
ENV NETWORK ${NETWORK:-Mainnet}
|
ENV NETWORK ${NETWORK:-Mainnet}
|
||||||
|
|
||||||
|
|
@ -100,10 +104,10 @@ COPY --from=us-docker.pkg.dev/zealous-zebra/zebra/lightwalletd /opt/lightwalletd
|
||||||
# This is the caching Docker layer for Rust!
|
# This is the caching Docker layer for Rust!
|
||||||
#
|
#
|
||||||
# TODO: is it faster to use --tests here?
|
# 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 . .
|
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
|
RUN cp /opt/zebrad/target/release/zebrad /usr/local/bin
|
||||||
|
|
||||||
COPY ./docker/entrypoint.sh /
|
COPY ./docker/entrypoint.sh /
|
||||||
|
|
@ -118,11 +122,11 @@ ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
# `test` stage. This step is a dependency for the `runtime` stage, which uses the resulting
|
# `test` stage. This step is a dependency for the `runtime` stage, which uses the resulting
|
||||||
# zebrad binary from this step.
|
# zebrad binary from this step.
|
||||||
FROM deps AS release
|
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 . .
|
COPY . .
|
||||||
# Build zebra
|
# 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
|
# This stage is only used when deploying nodes or when only the resulting zebrad binary is needed
|
||||||
#
|
#
|
||||||
|
|
@ -138,6 +142,7 @@ RUN apt-get update && \
|
||||||
|
|
||||||
ARG CHECKPOINT_SYNC=true
|
ARG CHECKPOINT_SYNC=true
|
||||||
ARG NETWORK=Mainnet
|
ARG NETWORK=Mainnet
|
||||||
|
ARG RPC_PORT
|
||||||
|
|
||||||
# Use a configurable dir and file for the zebrad configuration file
|
# Use a configurable dir and file for the zebrad configuration file
|
||||||
ARG ZEBRA_CONF_DIR=/etc/zebra
|
ARG ZEBRA_CONF_DIR=/etc/zebra
|
||||||
|
|
@ -169,12 +174,13 @@ RUN set -ex; \
|
||||||
{ \
|
{ \
|
||||||
echo "[network]"; \
|
echo "[network]"; \
|
||||||
echo "network = '${NETWORK}'"; \
|
echo "network = '${NETWORK}'"; \
|
||||||
|
echo "listen_addr = '127.0.0.1'"; \
|
||||||
echo "[consensus]"; \
|
echo "[consensus]"; \
|
||||||
echo "checkpoint_sync = ${CHECKPOINT_SYNC}"; \
|
echo "checkpoint_sync = ${CHECKPOINT_SYNC}"; \
|
||||||
echo "[state]"; \
|
echo "[state]"; \
|
||||||
echo "cache_dir = '/zebrad-cache'"; \
|
echo "cache_dir = '/zebrad-cache'"; \
|
||||||
echo "[rpc]"; \
|
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 "parallel_cpu_threads = 0"; \
|
||||||
echo "[metrics]"; \
|
echo "[metrics]"; \
|
||||||
echo "#endpoint_addr = '127.0.0.1:9999'"; \
|
echo "#endpoint_addr = '127.0.0.1:9999'"; \
|
||||||
|
|
@ -182,7 +188,8 @@ RUN set -ex; \
|
||||||
echo "#endpoint_addr = '127.0.0.1:3000'"; \
|
echo "#endpoint_addr = '127.0.0.1:3000'"; \
|
||||||
} > "${ZEBRA_CONF_PATH}"
|
} > "${ZEBRA_CONF_PATH}"
|
||||||
|
|
||||||
EXPOSE 8233 18233
|
|
||||||
|
EXPOSE 8233 18233 $RPC_PORT
|
||||||
|
|
||||||
ARG SHORT_SHA
|
ARG SHORT_SHA
|
||||||
ENV SHORT_SHA $SHORT_SHA
|
ENV SHORT_SHA $SHORT_SHA
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue