Skip to content

Commit 0432c1c

Browse files
committed
feat: add bitcoin core v28.0
1 parent fad635b commit 0432c1c

File tree

8 files changed

+465
-9
lines changed

8 files changed

+465
-9
lines changed

.github/workflows/bitcoin_core.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525
# context: "./25/alpine/tor"
2626
- name: 25-debian
2727
context: "./25/debian"
28-
- name: latest
29-
context: "./25/debian"
3028
- name: 25-ubuntu
3129
context: "./25/ubuntu"
3230
- name: 25-lightninglabs-alpine
@@ -35,8 +33,6 @@ jobs:
3533
context: "./26/alpine"
3634
- name: 26-debian
3735
context: "./26/debian"
38-
- name: latest
39-
context: "./26/debian"
4036
- name: 26-ubuntu
4137
context: "./26/ubuntu"
4238
- name: 26-lightninglabs-alpine
@@ -45,12 +41,14 @@ jobs:
4541
context: "./27/alpine"
4642
- name: 27-debian
4743
context: "./27/debian"
44+
- name: 28-alpine
45+
context: "./28/alpine"
46+
- name: 28-debian
47+
context: "./28/debian"
48+
- name: 28-ubuntu
49+
context: "./28/ubuntu"
4850
- name: latest
49-
context: "./27/debian"
50-
- name: 27-ubuntu
51-
context: "./27/ubuntu"
52-
#- name: 27-lightninglabs-alpine
53-
# context: "./27/alpine/lightninglabs"
51+
context: "./28/alpine"
5452
steps:
5553
- name: Checkout
5654
uses: actions/checkout@v4

