diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5c0179a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,82 @@ +sudo: required + +dist: xenial + +services: + - docker + +language: minimal + +# SLUG - converts Gihub slug (`lncm/docker-bitcoind`) to Docker slug (`lncm/bitcoind`) +# VER - if TAG is being build, VER contains only MAJOR and MINOR parts of the version (ex. `0.18.0` -> `0.18`) +# DIR - if BRANCH is being built, use DIR with the highest version number +# PREFIX - sets Dockerfile prefix. Be it based on `git tag`, or highest-version DIR name +env: + global: + - SLUG="${TRAVIS_REPO_SLUG/docker-/}" + - VER=$(echo ${TRAVIS_TAG} | cut -d. -f1,2) + - DIR=$(ls -vd */ | grep '^[0-9]' | tail -n 1 | tr -d /) + - PREFIX="${VER:-$DIR}" + +stages: + - build + - name: deploy + if: tag IS present + +jobs: + include: +# - stage: build +# name: "Build Docker image from SOURCE for amd64" +# env: ARCH=amd64 FROM=source + +# - name: "Build Docker image from BINARY for amd64" +# env: ARCH=amd64 FROM=binary + + - stage: build + name: "Build Docker image from SOURCE for arm" + env: ARCH=arm FROM=source + + - name: "See how fast building toolchain works on Travis" + script: docker build 0.18/ + +# - name: "Build Docker image from BINARY for arm" +# env: ARCH=arm FROM=binary + + - stage: deploy + name: "Aggregate Docker images under one manifest" + script: ./.travis/docker-manifest.sh + + - name: "Upload Docker containers to Github Releases" + deploy: + skip_cleanup: true + provider: releases + api_key: + secure: H7PazuFTFL/sTAf6DH47wB81rfB6AXsPdiDBTmMvPc6+P7zr3O+1g6T1c93sUq5wrVqUnD/XKLmPXDTWhiQVoLkdDPzM9fdd2JTzgbzfXTDtg7gi/mNuZOgftoKwRYiLhNnWR/hKmtLcXFYYzKVRt1BUGShv722y4lVl/GPolzRLGyO1+5f0dC48VBjYmDxInUkM32bFkVSlQ2ro+OndecRhn/Pd8oOPPOwwM+/4iplsbBe4pRJ4kHMjgxdJRnV3kb+jUuA0Q+4U5XXPDGLw4BDh6/wZZ4IUgIAubNam32B7lql9t733ksuPtWA40rkwEFmfQyGGU1QEzb4gHUOcKpKfm43s8THjU85EnSSuyv3NWmZL4/wtmnJL/SpW6azdnSjycJUlddXX1MvsMvdnrZrSSU4WWCHtxOxgm1Figv/QAtn48NMwhmpCya2HYBZKlpqqPYj0j3pk9+ifJANF9DzMJ/xBXuPBW7M3WFCDlnGIqXXRAKbk6mEkecBk8JH0Qn/gGVm+pTV9Rcm2wKcQwrSyBkC//nJ6CXQXZ9OSW8m7NqkCRfIjSQ9g/caZgkxNEKyNYWssLB8UJ8CKyrkRH0jjfXJ1bhwbyw3Opg6b6rafPqQHwGb9Dm8Z8QlnhyafVEcry9kRVax6NWMNZkCP19U0t0Fhs0OFR2Ex7FbZ+Cw= + file_glob: true + file: images/*.tgz + on: + repo: lncm/docker-bitcoind + tags: true + +before_script: ./.travis/before-script.sh +script: + - > + if [[ "${ARCH}" = "amd64" ]]; then + ./.travis/build-amd64.sh + + elif [[ "${ARCH}" = "arm" ]]; then + wget https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.10.0/alpine-chroot-install \ + && echo 'dcceb34aa63767579f533a7f2e733c4d662b0d1b alpine-chroot-install' | sha1sum -c \ + || exit 1 + + chmod +x alpine-chroot-install + sudo ./alpine-chroot-install -a armhf -b v3.9 + + /alpine/enter-chroot apk add bash + /alpine/enter-chroot ~/.travis/build-arm.sh || true + /alpine/enter-chroot ./.travis/build-arm.sh || true + + elif [[ ! -z "${ARCH}" ]]; then + ./.travis/pull-all.sh + fi + diff --git a/.travis/before-script.sh b/.travis/before-script.sh new file mode 100755 index 0000000..63a661a --- /dev/null +++ b/.travis/before-script.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +#if [[ ! -z "${FROM}" ]]; then +# PREFIX="${PREFIX}/${FROM}" +#fi + +## Magic `sed` command that replaces the last occurrence of `FROM alpine` with `FROM arm32v7/alpine` +## if base architecture of the final stage needs changing. Don't ask me about the "3". +#if [[ "${ARCH}" = "arm" ]]; then +# sed -i '3,\|^FROM alpine| s|FROM alpine|FROM arm32v7/alpine|' ${PREFIX}/Dockerfile +# echo "${PREFIX}/Dockerfile modified: Final stage image, base CPU architecture changed to: arm32v7" +#fi diff --git a/.travis/build-amd64.sh b/.travis/build-amd64.sh new file mode 100755 index 0000000..073097d --- /dev/null +++ b/.travis/build-amd64.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +TAG="${SLUG}:${TRAVIS_TAG:-$TRAVIS_BRANCH}-${FROM}-linux-${ARCH}" + +echo "Building ${TAG} with ${PREFIX}/Dockerfile…" + +if [[ "${FROM}" = "binary" ]]; then + docker build --no-cache --build-arg "arch=x86_64" -t ${TAG} ${PREFIX}/${FROM}/ + +else + docker build --no-cache -t ${TAG} ${PREFIX}/${FROM}/ +fi + + +# Push image, if tag was specified +if [[ -n "${TRAVIS_TAG}" ]]; then + echo "${DOCKER_PASS}" | docker login -u="${DOCKER_USER}" --password-stdin + + docker push "${TAG}" +fi + + + diff --git a/.travis/build-arm.sh b/.travis/build-arm.sh new file mode 100755 index 0000000..ced5f9b --- /dev/null +++ b/.travis/build-arm.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +apk add docker + +TAG="${SLUG}:${TRAVIS_TAG:-$TRAVIS_BRANCH}-${FROM}-linux-${ARCH}" + +echo "Building ${TAG} with ${PREFIX}/Dockerfile…" + +if [[ "${FROM}" = "binary" ]]; then + docker build --no-cache --build-arg "arch=${ARCH}" -t ${TAG} ${PREFIX}/${FROM}/ + +else + docker build --no-cache -t ${TAG} ${PREFIX}/${FROM}/ +fi + + +# Push image, if tag was specified +if [[ -n "${TRAVIS_TAG}" ]]; then + echo "${DOCKER_PASS}" | docker login -u="${DOCKER_USER}" --password-stdin + + docker push "${TAG}" +fi + + + diff --git a/.travis/docker-manifest.sh b/.travis/docker-manifest.sh new file mode 100755 index 0000000..109f671 --- /dev/null +++ b/.travis/docker-manifest.sh @@ -0,0 +1,78 @@ +#!/bin/bash +set -e + +# make sure Docker's config folder exists +mkdir -p ~/.docker + +# Putting experimental:true to config enables manifest options +echo '{ "experimental": "enabled" }' > ~/.docker/config.json + +# put above config into effect +sudo systemctl restart docker + +echo "${DOCKER_PASS}" | docker login -u="${DOCKER_USER}" --password-stdin + +# print this to verify manifest options are now available +docker version + + + +# Example: lncm/bitcoind:0.18.0 +IMAGE_VERSIONED="${SLUG}:${TRAVIS_TAG}" +IMAGE_AMD64_SRC="${IMAGE_VERSIONED}-source-linux-amd64" +#IMAGE_ARM7_SRC="${IMAGE_VERSIONED}-source-linux-armv7" + +docker pull "${IMAGE_AMD64_SRC}" +#docker pull "${IMAGE_ARM7_SRC}" + +echo "Pushing manifest ${IMAGE_VERSIONED}" +docker -D manifest create "${IMAGE_VERSIONED}" "${IMAGE_AMD64_SRC}" #"${IMAGE_ARM7_SRC}" +#docker manifest annotate "${IMAGE_VERSIONED}" "${IMAGE_ARM7_SRC}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_VERSIONED}" + +# example: lncm/bitcoind:0.18 +IMAGE_MINOR_VER="${SLUG}:${VER}" + +echo "Pushing manifest ${IMAGE_MINOR_VER}" +docker -D manifest create "${IMAGE_MINOR_VER}" "${IMAGE_AMD64_SRC}" #"${IMAGE_ARM7_SRC}" +#docker manifest annotate "${IMAGE_MINOR_VER}" "${IMAGE_ARM7_SRC}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_MINOR_VER}" + +#example: lncm/bitcoind:latest +IMAGE_LATEST="${SLUG}:latest" + +echo "Pushing manifest ${IMAGE_LATEST}" +docker -D manifest create "${IMAGE_LATEST}" "${IMAGE_AMD64_SRC}" #"${IMAGE_ARM7_SRC}" +#docker manifest annotate "${IMAGE_LATEST}" "${IMAGE_ARM7_SRC}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_LATEST}" + + + +# Example: lncm/bitcoind:0.18.0-binary +IMAGE_VERSIONED="${SLUG}:${TRAVIS_TAG}-binary" +IMAGE_AMD64_BIN="${IMAGE_VERSIONED}-binary-linux-amd64" +#IMAGE_ARM7_BIN="${IMAGE_VERSIONED}-binary-linux-armv7" + +docker pull "${IMAGE_AMD64_BIN}" +#docker pull "${IMAGE_ARM7_BIN}" + +echo "Pushing manifest ${IMAGE_VERSIONED}" +docker -D manifest create "${IMAGE_VERSIONED}" "${IMAGE_AMD64_BIN}" #"${IMAGE_ARM7_BIN}" +#docker manifest annotate "${IMAGE_VERSIONED}" "${IMAGE_ARM7_BIN}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_VERSIONED}" + +# example: lncm/bitcoind:0.18-binary +IMAGE_MINOR_VER="${SLUG}:${VER}-binary" + +echo "Pushing manifest ${IMAGE_MINOR_VER}" +docker -D manifest create "${IMAGE_MINOR_VER}" "${IMAGE_AMD64_BIN}" #"${IMAGE_ARM7_BIN}" +#docker manifest annotate "${IMAGE_MINOR_BIN}" "${IMAGE_ARM7_BIN}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_MINOR_VER}" + +#example: lncm/bitcoind:binary +IMAGE_BINARY="${SLUG}:binary" + +echo "Pushing manifest ${IMAGE_BINARY}" +docker -D manifest create "${IMAGE_BINARY}" "${IMAGE_AMD64_BIN}" #"${IMAGE_ARM7_BIN}" +#docker manifest annotate "${IMAGE_BINARY}" "${IMAGE_ARM7_BIN}" --os linux --arch arm --variant v7 +docker manifest push "${IMAGE_BINARY}" diff --git a/.travis/pull-all.sh b/.travis/pull-all.sh new file mode 100755 index 0000000..7aaac4d --- /dev/null +++ b/.travis/pull-all.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +echo "Saving images…" + +LATEST_AMD64_SRC="${SLUG}:${TRAVIS_TAG}-source-linux-amd64" +LATEST_AMD64_BIN="${SLUG}:${TRAVIS_TAG}-binary-linux-amd64" +#LATEST_ARM7_SRC="${SLUG}:${TRAVIS_TAG}-source-linux-armv7" +#LATEST_ARM7_BIN="${SLUG}:${TRAVIS_TAG}-binary-linux-armv7" + +mkdir images + +docker pull ${LATEST_AMD64_SRC} +docker save ${LATEST_AMD64_SRC} | gzip > "images/${SLUG/\//-}-${TRAVIS_TAG}-source-linux-amd64.tgz" + +docker pull ${LATEST_AMD64_BIN} +docker save ${LATEST_AMD64_BIN} | gzip > "images/${SLUG/\//-}-${TRAVIS_TAG}-binary-linux-amd64.tgz" + +#docker pull ${LATEST_ARM7_SRC} +#docker save ${LATEST_ARM7_SRC} | gzip > "images/${SLUG/\//-}-${TRAVIS_TAG}-source-linux-armv7.tgz" + +#docker pull ${LATEST_ARM7_BIN} +#docker save ${LATEST_ARM7_BIN} | gzip > "images/${SLUG/\//-}-${TRAVIS_TAG}-binary-linux-armv7.tgz" diff --git a/0.17/Dockerfile b/0.17/Dockerfile index 8f40517..49c646b 100644 --- a/0.17/Dockerfile +++ b/0.17/Dockerfile @@ -4,6 +4,7 @@ FROM alpine:3.9 AS bitcoin-core # fetch already built berkeleydb COPY --from=lncm/berkeleydb:db-4.8.30.NC /opt /opt +# Use APK repos over HTTPS. See: https://github.com/gliderlabs/docker-alpine/issues/184 RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories RUN apk --no-cache add autoconf RUN apk --no-cache add automake @@ -69,6 +70,7 @@ FROM alpine:3.9 AS final LABEL maintainer.0="nolim1t (@nolim1t)" \ maintainer.1="Damian Mee (@meeDamian)" +# Use APK repos over HTTPS. See: https://github.com/gliderlabs/docker-alpine/issues/184 RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories RUN apk --no-cache add \ boost \ @@ -86,7 +88,17 @@ VOLUME /root/.bitcoin COPY --from=bitcoin-core /opt /opt -EXPOSE 8080 8332 8333 18332 18333 18444 28333 28332 +# 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 ENTRYPOINT ["bitcoind"] CMD ["bitcoind", "-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"] diff --git a/0.18/Dockerfile b/0.18/Dockerfile new file mode 100644 index 0000000..96e7e56 --- /dev/null +++ b/0.18/Dockerfile @@ -0,0 +1,62 @@ +# Build stage for Bitcoin Core +FROM alpine:3.9 AS bitcoin-core + +# fetch already built berkeleydb +COPY --from=lncm/berkeleydb:db-4.8.30.NC-linux-arm /opt /opt + +# Replace `http:` repositories with `https:` ones +RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories +RUN echo 'https://alpine.global.ssl.fastly.net/alpine/edge/testing' >> /etc/apk/repositories + +# install packages necessary to build Bitcoind +RUN apk add --no-cache --update \ + autoconf \ + automake \ + boost-dev \ + build-base \ + chrpath \ + crosstool-ng \ + curl \ + file \ + g++ \ + gcc \ + git \ + gnupg \ + libevent-dev \ + libressl \ + libressl-dev \ + libtool \ + linux-headers \ + make \ + protobuf-dev \ + tar \ + wget \ + zeromq-dev + +# We are inside Docker container. It's easier to run as root, and no damage can be done anyway… so ¯\_(ツ)_/¯ +ENV CT_EXPERIMENTAL=y +ENV CT_ALLOW_BUILD_AS_ROOT=y +ENV CT_ALLOW_BUILD_AS_ROOT_SURE=y + +RUN apk add xz patch binutils + +RUN ct-ng arm-unknown-linux-musleabi + +RUN ct-ng -d build || true + +RUN tail -n 200 build.log + + + +# Alpine gotchas: +# +# `apk add --update wget` has to be run. +# Otherwise "wget: unrecognized option: progress=dot:binary" is returned +# +# `apk add --update tor` has to be run. +# Otherwise "tar: invalid tar magic" is returned +# +# `apk add --update patch` +# Otherwise: "/usr/bin/patch: unrecognized option: 0" +# +# Just missing & needs installing: xz strip (part of binutils) diff --git a/0.18/Dockerfile.bak b/0.18/Dockerfile.bak new file mode 100644 index 0000000..10389b9 --- /dev/null +++ b/0.18/Dockerfile.bak @@ -0,0 +1,136 @@ +# Build stage for Bitcoin Core +FROM alpine:3.9 AS bitcoin-core + +# fetch already built berkeleydb +COPY --from=lncm/berkeleydb:db-4.8.30.NC-linux-arm /opt /opt + +# Replace `http:` repositories with `https:` ones +RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories +RUN echo 'https://alpine.global.ssl.fastly.net/alpine/edge/testing' >> /etc/apk/repositories + + +# install packages necessary to build Bitcoind +RUN apk add --no-cache --update \ + autoconf \ + automake \ + boost-dev \ + build-base \ + chrpath \ + curl \ + file \ +# g++ \ +# gcc-cross-embedded \ + crosstool-ng \ + git \ + gnupg \ + libevent-dev \ + libressl \ + libressl-dev \ + libtool \ + linux-headers \ + protobuf-dev \ + zeromq-dev + +#RUN set -ex \ +# && for key in \ +# 90C8019E36C2E964 \ +# ; do \ +# gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ +# gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ +# gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \ +# gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \ +# done + +ENV BITCOIN_VERSION=0.18.0 +ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION} + +RUN git clone -b "v${BITCOIN_VERSION}" https://github.com/bitcoin/bitcoin.git + +# Download checksums (intentionally different source than source code) +#RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc + +# Download source code (intentionally different source than checksums) +#RUN wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}.tar.gz + +# Verify that hashes are signed with the previously imported key +#RUN gpg --verify SHA256SUMS.asc + +# Verify that downloaded source-code archive has exactly the hash that's provided +#RUN grep " bitcoin-${BITCOIN_VERSION}.tar.gz\$" SHA256SUMS.asc | sha256sum -c - + +# Extract +#RUN tar -xzf *.tar.gz + +# Change to the extraced directory +WORKDIR /bitcoin +# -${BITCOIN_VERSION} + +# ??? +RUN sed -i '/AC_PREREQ/a\AR_FLAGS=cr' src/univalue/configure.ac +# ??? +RUN sed -i '/AX_PROG_CC_FOR_BUILD/a\AR_FLAGS=cr' src/secp256k1/configure.ac +# ??? +RUN sed -i s:sys/fcntl.h:fcntl.h: src/compat.h + +RUN ./autogen.sh +RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \ + --prefix=${BITCOIN_PREFIX} \ + --mandir=/usr/share/man \ + --disable-tests \ + --disable-bench \ + --disable-ccache \ + --with-gui=no \ + --with-utils \ + --with-libs \ + --with-daemon +RUN make +RUN make install + +RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-cli +RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-tx +RUN strip ${BITCOIN_PREFIX}/bin/bitcoind +RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a +RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0 + + +# Build stage for compiled artifacts +FROM alpine:3.9 AS final + +LABEL maintainer.0="nolim1t (@nolim1t)" \ + maintainer.1="Damian Mee (@meeDamian)" + +# TODO: Eliminating the two RUN lines below is necessary to cross-compile… +# Replace `http:` repositories with `https:` ones +RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories + +RUN apk --no-cache --update + add \ + boost \ + boost-program_options \ + libevent \ + libressl \ + libzmq \ + su-exec + +ENV BITCOIN_VERSION=0.18.0 +ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION} +ENV PATH=${BITCOIN_PREFIX}/bin:$PATH + +VOLUME /root/.bitcoin + +COPY --from=bitcoin-core /opt /opt + +# 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 + +ENTRYPOINT ["bitcoind"] +CMD ["bitcoind", "-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"] diff --git a/0.18/binary/Dockerfile b/0.18/binary/Dockerfile new file mode 100644 index 0000000..e898f00 --- /dev/null +++ b/0.18/binary/Dockerfile @@ -0,0 +1,62 @@ +# Build stage for Bitcoin Core +FROM alpine:3.9 AS bitcoin-core + + + + +#RUN apk --no-cache add autoconf +#RUN apk --no-cache add automake +#RUN apk --no-cache add boost-dev +#RUN apk --no-cache add build-base +#RUN apk --no-cache add chrpath +#RUN apk --no-cache add file +RUN apk --no-cache add gnupg +#RUN apk --no-cache add libevent-dev +#RUN apk --no-cache add libressl +#RUN apk --no-cache add libressl-dev +#RUN apk --no-cache add libtool +#RUN apk --no-cache add linux-headers +#RUN apk --no-cache add protobuf-dev +#RUN apk --no-cache add zeromq-dev +RUN set -ex \ + && for key in \ + 90C8019E36C2E964 \ + ; do \ + gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ + gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \ + gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \ + done + +ENV BITCOIN_VERSION=0.18.0 + +ARG arch +RUN wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc +RUN wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${arch}-linux-gnu.tar.gz +RUN gpg --verify SHA256SUMS.asc +RUN grep " bitcoin-${BITCOIN_VERSION}.tar.gz\$" SHA256SUMS.asc | sha256sum -c - +RUN tar -xzf *.tar.gz + +RUN install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${BITCOIN_VERSION}/bin/* + +LABEL maintainer.0="nolim1t (@nolim1t)" \ + maintainer.1="Damian Mee (@meeDamian)" + +VOLUME /root/.bitcoin + +COPY --from=bitcoin-core /opt /opt + +# 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 + +ENTRYPOINT ["bitcoind"] +CMD ["bitcoind", "-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"] diff --git a/0.18/source/Dockerfile b/0.18/source/Dockerfile new file mode 100644 index 0000000..8941826 --- /dev/null +++ b/0.18/source/Dockerfile @@ -0,0 +1,125 @@ +# Build stage for Bitcoin Core +FROM alpine:3.9 AS bitcoin-core + +# fetch already built berkeleydb +COPY --from=lncm/berkeleydb:db-4.8.30.NC /opt /opt + +# Use APK repos over HTTPS. See: https://github.com/gliderlabs/docker-alpine/issues/184 +RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories + +# install packages necessary to build Bitcoind +RUN apk add --no-cache --update \ + autoconf \ + automake \ + boost-dev \ + build-base \ + chrpath \ + file \ + gnupg \ + libevent-dev \ + libressl \ + libressl-dev \ + libtool \ + linux-headers \ + protobuf-dev \ + zeromq-dev + +RUN set -ex \ + && for key in \ + 90C8019E36C2E964 \ + ; do \ + gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ + gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \ + gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \ + done + +ENV BITCOIN_VERSION=0.18.0 +ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION} + +# Download checksums (intentionally different source than source code) +RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc + +# Download source code (intentionally different source than checksums) +RUN wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}.tar.gz + +# Verify that hashes are signed with the previously imported key +RUN gpg --verify SHA256SUMS.asc + +# Verify that downloaded source-code archive has exactly the hash that's provided +RUN grep " bitcoin-${BITCOIN_VERSION}.tar.gz\$" SHA256SUMS.asc | sha256sum -c - + +# Extract +RUN tar -xzf *.tar.gz + +# Change to the extraced directory +WORKDIR /bitcoin-${BITCOIN_VERSION} + +# ??? +RUN sed -i '/AC_PREREQ/a\AR_FLAGS=cr' src/univalue/configure.ac +# ??? +RUN sed -i '/AX_PROG_CC_FOR_BUILD/a\AR_FLAGS=cr' src/secp256k1/configure.ac +# ??? +RUN sed -i s:sys/fcntl.h:fcntl.h: src/compat.h + +RUN ./autogen.sh +RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \ + --prefix=${BITCOIN_PREFIX} \ + --mandir=/usr/share/man \ + --disable-tests \ + --disable-bench \ + --disable-ccache \ + --with-gui=no \ + --with-utils \ + --with-libs \ + --with-daemon +RUN make +RUN make install + +RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-cli +RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-tx +RUN strip ${BITCOIN_PREFIX}/bin/bitcoind +RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a +RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0 + + +# Build stage for compiled artifacts +FROM alpine:3.9 AS final + +LABEL maintainer.0="nolim1t (@nolim1t)" \ + maintainer.1="Damian Mee (@meeDamian)" + +# TODO: Eliminating the two RUN lines below is crucial to make cross-compilation possible… +# Use APK repos over HTTPS. See: https://github.com/gliderlabs/docker-alpine/issues/184 +RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories +RUN apk --no-cache --update \ + add \ + boost \ + boost-program_options \ + libevent \ + libressl \ + libzmq \ + su-exec + +ENV BITCOIN_VERSION=0.18.0 +ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION} +ENV PATH=${BITCOIN_PREFIX}/bin:$PATH + +VOLUME /root/.bitcoin + +COPY --from=bitcoin-core /opt /opt + +# 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 + +ENTRYPOINT ["bitcoind"] +CMD ["bitcoind", "-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"] diff --git a/README.md b/README.md index e65bec5..4f3f922 100644 --- a/README.md +++ b/README.md @@ -89,3 +89,4 @@ docker exec -it bitcoind bitcoin-cli --help docker exec -it bitcoind bitcoin-cli -getinfo docker exec -it bitcoind bitcoin-cli getblockcount ``` +