Skip to content

Commit 92c5488

Browse files
committed
feat: add bitcoin core v29.0
1 parent 156a32d commit 92c5488

File tree

8 files changed

+462
-1
lines changed

8 files changed

+462
-1
lines changed

.github/workflows/bitcoin_core.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ jobs:
4545
context: "./28/debian"
4646
- name: 28-ubuntu
4747
context: "./28/ubuntu"
48+
- name: 29-alpine
49+
context: "./29/alpine"
50+
- name: 29-debian
51+
context: "./29/debian"
52+
- name: 29-ubuntu
53+
context: "./29/ubuntu"
4854
- name: latest
49-
context: "./28/alpine"
55+
context: "./29/alpine"
5056
steps:
5157
- name: Checkout
5258
uses: actions/checkout@v4

29/README.md

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

29/alpine/Dockerfile

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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=29.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+
89+
# Build stage for compiled artifacts
90+
FROM alpine
91+
92+
ARG UID=100
93+
ARG GID=101
94+
95+
LABEL maintainer="GeekWho <[email protected]>"
96+
LABEL version="1.0"
97+
LABEL description="A bitcoin-core docker image"
98+
99+
RUN addgroup bitcoin --gid ${GID} --system
100+
RUN adduser --uid ${UID} --system bitcoin --ingroup bitcoin
101+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
102+
RUN apk --no-cache add \
103+
libevent \
104+
libzmq \
105+
shadow \
106+
sqlite-dev \
107+
su-exec
108+
109+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
110+
ENV BITCOIN_VERSION=29.0
111+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
112+
ENV PATH=${BITCOIN_PREFIX}/bin:$PATH
113+
114+
COPY --from=bitcoin-core /opt /opt
115+
COPY docker-entrypoint.sh /entrypoint.sh
116+
117+
VOLUME ["/home/bitcoin/.bitcoin"]
118+
119+
EXPOSE 8332 8333 18332 18333 18444
120+
121+
ENTRYPOINT ["/entrypoint.sh"]
122+
123+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
124+
125+
CMD ["bitcoind"]

29/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 "$@"

29/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=29.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=29.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"]

29/debian/docker-entrypoint.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
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+
groupmod -g "$GID" bitcoin
10+
fi
11+
12+
echo "$0: assuming uid:gid for bitcoin:bitcoin of $(id -u bitcoin):$(id -g bitcoin)"
13+
14+
if [ $(echo "$1" | cut -c1) = "-" ]; then
15+
echo "$0: assuming arguments for bitcoind"
16+
17+
set -- bitcoind "$@"
18+
fi
19+
20+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
21+
mkdir -p "$BITCOIN_DATA"
22+
chmod 700 "$BITCOIN_DATA"
23+
# Fix permissions for home dir.
24+
chown -R bitcoin:bitcoin "$(getent passwd bitcoin | cut -d: -f6)"
25+
# Fix permissions for bitcoin data dir.
26+
chown -R bitcoin:bitcoin "$BITCOIN_DATA"
27+
28+
echo "$0: setting data directory to $BITCOIN_DATA"
29+
30+
set -- "$@" -datadir="$BITCOIN_DATA"
31+
fi
32+
33+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
34+
echo "start bitcoind with user bitcoin..."
35+
exec gosu bitcoin "$@"
36+
fi
37+
38+
echo " run defalut command with root..."
39+
exec "$@"

0 commit comments

Comments
 (0)