28/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# Bitcoin Core Docker Image
3+
[![bitcoin_core](https://github.com/geekwho-eth/docker-bitcoin-core/actions/workflows/bitcoin_core.yaml/badge.svg)](https://github.com/geekwho-eth/docker-bitcoin-core/actions/workflows/bitcoin_core.yaml)
4+
[![Docker Pulls](https://img.shields.io/docker/pulls/caijiamx/bitcoin-core.svg)](https://hub.docker.com/r/caijiamx/bitcoin-core)
5+
[![Docker Stars](https://img.shields.io/docker/stars/caijiamx/bitcoin-core.svg)](https://hub.docker.com/r/caijiamx/bitcoin-core)
6+
[![Docker Image Size (latest)](https://img.shields.io/docker/image-size/caijiamx/bitcoin-core/latest.svg)](https://hub.docker.com/r/caijiamx/bitcoin-core)
7+
8+
This Docker image is built to run Bitcoin Core, leveraging a multi-stage build process.
9+
10+
## Bitcoin Core Tags
11+
12+
- `28.0-ubuntu`, `28-ubuntu`, `latest` ([28/ubuntu/Dockerfile](https://github.com/geekwho-eth/docker-bitcoin-core/blob/master/28/ubuntu/Dockerfile))
13+
- `28.0-debian`, `28-debian`, `latest` ([28/debian/Dockerfile](https://github.com/geekwho-eth/docker-bitcoin-core/blob/master/28/debian/Dockerfile))
14+
- `28.0-alpine`, `28-alpine` ([28/alpine/Dockerfile](https://github.com/geekwho-eth/docker-bitcoin-core/blob/master/28/alpine/Dockerfile))
15+
- `28.0-alpine-tor`, `28-alpine-tor` ([28/alpine/tor/Dockerfile](https://github.com/geekwho-eth/docker-bitcoin-core/blob/master/28/alpine/tor/Dockerfile))
16+
17+
Origin README.md pls see [ruimarinho/docker-bitcoin-core](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/README.md)
18+
19+
## Features
20+
21+
- Utilizes Alpine Linux for a lightweight base image.
22+
- Automatic installation of required dependencies.
23+
- Utilizes BerkeleyDB for data storage.
24+
- Supports configuration via `bitcoin.conf`.
25+
- Exposes ports for communication (8332, 8333, 18332, 18333, 18444).
26+
27+
## Build Stages
28+
29+
### BerkeleyDB
30+
31+
- Downloads and compiles BerkeleyDB for data storage.
32+
33+
### Bitcoin Core
34+
35+
- Downloads Bitcoin Core source code and verifies its integrity.
36+
- Compiles Bitcoin Core with specified configurations.
37+
38+
### Final Stage
39+
40+
- Sets up non-root user `bitcoin` for enhanced security.
41+
- Exposes necessary ports for Bitcoin Core operation.
42+
43+
## Usage
44+
45+
1. **Build Image**:
46+
47+
```bash
48+
docker build -t bitcoin-core .
49+
```
50+
51+
2. **Run Bitcoin Core**:
52+
53+
```bash
54+
docker run -d --name bitcoin-core \
55+
-v /path/to/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf \
56+
-p 8332:8332 \
57+
-p 8333:8333 \
58+
-p 18332:18332 \
59+
-p 18333:18333 \
60+
-p 18444:18444 \
61+
bitcoin-core
62+
```
63+
64+
3. **Configuration**:
65+
66+
Modify `bitcoin.conf` as per your requirements.
67+
68+
4. **Access Web Interface**:
69+
70+
Open your browser and go to `http://localhost:8332`.
71+
72+
5. **Additional Information**:
73+
74+
- [Bitcoin Core Documentation](https://bitcoin.org/en/bitcoin-core/)
75+
76+
## Maintenance
77+
78+
For any issues or feedback, please contact the maintainer:
79+
80+
- Maintainer: GeekWho
81+
82+
83+
## Version Information
84+
85+
- Docker Image Version: 1.0
86+
- Bitcoin Core Version: 28.0
87+
88+
## License
89+
90+
[MIT License](../LICENSE)

28/alpine/Dockerfile

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Build stage for BerkeleyDB
2+
FROM alpine as berkeleydb
3+
4+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
5+
RUN apk --no-cache add autoconf
6+
RUN apk --no-cache add automake
7+
RUN apk --no-cache add build-base
8+
RUN apk --no-cache add libressl
9+
10+
ENV BERKELEYDB_VERSION=db-4.8.30.NC
11+
ENV BERKELEYDB_PREFIX=/opt/${BERKELEYDB_VERSION}
12+
13+
RUN wget https://download.oracle.com/berkeley-db/${BERKELEYDB_VERSION}.tar.gz
14+
RUN tar -xzf *.tar.gz
15+
RUN sed s/__atomic_compare_exchange/__atomic_compare_exchange_db/g -i ${BERKELEYDB_VERSION}/dbinc/atomic.h
16+
RUN mkdir -p ${BERKELEYDB_PREFIX}
17+
18+
WORKDIR /${BERKELEYDB_VERSION}/build_unix
19+
20+
RUN ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=${BERKELEYDB_PREFIX} --build=aarch64-unknown-linux-gnu
21+
RUN make -j4
22+
RUN make install
23+
RUN rm -rf ${BERKELEYDB_PREFIX}/docs
24+
25+
# Build stage for Bitcoin Core
26+
FROM alpine as bitcoin-core
27+
28+
COPY --from=berkeleydb /opt /opt
29+
30+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
31+
RUN apk --no-cache add autoconf
32+
RUN apk --no-cache add automake
33+
RUN apk --no-cache add boost-dev
34+
RUN apk --no-cache add build-base
35+
RUN apk --no-cache add chrpath
36+
RUN apk --no-cache add file
37+
RUN apk --no-cache add gnupg
38+
RUN apk --no-cache add git
39+
RUN apk --no-cache add libevent-dev
40+
RUN apk --no-cache add libressl
41+
RUN apk --no-cache add libtool
42+
RUN apk --no-cache add linux-headers
43+
RUN apk --no-cache add sqlite-dev
44+
RUN apk --no-cache add zeromq-dev
45+
46+
ENV BITCOIN_VERSION=28.0
47+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
48+
ENV BITCOIN_SOURCE_DIR=/bitcoin/src
49+
ENV SIGS_REPO_URL="https://github.com/bitcoin-core/guix.sigs.git"
50+
ENV SIGS_CLONE_DIR="guix.sigs"
51+
ENV VERIFY_SCRIPT_URL="https://github.com/bitcoin/bitcoin/raw/master/contrib/verify-binaries/verify.py"
52+
53+
WORKDIR /bitcoin
54+
RUN set -ex \
55+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}.tar.gz \
56+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
57+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc \
58+
&& git clone ${SIGS_REPO_URL} ${SIGS_CLONE_DIR} \
59+
&& gpg --import "${SIGS_CLONE_DIR}"/builder-keys/* \
60+
&& wget -O verify.py ${VERIFY_SCRIPT_URL} \
61+
&& chmod +x verify.py \
62+
&& ./verify.py bin SHA256SUMS \
63+
"bitcoin-${BITCOIN_VERSION}.tar.gz" \
64+
&& mkdir -p ${BITCOIN_SOURCE_DIR} \
65+
&& tar -xzf "bitcoin-${BITCOIN_VERSION}.tar.gz" -C ${BITCOIN_SOURCE_DIR} \
66+
&& rm -rf ${SIGS_CLONE_DIR}
67+
68+
WORKDIR "${BITCOIN_SOURCE_DIR}/bitcoin-${BITCOIN_VERSION}"
69+
70+
RUN sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h
71+
RUN ./autogen.sh
72+
RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \
73+
--prefix=${BITCOIN_PREFIX} \
74+
--mandir=/usr/share/man \
75+
--disable-tests \
76+
--disable-bench \
77+
--disable-ccache \
78+
--with-gui=no \
79+
--with-utils \
80+
--with-libs \
81+
--with-sqlite=yes \
82+
--with-daemon
83+
RUN make -j4
84+
RUN make install
85+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-cli
86+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-tx
87+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoind
88+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a
89+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0
90+
91+
# Build stage for compiled artifacts
92+
FROM alpine
93+
94+
ARG UID=100
95+
ARG GID=101
96+
97+
LABEL maintainer="GeekWho <[email protected]>"
98+
LABEL version="1.0"
99+
LABEL description="A bitcoin-core docker image"
100+
101+
RUN addgroup bitcoin --gid ${GID} --system
102+
RUN adduser --uid ${UID} --system bitcoin --ingroup bitcoin
103+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
104+
RUN apk --no-cache add \
105+
libevent \
106+
libzmq \
107+
shadow \
108+
sqlite-dev \
109+
su-exec
110+
111+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
112+
ENV BITCOIN_VERSION=28.0
113+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
114+
ENV PATH=${BITCOIN_PREFIX}/bin:$PATH
115+
116+
COPY --from=bitcoin-core /opt /opt
117+
COPY docker-entrypoint.sh /entrypoint.sh
118+
119+
VOLUME ["/home/bitcoin/.bitcoin"]
120+
121+
EXPOSE 8332 8333 18332 18333 18444
122+
123+
ENTRYPOINT ["/entrypoint.sh"]
124+
125+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
126+
127+
CMD ["bitcoind"]

28/alpine/docker-entrypoint.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then
5+
usermod -u "$UID" bitcoin
6+
fi
7+
8+
if [ -n "${GID+x}" ] && [ "${GID}" != "0" ]; then
9+
if grep -q ":$GID:" /etc/group; then # if group exists
10+
usermod -a -G $GID bitcoin # Add USER_NAME to Group ID HOST_GID
11+
else
12+
groupmod -g "$GID" bitcoin # Change the group ID to HOST_GID
13+
fi
14+
fi
15+
16+
echo "$0: assuming uid:gid for bitcoin:bitcoin of $(id -u bitcoin):$(id -g bitcoin)"
17+
18+
if [ $(echo "$1" | cut -c1) = "-" ]; then
19+
echo "$0: assuming arguments for bitcoind"
20+
21+
set -- bitcoind "$@"
22+
fi
23+
24+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
25+
mkdir -p "$BITCOIN_DATA"
26+
chmod 700 "$BITCOIN_DATA"
27+
# Fix permissions for home dir.
28+
chown -R bitcoin:$GID "$(getent passwd bitcoin | cut -d: -f6)"
29+
# Fix permissions for bitcoin data dir.
30+
chown -R bitcoin:$GID "$BITCOIN_DATA"
31+
32+
echo "$0: setting data directory to $BITCOIN_DATA"
33+
34+
set -- "$@" -datadir="$BITCOIN_DATA"
35+
fi
36+
37+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
38+
echo "start bitcoind with user bitcoin..."
39+
exec su-exec bitcoin:$GID "$@"
40+
fi
41+
42+
echo " run defalut command with root..."
43+
exec "$@"

28/debian/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM debian:bookworm-slim as builder
2+
3+
LABEL maintainer="GeekWho <[email protected]>"
4+
LABEL version="1.0"
5+
LABEL description="A bitcoin-core docker image"
6+
7+
RUN apt-get update -y \
8+
&& apt-get install -y ca-certificates curl git gnupg gosu python3 wget --no-install-recommends \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
11+
12+
ARG TARGETPLATFORM
13+
ENV BITCOIN_VERSION=28.0
14+
ENV SIGS_REPO_URL="https://github.com/bitcoin-core/guix.sigs.git"
15+
ENV SIGS_CLONE_DIR="guix.sigs"
16+
ENV VERIFY_SCRIPT_URL="https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/verify-binaries/verify.py"
17+
ENV TMPDIR="/tmp/bitcoin_verify_binaries"
18+
19+
RUN set -ex \
20+
&& if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export TARGETPLATFORM=x86_64-linux-gnu; fi \
21+
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGETPLATFORM=aarch64-linux-gnu; fi \
22+
&& if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then export TARGETPLATFORM=arm-linux-gnueabihf; fi \
23+
&& git clone ${SIGS_REPO_URL} ${SIGS_CLONE_DIR} \
24+
&& gpg --import "${SIGS_CLONE_DIR}"/builder-keys/* \
25+
&& curl -o verify.py ${VERIFY_SCRIPT_URL} \
26+
&& chmod +x verify.py \
27+
&& ./verify.py \
28+
--min-good-sigs 6 pub "${BITCOIN_VERSION}-linux" \
29+
&& tar -xzf "${TMPDIR}.${BITCOIN_VERSION}-linux/bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz" -C /opt \
30+
&& rm -rf ${SIGS_CLONE_DIR} \
31+
&& rm -rf ${TMPDIR} \
32+
&& rm -rf /opt/bitcoin-${BITCOIN_VERSION}/bin/bitcoin-qt
33+
34+
# Second stage
35+
FROM debian:bookworm-slim
36+
37+
ARG UID=101
38+
ARG GID=101
39+
40+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
41+
ENV BITCOIN_VERSION=28.0
42+
ENV PATH=/opt/bitcoin-${BITCOIN_VERSION}/bin:$PATH
43+
44+
RUN groupadd --gid ${GID} bitcoin \
45+
&& useradd --create-home --no-log-init -u ${UID} -g ${GID} bitcoin \
46+
&& apt-get update -y \
47+
&& apt-get install -y gosu --no-install-recommends \
48+
&& apt-get clean \
49+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
50+
51+
COPY --from=builder /opt/bitcoin-${BITCOIN_VERSION} /opt/bitcoin-${BITCOIN_VERSION}
52+
53+
COPY docker-entrypoint.sh /entrypoint.sh
54+
55+
VOLUME ["/home/bitcoin/.bitcoin"]
56+
EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332
57+
58+
ENTRYPOINT ["/entrypoint.sh"]
59+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
60+
CMD ["bitcoind"]

0 commit comments

Comments
 (0)