Skip to content

Commit 247771c

Browse files
authored
Docker: make available as ARM64 (#538)
* CI: set up arm64 build * fee_estimates: clean up usage
1 parent 4f5c82f commit 247771c

7 files changed

+78
-114
lines changed

.gitlab-ci.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
variables:
2+
DOCKER_HOST: tcp://docker:2375
3+
DOCKER_TLS_CERTDIR: ""
4+
DOCKER_BUILDKIT: 1
25
CI_DISPOSABLE_ENVIRONMENT: "true"
36
BULLSEYE_IMAGE: debian:bullseye@sha256:4d6ab716de467aad58e91b1b720f0badd7478847ec7a18f66027d0f8a329a43c
47
IMAGE_BASE: blockstream/esplora-base
58
IMAGE: blockstream/esplora
69
DOCKERHUB_ESPLORA_URL: "https://hub.docker.com/v2/repositories/blockstream/esplora/tags/"
710

8-
stages:
9-
- build
10-
- plan
11-
- deploy
12-
1311
default:
14-
image: blockstream/gcloud-docker-tf:1.3.8
12+
image: docker:27
13+
services:
14+
- name: docker:27-dind
15+
command: ["dockerd", "--host=tcp://0.0.0.0:2375"]
16+
alias: "docker"
17+
before_script:
18+
- docker info
19+
- docker buildx create
20+
--driver=docker-container
21+
--name=buildkit-builder
22+
--use
23+
--platform linux/amd64,linux/arm64
1524
tags:
1625
- cloud
1726
retry:
@@ -21,8 +30,11 @@ default:
2130
- unknown_failure
2231
- stuck_or_timeout_failure
2332

33+
stages:
34+
- build
35+
2436
include:
25-
- gitlab/**.yaml
37+
- "gitlab/**.yml"
2638

2739
## disables MR-triggered pipelines and allows only branch-triggered pipelines
2840
workflow:

Dockerfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM blockstream/esplora-base:latest AS build
22

3-
FROM debian:bullseye@sha256:4d6ab716de467aad58e91b1b720f0badd7478847ec7a18f66027d0f8a329a43c
3+
FROM debian:bookworm-slim
44

55
COPY --from=build /srv/explorer /srv/explorer
66
COPY --from=build /srv/wally_wasm /srv/wally_wasm
@@ -20,9 +20,7 @@ WORKDIR /srv/explorer/source
2020

2121
SHELL ["/bin/bash", "-c"]
2222

23-
# required to run some scripts as root (needed for docker)
2423
RUN source /root/.nvm/nvm.sh \
25-
&& npm config set unsafe-perm true \
2624
&& npm install && (cd prerender-server && npm run dist) \
2725
&& DEST=/srv/explorer/static/bitcoin-mainnet \
2826
npm run dist -- bitcoin-mainnet \

Dockerfile.deps

+29-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Build libwally wasm files. Used for client-side blinding verification on Elements-based chains
22

3-
FROM greenaddress/wallycore@sha256:d63d222be12f6b2535e1548aa7f21cf649e2230d6c9e01bd518c23eb0bccd46f AS libwally-wasm
3+
FROM blockstream/wallycore@sha256:62cc52bd3ad9176b55cb486482368f858a4debee248a15d2fada0a62eb074a05 AS libwally-wasm
44
ARG NO_LIQUID
55
ENV EXPORTED_FUNCTIONS="['_malloc', '_free', '_wally_init','_wally_asset_value_commitment','_wally_asset_generator_from_bytes']"
66
ENV EXTRA_EXPORTED_RUNTIME_METHODS="['getValue', 'ccall']"
@@ -12,7 +12,7 @@ RUN sh -c '[ -n "$NO_LIQUID" ] && mkdir -p /wally/wally_dist || ( \
1212
&& git submodule sync --recursive && git submodule update --init --recursive \
1313
&& ./tools/build_wasm.sh --enable-elements)'
1414

15-
FROM debian:bullseye@sha256:4d6ab716de467aad58e91b1b720f0badd7478847ec7a18f66027d0f8a329a43c
15+
FROM debian:bookworm-slim
1616
SHELL ["/bin/bash", "-c"]
1717

1818
ENV CORE_BUILD_DEPS="autoconf autotools-dev automake libtool pkg-config bsdmainutils build-essential"
@@ -23,42 +23,37 @@ RUN mkdir -p /srv/explorer \
2323
&& apt-get -yqq install ${ESPLORA_BUILD_DEPS} tor ${CORE_BUILD_DEPS}
2424

2525

26-
RUN git clone --quiet --depth 1 --single-branch --branch v0.39.0 https://github.com/nvm-sh/nvm.git /root/.nvm \
26+
RUN git clone --quiet --depth 1 --single-branch --branch v0.40.1 https://github.com/nvm-sh/nvm.git /root/.nvm \
2727
&& rm -rf /root/.nvm/.git \
2828
&& source /root/.nvm/nvm.sh \
29-
&& nvm install v17.1.0
29+
&& nvm install v18.20.4
3030

31-
# Build core from sources until PR https://github.com/bitcoin/bitcoin/pull/23387 is merged
32-
ENV CORE_PATCH=contrib/0001-add-support-to-save-fee-estimates-without-shutting-d.patch
33-
ENV CORE_SRC=/root/bitcoin
34-
COPY ${CORE_PATCH} /${CORE_PATCH}
35-
RUN git clone --quiet --depth 1 --branch v24.1 --single-branch --recursive https://github.com/bitcoin/bitcoin.git ${CORE_SRC} \
36-
&& (cd ${CORE_SRC} \
37-
&& git checkout 3116ccd790e76de8f64d2ef9aa5a2641c15bbd8b \
38-
&& git apply /${CORE_PATCH} \
39-
&& (cd depends \
40-
&& make HOST=x86_64-pc-linux-gnu NO_QT=1 -j $(nproc --all)) \
41-
&& ./autogen.sh \
42-
&& CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure --prefix=/srv/explorer/bitcoin --disable-man --disable-zmq --disable-qt --disable-gui-tests --disable-bench \
43-
--enable-experimental-asm --without-utils --enable-util-cli --without-libs --with-daemon --disable-maintainer-mode \
44-
--disable-glibc-back-compat --disable-ccache --disable-dependency-tracking --disable-tests --with-gui=no \
45-
&& make -j $(nproc --all) \
46-
&& make install -j $(nproc --all) \
47-
&& strip /srv/explorer/bitcoin/bin/* \
48-
&& rm -fr ${CORE_SRC} /${CORE_PATCH})
31+
ARG TARGETARCH
32+
ENV SHA256SUM_ELEMENTS_X86_64="d1c0919955a1d50f2f1518e2ee27aa21fd5dd45cd481635d59fa453ff776dede"
33+
ENV SHA256SUM_ELEMENTS_ARM64="b6345394020486f7f8af111e2063f355571488cd8e8f384ed1082606c94e6c0d"
34+
ENV SHA256SUM_BITCOINCORE_X86_64="2a6974c5486f528793c79d42694b5987401e4a43c97f62b1383abf35bcee44a8"
35+
ENV SHA256SUM_BITCOINCORE_ARM64="cb35e250ae9d0328aa90e7aad0b877ed692597420a1092e8ab1a5dd756209722"
4936

50-
#ENV SHA256SUM_BITCOINCORE=59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16
51-
#ENV VERSION_BITCOINCORE=22.0
52-
#RUN curl -sL -o bitcoin.tar.gz "https://bitcoincore.org/bin/bitcoin-core-${VERSION_BITCOINCORE}/bitcoin-${VERSION_BITCOINCORE}-x86_64-linux-gnu.tar.gz" \
53-
# && echo "${SHA256SUM_BITCOINCORE} bitcoin.tar.gz" | sha256sum --check \
54-
# && tar xzf bitcoin.tar.gz -C /srv/explorer \
55-
# && ln -s "/srv/explorer/bitcoin-${VERSION_BITCOINCORE}" /srv/explorer/bitcoin \
56-
# && rm bitcoin.tar.gz
37+
ENV VERSION_BITCOINCORE=27.0
38+
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
39+
curl -sL -o bitcoin.tar.gz "https://bitcoincore.org/bin/bitcoin-core-${VERSION_BITCOINCORE}/bitcoin-${VERSION_BITCOINCORE}-aarch64-linux-gnu.tar.gz"; \
40+
echo "${SHA256SUM_BITCOINCORE_ARM64} bitcoin.tar.gz" | sha256sum --check; \
41+
else \
42+
curl -sL -o bitcoin.tar.gz "https://bitcoincore.org/bin/bitcoin-core-${VERSION_BITCOINCORE}/bitcoin-${VERSION_BITCOINCORE}-x86_64-linux-gnu.tar.gz"; \
43+
echo "${SHA256SUM_BITCOINCORE_X86_64} bitcoin.tar.gz" | sha256sum --check; \
44+
fi \
45+
&& tar xzf bitcoin.tar.gz -C /srv/explorer \
46+
&& ln -s "/srv/explorer/bitcoin-${VERSION_BITCOINCORE}" /srv/explorer/bitcoin \
47+
&& rm bitcoin.tar.gz
5748

58-
ENV SHA256SUM_ELEMENTS=67aca46c12b8a81c960798502f81463b18c54d3ebd5c0804b26f1a336d148042
59-
ENV VERSION_ELEMENTS=22.1.1
60-
RUN curl -sL -o elements.tar.gz "https://github.com/ElementsProject/elements/releases/download/elements-${VERSION_ELEMENTS}/elements-${VERSION_ELEMENTS}-x86_64-linux-gnu.tar.gz" \
61-
&& echo "${SHA256SUM_ELEMENTS} elements.tar.gz" | sha256sum --check \
49+
ENV VERSION_ELEMENTS=23.2.3
50+
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
51+
curl -sL -o elements.tar.gz "https://github.com/ElementsProject/elements/releases/download/elements-${VERSION_ELEMENTS}/elements-${VERSION_ELEMENTS}-aarch64-linux-gnu.tar.gz"; \
52+
echo "${SHA256SUM_ELEMENTS_ARM64} elements.tar.gz" | sha256sum --check; \
53+
else \
54+
curl -sL -o elements.tar.gz "https://github.com/ElementsProject/elements/releases/download/elements-${VERSION_ELEMENTS}/elements-${VERSION_ELEMENTS}-x86_64-linux-gnu.tar.gz"; \
55+
echo "${SHA256SUM_ELEMENTS_X86_64} elements.tar.gz" | sha256sum --check; \
56+
fi \
6257
&& tar xzf elements.tar.gz -C /srv/explorer \
6358
&& ln -s "/srv/explorer/elements-${VERSION_ELEMENTS}" /srv/explorer/liquid \
6459
&& mv /srv/explorer/liquid/bin/{elementsd,liquidd} \
@@ -94,4 +89,4 @@ RUN apt-get --auto-remove remove -yqq --purge ${ESPLORA_BUILD_DEPS} manpages ${C
9489
&& apt-get autoclean \
9590
&& rm -rf /usr/share/doc* /usr/share/man /usr/share/postgresql/*/man /var/lib/apt/lists/* /var/cache/* /tmp/* /root/.cache /*.deb /root/.cargo
9691

97-
COPY --from=libwally-wasm /wally/wally_dist /srv/wally_wasm
92+
COPY --from=libwally-wasm /wally/wally_dist /srv/wally_wasm

contrib/nginx-sync.conf.in

+1-20
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,10 @@ location = /{NGINX_PATH}_sync/mempool {
99
}
1010
}
1111

12-
# Dump the current mempool and return it
13-
location = /{NGINX_PATH}_sync/fee_estimates {
14-
auth_basic "private";
15-
auth_basic_user_file /srv/explorer/htpasswd;
16-
17-
content_by_lua_block {
18-
os.execute("/usr/bin/cli savefeeestimates");
19-
ngx.exec("/{NGINX_PATH}_sync/fee_estimates.dat");
20-
}
21-
}
22-
2312
# Return mempool.dat without dumping it first, used as an internal redirect
2413
# from the location block above
2514
location = /{NGINX_PATH}_sync/mempool.dat {
2615
auth_basic "private";
2716
auth_basic_user_file /srv/explorer/htpasswd;
2817
alias {DAEMON_DIR}/mempool.dat;
29-
}
30-
31-
# Return fee_estimates.dat without dumping it first, used as an internal redirect
32-
# from the location block above
33-
location = /{NGINX_PATH}_sync/fee_estimates.dat {
34-
auth_basic "private";
35-
auth_basic_user_file /srv/explorer/htpasswd;
36-
alias {DAEMON_DIR}/fee_estimates.dat;
37-
}
18+
}

gitlab/build.yaml gitlab/build.yml

+27-34
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
1+
build_base:
2+
stage: build
3+
rules:
4+
- if: $CI_COMMIT_BRANCH
5+
changes:
6+
paths:
7+
- Dockerfile.deps
8+
compare_to: master
9+
script:
10+
- docker buildx build
11+
--platform linux/amd64,linux/arm64
12+
--push
13+
-f Dockerfile.deps
14+
--build-arg BUILDKIT_INLINE_CACHE=1
15+
--cache-from ${IMAGE_BASE}:latest
16+
-t ${IMAGE_BASE}:$CI_COMMIT_SHA
17+
-t ${IMAGE_BASE}:latest
18+
.
19+
120
test_docker_build_esplora:
2-
extends: .build_setup
21+
stage: build
322
script:
4-
- docker pull ${IMAGE}:latest || true
5-
- docker build
6-
--network=host
23+
- docker buildx build
24+
--platform linux/amd64,linux/arm64
725
--build-arg BUILDKIT_INLINE_CACHE=1
826
--cache-from ${IMAGE}:latest
927
-f Dockerfile
1028
-t ${IMAGE} .
11-
- docker rmi ${IMAGE} || true
1229

1330
build_esplora:
14-
extends: .build_setup
31+
stage: build
1532
when: manual
1633
script:
1734
- curl -s "${DOCKERHUB_ESPLORA_URL}" | grep -q "$CI_COMMIT_SHA" || (
1835
sed -i "s#esplora-base:latest#esplora-base:${BASE_TAG}#" Dockerfile
19-
&& docker pull ${IMAGE}:latest
20-
&& docker build
21-
--network=host
36+
&& docker buildx build
37+
--platform linux/amd64,linux/arm64
38+
--push
2239
--build-arg BUILDKIT_INLINE_CACHE=1
2340
--build-arg FOOT_HTML='<!-- '"$CI_COMMIT_SHA"' -->'
2441
--cache-from ${IMAGE}:latest
2542
-t ${IMAGE}:latest
26-
-t ${IMAGE}:$CI_COMMIT_SHA .
27-
&& docker push ${IMAGE}:$CI_COMMIT_SHA)
43+
-t ${IMAGE}:$CI_COMMIT_SHA .)
2844
- if [ $CI_COMMIT_BRANCH == "master" ]; then docker pull ${IMAGE}:$CI_COMMIT_SHA; docker tag ${IMAGE}:$CI_COMMIT_SHA ${IMAGE}:latest; docker push ${IMAGE}:latest; fi
29-
30-
build_base:
31-
extends: .build_setup
32-
rules:
33-
- if: $CI_COMMIT_BRANCH
34-
changes:
35-
paths:
36-
- Dockerfile.deps
37-
compare_to: master
38-
script:
39-
- docker pull ${BULLSEYE_IMAGE} || true
40-
- docker pull ${IMAGE_BASE}:latest || true
41-
- >
42-
docker build
43-
-f Dockerfile.deps
44-
--network=host
45-
--build-arg BUILDKIT_INLINE_CACHE=1
46-
--cache-from ${IMAGE_BASE}:latest
47-
-t ${IMAGE_BASE}:$CI_COMMIT_SHA
48-
-t ${IMAGE_BASE}:latest
49-
.
50-
- docker push ${IMAGE_BASE}:$CI_COMMIT_SHA
51-
- docker push ${IMAGE_BASE}:latest

gitlab/functions.yaml

-14
This file was deleted.

run.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ if [ -n "$SYNC_SOURCE" ]; then
298298
sleep 2 # without this, the download below would occasionally start while the terminating bitcoind is still flushing its mempool.dat
299299
# then fetch a recent mempool.dat,
300300
curl -v -u sync:$SYNC_SECRET -o $DAEMON_DIR/mempool.dat $SYNC_SOURCE/mempool || true
301-
curl -v -u sync:$SYNC_SECRET -o $DAEMON_DIR/fee_estimates.dat $SYNC_SOURCE/fee_estimates || true
302-
ls -l $DAEMON_DIR/{mempool,fee_estimates}.dat || true
301+
ls -l $DAEMON_DIR/{mempool}.dat || true
303302
# and let the runit services take over
304303
fi
305304

0 commit comments

Comments
 (0)