bitcoin-core-container/Containerfile
2023-10-19 19:50:06 -04:00

66 lines
2.3 KiB
Docker

# Copyright 2023 Foster Hangdaan <foster@hangdaan.email>
# Licensed under Apache-2.0
# Download, verify and unpack stage
FROM docker.io/library/debian:12 as downloader
RUN apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git \
&& apt-get clean
WORKDIR /bitcoin
ARG TARGETPLATFORM
ENV BITCOIN_VERSION=25.1
RUN set -ex \
&& if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export TARGETPLATFORM=x86_64-linux-gnu; fi \
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGETPLATFORM=aarch64-linux-gnu; fi \
&& if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then export TARGETPLATFORM=arm-linux-gnueabihf; fi \
&& git clone https://github.com/bitcoin-core/guix.sigs.git \
&& gpg --import guix.sigs/builder-keys/* \
&& curl --show-error --remote-name --location https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz \
&& curl --show-error --remote-name --location https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
&& curl --show-error --remote-name --location https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc \
&& gpg --verify SHA256SUMS.asc SHA256SUMS \
&& grep " bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz" SHA256SUMS | sha256sum --check - \
&& mkdir ./tmp \
&& tar -xzf bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz -C ./tmp --strip-components 1
# Runtime stage
FROM docker.io/library/debian:12-slim
LABEL maintainer="Foster Hangdaan <foster@hangdaan.email>"
RUN set -ex && \
apt-get update && \
apt-get --no-install-recommends --yes install ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt
COPY --from=downloader /bitcoin/tmp/bin/bitcoind /usr/local/bin/
RUN adduser --system --group --disabled-password bitcoin && \
mkdir -p /home/bitcoin/.bitcoin
# Expose volume containing all `bitcoind` data
VOLUME /home/bitcoin/.bitcoin/
# REST interface
EXPOSE 8080
# P2P network (mainnet, testnet & regnet respectively)
EXPOSE 8333 18333 18444
# RPC interface (mainnet, testnet & regnet respectively)
EXPOSE 8332 18332 18443
# ZMQ ports (for transactions & blocks respectively)
EXPOSE 28332 28333
# Switch to bitcoin user
USER bitcoin
ENTRYPOINT ["bitcoind"]
CMD ["-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"]