# Copyright 2023 Foster Hangdaan # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Download, verify and unpack stage FROM docker.io/library/ubuntu:22.04 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=27.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/ubuntu:22.04 LABEL maintainer="Foster Hangdaan " RUN set -ex && \ apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --yes install ca-certificates && \ apt-get clean && \ rm -rf /var/lib/apt COPY --from=downloader /bitcoin/tmp/bin/bitcoind /bitcoin/tmp/bin/bitcoin-cli /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"]