-
Notifications
You must be signed in to change notification settings - Fork 54
Added docker image build script for k8s #206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Create a new builder to enable building multi-platform images | ||
| docker buildx create --use | ||
|
|
||
| # Image and Registry info | ||
| DOCKER_REGISTRY="bitcoindevproject/k8s-bitcoin-core" | ||
| REPO="bitcoin/bitcoin" | ||
| BUILD_ARGS="--disable-tests --with-incompatible-bdb --without-gui --disable-bench --disable-fuzz-binary --enable-suppress-external-warnings --without-miniupnpc --without-natpmp" | ||
| echo "DOCKER_REGISTRY=${DOCKER_REGISTRY}" | ||
| echo "REPO=${REPO}" | ||
|
|
||
| # Tags and their supported architectures | ||
| declare -A VERSION_ARCH_MAP=( | ||
| ["23.2"]="amd64 arm64 armhf" | ||
| ["24.2"]="amd64 arm64 armhf" | ||
| ["25.1"]="amd64 arm64 armhf" | ||
| ["26.0"]="amd64 arm64 armhf" | ||
| ) | ||
|
|
||
| if [[ -d "src/templates" ]]; then | ||
| cd src/templates || exit 1 | ||
| else | ||
| echo "Directory src/templates does not exist. Please run this script from the project root." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Loop through each tag and its architectures to build and push | ||
| for VERSION in "${!VERSION_ARCH_MAP[@]}"; do | ||
| IFS=' ' read -ra ARCHS <<< "${VERSION_ARCH_MAP[${VERSION}]}" | ||
| IMAGES_LIST=() # Array to store images for manifest | ||
| for DOCKER_ARCH in "${ARCHS[@]}"; do | ||
| echo "BRANCH=v${VERSION}" | ||
| echo "DOCKER_ARCH=${DOCKER_ARCH}" | ||
|
|
||
| IMAGE_TAG="${VERSION}-${DOCKER_ARCH}" | ||
| IMAGE_FULL_NAME="${DOCKER_REGISTRY}:${IMAGE_TAG}" | ||
| echo "IMAGE_FULL_NAME=${IMAGE_FULL_NAME}" | ||
|
|
||
| # Use Buildx to build the image for the specified architecture | ||
| docker buildx build --platform linux/"${DOCKER_ARCH}" \ | ||
| --provenance=false \ | ||
| --build-arg REPO="${REPO}" \ | ||
| --build-arg BRANCH="v${VERSION}" \ | ||
| --build-arg BUILD_ARGS="${BUILD_ARGS}" \ | ||
| --tag "${IMAGE_FULL_NAME}" \ | ||
| --file Dockerfile_k8 \ | ||
| . --push | ||
|
|
||
| IMAGES_LIST+=("${IMAGE_FULL_NAME}") | ||
| done | ||
|
|
||
| # Create the manifest list for each version under the same repository | ||
| MANIFEST_TAG="${DOCKER_REGISTRY}:${VERSION}" | ||
| docker buildx imagetools create --tag "${MANIFEST_TAG}" "${IMAGES_LIST[@]}" | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| FROM debian:bookworm-slim as builder | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| ARG ARCH | ||
| ARG REPO | ||
| ARG BRANCH | ||
| ARG BUILD_ARGS | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| wget \ | ||
| git \ | ||
| automake \ | ||
| autotools-dev \ | ||
| build-essential \ | ||
| libtool \ | ||
| libboost-dev \ | ||
| libevent-dev \ | ||
| libdb5.3++-dev \ | ||
| libminiupnpc-dev \ | ||
| libnatpmp-dev \ | ||
| libzmq3-dev \ | ||
| libqrencode-dev \ | ||
| libsqlite3-dev \ | ||
| pkg-config \ | ||
| && rm -rf /var/lib/apt/lists/* # Clean up to reduce image size | ||
|
|
||
| # Copy the patch into the container | ||
| COPY isroutable.patch /tmp/ | ||
|
|
||
| # Clone, patch, and build | ||
| RUN set -ex \ | ||
| && mkdir build \ | ||
| && cd build \ | ||
| && git clone --depth 1 --branch "${BRANCH}" "https://github.com/${REPO}" \ | ||
| && cd bitcoin \ | ||
| && git apply /tmp/isroutable.patch \ | ||
| && ./autogen.sh \ | ||
| && ./configure ${BUILD_ARGS} \ | ||
| && make -j$(nproc) \ | ||
| && make install | ||
|
|
||
| # Shrink image size with a second stage | ||
| FROM debian:bookworm-slim | ||
|
|
||
| ARG UID=3338 | ||
| ARG GID=3338 | ||
| ARG REPO | ||
| ARG TOR=0 | ||
| ARG WARNET=0 | ||
| ARG BITCOIN_ARGS | ||
| # env var overrides | ||
| ENV UID=$UID | ||
| ENV GID=$GID | ||
| ENV BITCOIN_DATA=/home/bitcoin/.bitcoin | ||
| ENV BITCOIN_ARGS=$BITCOIN_ARGS | ||
| ENV TOR=$TOR | ||
| ENV WARNET=$WARNET | ||
|
|
||
| RUN set -ex \ | ||
| && groupadd --gid ${GID} bitcoin \ | ||
| && useradd --create-home --no-log-init -u ${UID} -g ${GID} bitcoin \ | ||
| && apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| dnsutils \ | ||
| gosu \ | ||
| iproute2 \ | ||
| tor \ | ||
| $(if [ -n "${REPO}" ]; then echo "libboost-dev libevent-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev"; fi) \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/cache/apt/* /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=builder /usr/local/bin/bitcoind /usr/local/bin/bitcoin-cli /usr/local/bin/ | ||
| COPY entrypoint.sh /entrypoint.sh | ||
| # Warnet torrc using test network | ||
| COPY torrc /etc/tor/warnet-torr | ||
|
|
||
| VOLUME ["/home/bitcoin/.bitcoin"] | ||
| EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332 | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| RUN bitcoind -version | grep -E "Bitcoin Core( Daemon)? version ${BRANCH}" | ||
| CMD ["bitcoind"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| diff --git a/src/netaddress.cpp b/src/netaddress.cpp | ||
| index 7530334db1..b66cfe5c2f 100644 | ||
| --- a/src/netaddress.cpp | ||
| +++ b/src/netaddress.cpp | ||
| @@ -462,7 +462,7 @@ bool CNetAddr::IsValid() const | ||
| */ | ||
| bool CNetAddr::IsRoutable() const | ||
| { | ||
| - return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || IsRFC4193() || IsRFC4843() || IsRFC7343() || IsLocal() || IsInternal()); | ||
| + return IsValid() && !(IsLocal() || IsInternal()); | ||
| } | ||
|
|
||
| /** | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not specifying
--file Dockerfile_k8sso (for me) it was using the defaultDockerfile.This could be why @josibake observed networking not working? (perhaps patch not applied?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have been. I might have built and pushed the images and then renamed the Dockerfile but forgot to update it here. I might be misremembering but I thought I saw bitcoind compiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should re-push the images though as there is doubt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were the images re-pushed? if not no worries, was going to do it now as part of testing this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not re-push anything