Skip to content

Commit

Permalink
Add Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Nov 28, 2024
1 parent 2b33322 commit c2023de
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 23 deletions.
23 changes: 0 additions & 23 deletions ci/test/02_run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,12 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# System-dependent env vars must be kept as is. So read them from the container.
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"

# Env vars during the build can not be changed. For example, a modified
# $MAKEJOBS is ignored in the build process. Use --cpuset-cpus as an
# approximation to respect $MAKEJOBS somewhat, if cpuset is available.
MAYBE_CPUSET=""
if [ "$HAVE_CGROUP_CPUSET" ]; then
MAYBE_CPUSET="--cpuset-cpus=$( python3 -c "import random;P=$( nproc );M=min(P,int('$MAKEJOBS'.lstrip('-j')));print(','.join(map(str,sorted(random.sample(range(P),M)))))" )"
fi
echo "Creating $CI_IMAGE_NAME_TAG container to run in"

# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
--build-arg "FILE_ENV=${FILE_ENV}" \
$MAYBE_CPUSET \
--label="${CI_IMAGE_LABEL}" \
--tag="${CONTAINER_NAME}" \
"${BASE_READ_ONLY_DIR}"
Expand Down Expand Up @@ -58,19 +48,6 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
CI_PREVIOUS_RELEASES_MOUNT="type=bind,src=${PREVIOUS_RELEASES_DIR},dst=$PREVIOUS_RELEASES_DIR"
fi

if [ "$DANGER_CI_ON_HOST_CCACHE_FOLDER" ]; then
# Temporary exclusion for https://github.com/bitcoin/bitcoin/issues/31108
# to allow CI configs and envs generated in the past to work for a bit longer.
# Can be removed in March 2025.
if [ "${CCACHE_DIR}" != "/tmp/ccache_dir" ]; then
if [ ! -d "${CCACHE_DIR}" ]; then
echo "Error: Directory '${CCACHE_DIR}' must be created in advance."
exit 1
fi
CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=${CCACHE_DIR}"
fi # End temporary exclusion
fi

docker network create --ipv6 --subnet 1111:1111::/112 ci-ip6net || true

if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then
Expand Down
41 changes: 41 additions & 0 deletions ci/test/Dockerfile.asan
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM bitcoin-core-base:latest

# Add any additional environment variables
RUN export BPFCC_PACKAGE="bpfcc-tools linux-headers-$(uname --kernel-release)"
ENV LLVM_VERSION="19"
ENV BITCOIN_CONFIG="\
-DWITH_USDT=ON -DWITH_ZMQ=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=ON \
-DSANITIZERS=address,float-divide-by-zero,integer,undefined \
-DCMAKE_C_COMPILER=clang-${LLVM_VERSION} \
-DCMAKE_CXX_COMPILER=clang++-${LLVM_VERSION} \
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern -Wno-error=deprecated-declarations' \
-DAPPEND_CXXFLAGS='-std=c++23' \
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
"

# For LLVM 19 sources
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& . /etc/os-release \
&& echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${LLVM_VERSION} main" > "/etc/apt/sources.list.d/llvm-toolchain-${VERSION_CODENAME}-${LLVM_VERSION}.list"

# Install specific packages
RUN apt-get update && apt-get install --yes \
"${BPFCC_PACKAGE}" \
clang-${APT_LLVM_VERSION} \
libboost-dev \
libclang-rt-${LLVM_VERSION}-dev \
libdb5.3++-dev \
libevent-dev \
libqrencode-dev \
libsqlite3-dev \
libzmq3-dev \
llvm-${LLVM_VERSION} \
python3-zmq \
qtbase5-dev \
qttools5-dev \
qttools5-dev-tools \
systemtap-sdt-dev \
&& rm -rf /var/lib/apt/lists/*

CMD ["bash"]
25 changes: 25 additions & 0 deletions ci/test/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ubuntu:noble-20241015
FROM ubuntu:noble-20241015@sha256:278628f08d4979fb9af9ead44277dbc9c92c2465922310916ad0c46ec9999295

ENV DEBIAN_FRONTEND=noninteractive

# CI Base Packages
RUN apt-get update && apt-get install --yes \
bison \
build-essential \
ca-certificates \
ccache \
cmake \
curl \
e2fsprogs \
git \
ninja-build \
pkg-config \
procps \
python3 \
python3-pip \
rsync \
wget \
&& rm -rf /var/lib/apt/lists/*

CMD ["bash"]
13 changes: 13 additions & 0 deletions ci/test/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target "base" {
context = "."
dockerfile = "./Dockerfile.base"
platforms = ["linux/amd64"]
tags = ["bitcoin-core-base:latest"]
}

target "asan" {
dockerfile = "./Dockerfile.asan"
context = "."
platforms = ["linux/amd64"]
tags = ["bitcoin-core-asan:latest"]
}
9 changes: 9 additions & 0 deletions ci/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[private]
default:
@just --list

base:
docker buildx bake base

asan:
docker buildx bake asan

0 comments on commit c2023de

Please sign in to comment.