Skip to content

fix: auto-detect CMake vs autotools for warnet image build#801

Open
b-l-u-e wants to merge 2 commits intobitcoin-dev-project:mainfrom
b-l-u-e:fix/769-warnet-image-build-cmake-autotools
Open

fix: auto-detect CMake vs autotools for warnet image build#801
b-l-u-e wants to merge 2 commits intobitcoin-dev-project:mainfrom
b-l-u-e:fix/769-warnet-image-build-cmake-autotools

Conversation

@b-l-u-e
Copy link
Copy Markdown
Contributor

@b-l-u-e b-l-u-e commented Apr 8, 2026

warnet image build now chooses the Bitcoin Core build path automatically:

  • CMake when CMakeLists.txt exists at the given ref on raw.githubusercontent.com - Dockerfile.cmake and default CMake BUILD_ARGS.
  • Autotools otherwise - Dockerfile.autotools and default autotools BUILD_ARGS.

Users can still override with --build-args.

  • Removed docker-bake.hcl and the Docker bake section from docs/developer-notes.md in favor of on-the-fly builds via the CLI.

Dockerfiles

  • Renamed: DockerfileDockerfile.autotools, Dockerfile.dev - Dockerfile.cmake.
  • After shallow git fetch, use git checkout FETCH_HEAD so tags (e.g. v26.0) work (Dockerfile.cmake, Dockerfile.autotools, insecure/Dockerfile).
  • Autotools: pin alpine:3.20; set Berkeley DB LDFLAGS/CPPFLAGS only when /opt/db-* exists.

Testing

  • warnet image build with bitcoin/bitcoin, --commit-sha master (cmake) and v26.0 (autotools), --arches amd64, --action load both produced loadable images locally.

This Closes #769.

@pinheadmz
Copy link
Copy Markdown
Contributor

pinheadmz commented Apr 22, 2026

rebased on main and tweaked a few things: https://github.com/pinheadmz/warnet/tree/fix/769-warnet-image-build-cmake-autotools

If you allow maintainers to edit your branch I can just push my suggestions

