Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/imagebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
--build-arg COMMIT_SHA=v$tag \
--build-arg BUILD_ARGS='-DBUILD_TESTS=OFF -DBUILD_GUI=OFF -DBUILD_BENCH=OFF -DBUILD_UTIL=ON -DBUILD_FUZZ_BINARY=OFF -DWITH_ZMQ=ON' \
-t bitcoindevproject/bitcoin:$tag \
--file resources/images/bitcoin/Dockerfile.dev \
--file resources/images/bitcoin/Dockerfile.cmake \
resources/images/bitcoin/ \
--push
done
230 changes: 0 additions & 230 deletions docker-bake.hcl

This file was deleted.

28 changes: 1 addition & 27 deletions docs/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,5 @@ python3 -m twine upload dist/*

## Building docker images

The Bitcoin Core docker images used by warnet are specified in the *docker-bake.hcl* file.
This uses the (experimental) `bake` build functionality of docker buildx.
We use [HCL language](https://github.com/hashicorp/hcl) in the declaration file itself.
See the `bake` [documentation](https://docs.docker.com/build/bake/) for more information on specifications, and how to e.g. override arguments.
See [docs for `warnet image build` command](./warnet.md#warnet-image-build)

In order to build (or "bake") a certain image, find the image's target (name) in the *docker-bake.hcl* file, and then run `docker buildx bake <target>`.

```bash
# build the dummy image that will crash on 5k invs
docker buildx bake bitcoin-5k-inv

# build the same image, but set platform to only linux/amd64
docker buildx bake bitcoin-5k-inv --set bitcoin-5k-inv.platform=linux/amd64
```

To load the single-platform build result to `docker images`, run:

```bash
docker buildx bake --load bitcoin-5k-inv
```

Push the build result to a registry by running:

```bash
docker buildx bake --push bitcoin-5k-inv
```

It will automatically push the build result to registry.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setup deps stage
FROM alpine AS deps
FROM alpine:3.20 AS deps
ARG REPO
ARG COMMIT_SHA
ARG BUILD_ARGS
Expand All @@ -20,7 +20,8 @@ RUN --mount=type=cache,target=/var/cache/apk \
libtool \
linux-headers \
sqlite-dev \
zeromq-dev
zeromq-dev \
db-dev

COPY isroutable.patch /tmp/
COPY addrman.patch /tmp/
Expand All @@ -31,19 +32,37 @@ FROM deps AS build
ENV BITCOIN_PREFIX=/opt/bitcoin
WORKDIR /build

# Assume $COMMIT_SHA is a git commit but if that fails, then
# assume it is a release tag that can be checked out
RUN set -ex \
&& cd /build \
&& git clone --depth 1 "https://github.com/${REPO}" \
&& cd bitcoin \
&& git fetch --depth 1 origin "$COMMIT_SHA" \
&& git checkout "$COMMIT_SHA" \
&& git apply /tmp/isroutable.patch \
&& git apply /tmp/addrman.patch \
&& sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h \
&& git init \
&& git remote add origin "https://github.com/${REPO}" \
# Try commit/branch first
&& if git fetch --depth 1 origin "$COMMIT_SHA:refs/temp/ref" 2>/dev/null; then \
REF=refs/temp/ref; \
else \
# Fallback: fetch tag explicitly into local refs
git fetch --depth 1 origin "refs/tags/$COMMIT_SHA:refs/tags/$COMMIT_SHA"; \
REF="refs/tags/$COMMIT_SHA"; \
fi \
# Resolve tag -> commit if needed
&& resolved=$(git rev-parse --verify "$REF^{commit}") \
&& git checkout "$resolved" \
# Build
&& git apply /tmp/isroutable.patch || true \
&& git apply /tmp/addrman.patch || true \
&& sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h || true \
&& ./autogen.sh \
&& DB_PREFIX="$(ls -d /opt/db-* 2>/dev/null | head -n1 || true)" \
&& if [ -n "$DB_PREFIX" ] && [ -d "$DB_PREFIX/lib" ]; then \
export LDFLAGS="-L${DB_PREFIX}/lib"; \
export CPPFLAGS="-g0 -I${DB_PREFIX}/include --param ggc-min-expand=1 --param ggc-min-heapsize=32768"; \
else \
export LDFLAGS=""; \
export CPPFLAGS="-g0 --param ggc-min-expand=1 --param ggc-min-heapsize=32768"; \
fi \
&& ./configure \
LDFLAGS=-L`ls -d /opt/db*`/lib/ \
CPPFLAGS="-g0 -I`ls -d /opt/db*`/include/ --param ggc-min-expand=1 --param ggc-min-heapsize=32768" \
--prefix=${BITCOIN_PREFIX} \
${BUILD_ARGS} \
&& make -j$(nproc) \
Expand All @@ -56,8 +75,7 @@ RUN set -ex \
&& rm ${BITCOIN_PREFIX}/bin/bitcoin-wallet \
&& rm ${BITCOIN_PREFIX}/bin/bitcoin-util

# Final clean stage
FROM alpine
FROM alpine:3.20
ARG UID=100
ARG GID=101
ENV BITCOIN_DATA=/root/.bitcoin
Expand All @@ -84,4 +102,3 @@ EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bitcoind"]

Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@ RUN set -ex \
&& cd /build \
&& git init \
&& git remote add origin "https://github.com/${REPO}" \

# Try commit/branch first
&& if git fetch --depth 1 origin "$COMMIT_SHA:refs/temp/ref" 2>/dev/null; then \
REF=refs/temp/ref; \
else \

# Fallback: fetch tag explicitly into local refs
git fetch --depth 1 origin "refs/tags/$COMMIT_SHA:refs/tags/$COMMIT_SHA"; \
REF="refs/tags/$COMMIT_SHA"; \
fi \

# Resolve tag -> commit if needed
&& resolved=$(git rev-parse --verify "$REF^{commit}") \
&& git checkout "$resolved" \

# Build
&& git apply /tmp/isroutable.patch \
&& git apply /tmp/addrman.patch \
&& sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h \
Expand All @@ -66,7 +63,6 @@ RUN set -ex \
&& rm -f ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a \
&& rm -f ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0

# Final clean stage
FROM alpine:3.20
ARG UID=100
ARG GID=101
Expand Down
Loading
Loading