diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..5554fd1a84 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,150 @@ +*.tar.gz + +*.exe +*.pdb +src/elements +src/elementsd +src/elements-cli +src/elements-gui +src/elements-node +src/elements-tx +src/elements-wallet +src/test/fuzz/* +!src/test/fuzz/*.* +src/test/test_bitcoin +src/qt/test/test_elements-qt + +# autoreconf +Makefile.in +aclocal.m4 +autom4te.cache/ +build-aux/config.guess +build-aux/config.sub +build-aux/depcomp +build-aux/install-sh +build-aux/ltmain.sh +build-aux/m4/libtool.m4 +build-aux/m4/lt~obsolete.m4 +build-aux/m4/ltoptions.m4 +build-aux/m4/ltsugar.m4 +build-aux/m4/ltversion.m4 +build-aux/missing +build-aux/compile +build-aux/test-driver +config.cache +config.log +config.status +configure +libtool +src/config/bitcoin-config.h +src/config/bitcoin-config.h.in +src/config/stamp-h1 +src/obj +share/setup.nsi +share/qt/Info.plist + +src/univalue/gen + +src/qt/*.moc +src/qt/moc_*.cpp +src/qt/forms/ui_*.h + +src/qt/test/moc*.cpp + +src/qt/bitcoin-qt.config +src/qt/bitcoin-qt.creator +src/qt/bitcoin-qt.creator.user +src/qt/bitcoin-qt.files +src/qt/bitcoin-qt.includes + +.deps +.dirstamp +.libs +.*.swp +*.*~* +*.bak +*.rej +*.orig +*.pyc +*.o +*.o-* +*.a +*.pb.cc +*.pb.h +*.dat + +*.log +*.trs +*.dmg + +*.json.h +*.raw.h + +# Only ignore unexpected patches +*.patch +!depends/patches/**/*.patch + +#libtool object files +*.lo +*.la + +# Compilation and Qt preprocessor part +*.qm +Makefile +!depends/Makefile +src/qt/elements-qt +Elements-Qt.app +background.tiff* + +# Qt Creator +Makefile.am.user + +# Unit-tests +Makefile.test +bitcoin-qt_test + +# Resources cpp +qrc_*.cpp + +# Mac specific +.DS_Store +build + +# Previous releases +releases + +#lcov +*.gcno +*.gcda +/*.info +test_bitcoin.coverage/ +total.coverage/ +fuzz.coverage/ +coverage_percent.txt +/cov_tool_wrapper.sh +qa-assets/ + +#build tests +linux-coverage-build +linux-build +win32-build +test/config.ini +test/cache/* +test/.mypy_cache/ + +!src/leveldb*/Makefile + +/doc/doxygen/ + +libbitcoinconsensus.pc +contrib/devtools/split-debug.sh + +# Output from running db4 installation +db4/ + +# clang-check +*.plist + +osx_volname +dist/ +*.background.tiff diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..ddefe73d04 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Build Docker containers on push + +permissions: + packages: write + +on: + push: + branches: + - master + +jobs: + build-amd64: + name: Build image + runs-on: ubuntu-20.04 + + steps: + - name: Checkout project + uses: actions/checkout@v2 + + - name: Set env variables + run: | + echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV + REPO_OWNER=${{ github.repository_owner }} + echo "IMAGE_NAME=${REPO_OWNER,,}/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Setup Docker buildx action + uses: docker/setup-buildx-action@v1 + + - name: Run Docker buildx + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag ghcr.io/$IMAGE_NAME:$BRANCH \ + --output "type=registry" ./ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..b2798d2afb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,100 @@ +# This Dockerfile builds Elements and packages it into a minimal `final` image + +# Define default versions so that they don't have to be repeated throughout the file +ARG VER_ALPINE=3.15 + +# $USER name, and data $DIR to be used in the `final` image +ARG USER=elements +ARG DIR=/data + +# +# This downloads a pre-built BerkeleyDB to make sure +# the overall build time of this Dockerfile fits within CI limits. +# +FROM ghcr.io/runcitadel/berkeleydb:main AS berkeleydb + + +FROM alpine:${VER_ALPINE} AS builder + +ARG VERSION +ARG SOURCE + +RUN apk add --no-cache \ + autoconf \ + automake \ + boost-dev \ + sqlite-dev \ + build-base clang clang-dev lld \ + chrpath \ + file \ + libevent-dev \ + libressl \ + libtool \ + linux-headers \ + zeromq-dev + +# Fetch pre-built berkeleydb +COPY --from=berkeleydb /opt/ /opt/ + +# Change to the extracted directory +WORKDIR /elements + +# Copy bitcoin source (downloaded & verified in previous stages) +COPY . . + +ENV ELEMENTS_PREFIX /opt/element + +RUN ./autogen.sh + +# TODO: Try to optimize on passed params +RUN ./configure LDFLAGS=-L/opt/db4/lib/ CPPFLAGS=-I/opt/db4/include/ \ + CXXFLAGS="-O2" CC=clang CXX=clang++ \ + --prefix="/opt/element" \ + --disable-man \ + --disable-shared \ + --disable-ccache \ + --disable-tests \ + --disable-bench \ + --enable-static \ + --enable-reduce-exports \ + --enable-c++17 \ + --without-gui \ + --without-libs \ + --with-utils \ + --with-sqlite=yes \ + --with-daemon + +RUN make -j$(nproc) +RUN make install + +FROM alpine:${VER_ALPINE} AS final + +ARG USER +ARG DIR + +RUN apk add --no-cache \ + boost-filesystem \ + boost-thread \ + boost-system \ + libevent \ + libsodium \ + libstdc++ \ + libzmq \ + sqlite-libs + +COPY --from=builder /opt/element/bin/elements* /usr/local/bin/ + +RUN adduser --disabled-password \ + --home "$DIR/" \ + --gecos "" \ + "$USER" + +USER $USER + +# Prevents `VOLUME $DIR/.bitcoind/` being created as owned by `root` +RUN mkdir -p "$DIR/.elements/" + +# Expose volume containing all `bitcoind` data +VOLUME $DIR/.elements/ + +ENTRYPOINT ["elementsd"]