Comment thread src/warnet/image_build.py
Probes the GitHub raw content URL for CMakeLists.txt at the given commit.
Returns 'cmake' if found, 'autotools' otherwise.
"""
url = f"https://raw.githubusercontent.com/{repo}/{commit_sha}/CMakeLists.txt"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this works. did you test it? provide examples please

@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented Apr 23, 2026

If you allow maintainers to edit your branch I can just push my suggestions
sorry about that i allowed now

@pinheadmz pinheadmz force-pushed the fix/769-warnet-image-build-cmake-autotools branch from 5247c69 to 59ad685 Compare April 23, 2026 13:54
@pinheadmz
Copy link
Copy Markdown
Contributor

okay thanks, pushing my changes. I still think the URL to check for cmakelists is wrong, my local testing always falls back to autotools

@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented Apr 23, 2026

okay thanks, pushing my changes. I still think the URL to check for cmakelists is wrong, my local testing always falls back to autotools

let me recheck on this again

@b-l-u-e b-l-u-e force-pushed the fix/769-warnet-image-build-cmake-autotools branch from 59ad685 to 96ddf6b Compare April 23, 2026 15:01
@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented Apr 23, 2026

I re-tested and tightened the behavior is explicit.

raw.githubusercontent.com/{repo}/{ref}/CMakeLists.txt

  • HTTP 200 means CMakeLists.txt exists at that ref → use Dockerfile.cmake
  • HTTP 404 means that file does not exist at that ref (expected for older releases) → use Dockerfile.autotools

verified

  • v31.0HTTP 200 -> cmake and Using Dockerfile: .../Dockerfile.cmake
  • v26.0HTTP 404 -> autotools and Using Dockerfile: .../Dockerfile.autotools

warnet image build \
  --repo bitcoin/bitcoin \
  --commit-sha v31.0 \
  --tags bitcoindevproject/bitcoin:test-cmake \
  --arches amd64 \
  --action load
Detecting build system: GET https://raw.githubusercontent.com/bitcoin/bitcoin/v31.0/CMakeLists.txt
  HTTP 200 -> cmake
Detected build system: cmake
repo=bitcoin/bitcoin
commit_sha=v31.0
tags=bitcoindevproject/bitcoin:test-cmake
build_args="-DBUILD_TESTS=OFF -DBUILD_GUI=OFF -DBUILD_BENCH=OFF -DBUILD_UTIL=ON -DBUILD_FUZZ_BINARY=OFF -DWITH_ZMQ=ON "
build_arches=['amd64']
Using Dockerfile: /home/user/projects/warnet/resources/images/bitcoin/Dockerfile.cmake
bitcoind-builder
tag_args='--tag bitcoindevproject/bitcoin:test-cmake'
Using build_command='docker buildx build --platform linux/amd64 --build-arg REPO=bitcoin/bitcoin --build-arg COMMIT_SHA=v31.0 --build-arg BUILD_ARGS="-DBUILD_TESTS=OFF -DBUILD_GUI=OFF -DBUILD_BENCH=OFF -DBUILD_UTIL=ON -DBUILD_FUZZ_BINARY=OFF -DWITH_ZMQ=ON " --tag bitcoindevproject/bitcoin:test-cmake --file /home/user/projects/warnet/resources/images/bitcoin/Dockerfile.cmake /home/user/projects/warnet/resources/images/bitcoin --load'
[+] Building 237.4s (12/15)                                           docker-container:bitcoind-builder
 => WARN: NoEmptyContinuation: Empty continuation line (line 68)                                   0.0s
 => [internal] load .dockerignore     
 

warnet image build \
 --repo bitcoin/bitcoin \
 --commit-sha v26.0 \
 --tags bitcoindevproject/bitcoin:test-autotools \
 --arches amd64 \
 --action load
Detecting build system: GET https://raw.githubusercontent.com/bitcoin/bitcoin/v26.0/CMakeLists.txt
 HTTP 404 -> autotools
Detected build system: autotools
repo=bitcoin/bitcoin
commit_sha=v26.0
tags=bitcoindevproject/bitcoin:test-autotools
build_args="--disable-tests --without-gui --disable-bench --disable-fuzz-binary --enable-suppress-external-warnings "
build_arches=['amd64']
Using Dockerfile: /home/user/projects/warnet/resources/images/bitcoin/Dockerfile.autotools
ERROR: existing instance for "bitcoind-builder" but no append mode, specify the node name to make changes for existing instances
tag_args='--tag bitcoindevproject/bitcoin:test-autotools'
Using build_command='docker buildx build --platform linux/amd64 --build-arg REPO=bitcoin/bitcoin --build-arg COMMIT_SHA=v26.0 --build-arg BUILD_ARGS="--disable-tests --without-gui --disable-bench --disable-fuzz-binary --enable-suppress-external-warnings " --tag bitcoindevproject/bitcoin:test-autotools --file /home/user/projects/warnet/resources/images/bitcoin/Dockerfile.autotools /home/user/projects/warnet/resources/images/bitcoin --load'
[+] Building 2.9s (6/14)                                              docker-container:bitcoind-builder
=> [internal] load build definition from Dockerfile.autotools                                     0.0s
=> => transferring dockerfile: 3.25kB                                                             0.0s
=> WARN: NoEmptyContinuation: Empty continuation line (line 79)                                   0.0s
=> [internal] load metadata for docker.io/library/alpine:3.20                                     1.2s
=> [internal] load .dockerignore                                                                  0.0s
=> => transferring context: 2B         

Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
@pinheadmz pinheadmz force-pushed the fix/769-warnet-image-build-cmake-autotools branch from 96ddf6b to 9710f90 Compare April 23, 2026 20:20
@pinheadmz
Copy link
Copy Markdown
Contributor

add berkeley db to the legacy (autotools) builds and made our addrman / isroutable hacks optional

@pinheadmz
Copy link
Copy Markdown
Contributor

Seems to work with tags but not actual commits. Sorry thats my fault, introduced very recently in #804

This one is wrong:

$ warnet image build --repo pinheadmz/bitcoin --commit-sha e7c6e6eba631306a287da8c9a4603fbb41df4498 --tags warnet/bitcoin:http-rewrite --action load --arches amd64
Detecting build system: GET https://raw.githubusercontent.com/pinheadmz/bitcoin/e7c6e6eba631306a287da8c9a4603fbb41df4498/CMakeLists.txt
  HTTP 404 -> autotools

but this worked which is great:

$ warnet image build --repo bitcoin/bitcoin --commit-sha v31.0rc1 --tags warnet/bitcoin:v31.0rc1 --action load --arches amd64
Detecting build system: GET https://raw.githubusercontent.com/bitcoin/bitcoin/v31.0rc1/CMakeLists.txt
  HTTP 200 -> cmake

and

$  warnet image build --repo bitcoin/bitcoin --commit-sha v0.21.0 --tags warnet/bitcoin:v0.21.0 --action load --arches arm64
Detecting build system: GET https://raw.githubusercontent.com/bitcoin/bitcoin/v0.21.0/CMakeLists.txt
  HTTP 404 -> autotools

@b-l-u-e b-l-u-e force-pushed the fix/769-warnet-image-build-cmake-autotools branch from 9710f90 to 8f6b2d5 Compare April 24, 2026 19:55
Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
@b-l-u-e b-l-u-e force-pushed the fix/769-warnet-image-build-cmake-autotools branch from 8f6b2d5 to e07c5e7 Compare April 24, 2026 20:03
@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented Apr 24, 2026

Seems to work with tags but not actual commits. Sorry thats my fault, introduced very recently in #804

This one is wrong:

$ warnet image build --repo pinheadmz/bitcoin --commit-sha e7c6e6eba631306a287da8c9a4603fbb41df4498 --tags warnet/bitcoin:http-rewrite --action load --arches amd64
Detecting build system: GET https://raw.githubusercontent.com/pinheadmz/bitcoin/e7c6e6eba631306a287da8c9a4603fbb41df4498/CMakeLists.txt
  HTTP 404 -> autotools

thanks for the review updated the detection now missing or invalid ref fails instead of selecting autotools

warnet image build --repo pinheadmz/bitcoin --commit-sha
 e7c6e6eba631306a287da8c9a4603fbb41df4498 --tags warnet/bitcoin:http-rewrite --action load --arch
es amd64
Detecting build system: GET https://raw.githubusercontent.com/pinheadmz/bitcoin/e7c6e6eba631306a287da8c9a4603fbb41df4498/CMakeLists.txt
Error: Ref not found in pinheadmz/bitcoin: e7c6e6eba631306a287da8c9a4603fbb41df4498

@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented Apr 24, 2026

noticed the doc is stale for ruff version:

$ uv tool install ruff@0.11.0
# lint
$ uvx ruff@0.11.0 check .
# format
$ uvx ruff@0.11.0 format .

https://github.com/bitcoin-dev-project/warnet/actions/runs/24909352604/job/72946772048?pr=801
Ruff version is 0.15.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warnet image build should automatically switch to cmake/autotools

2 participants