Skip to content

Commit

Permalink
docker: add a bookworm image
Browse files Browse the repository at this point in the history
This updates Python to 3.11 and OpenJDK to 1.17.
  • Loading branch information
jgriffiths committed Nov 27, 2024
1 parent 9786b51 commit 5f07455
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
17 changes: 17 additions & 0 deletions contrib/Dockerfile_bookworm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Dockerfile for wally builds on Debain bookworm (stable).
# build from this directory with e.g:
# docker buildx build --platform linux/arm64,linux/amd64 -f Dockerfile_bullseye -t greenaddress/wallycore:bookworm .
#
# Note that to build both platforms you need to:
# apt install qemu-user-static binfmt-support
#
FROM debian:bookworm@sha256:10901ccd8d249047f9761845b4594f121edef079cfd8224edebd9ea726f0a7f6
WORKDIR /root
COPY bookworm_deps.sh ./deps.sh
COPY requirements.txt ./contrib/requirements.txt
ARG TARGETARCH
ENV TARGETARCH=${TARGETARCH}
ENV JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-${TARGETARCH}
RUN ./deps.sh && rm ./deps.sh
ENV ANDROID_NDK=/opt/android-ndk-r26b
2 changes: 1 addition & 1 deletion contrib/Dockerfile_bullseye
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Dockerfile for wally builds.
# Dockerfile for wally builds on Debain bullseye (oldstable).
# build from this directory with e.g:
# DOCKER_BUILDKIT=1 docker build . -t greenaddress/wallycore -f Dockerfile_bullseye
# and for linux/arm64:
Expand Down
85 changes: 85 additions & 0 deletions contrib/bookworm_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#! /usr/bin/env bash
# Install required dependencies for building wally
# Options:
# -e : Don't install emsdk (used for JS builds)
# -j : Don't install Java SDK (used for Java builds)
# -n : Don't install Android NDK (used for Android builds)
# -w : Don't install MinGW (used for Windows cross compiles)
set -e

skip_emsdk=
skip_ndk=
skip_java=
skip_windows=
while getopts enjw name
do
case $name in
e) skip_emsdk=1;;
n) skip_ndk=1;;
j) skip_java=1;;
w) skip_windows=1;;
*) echo "Invalid flag"; exit 1;;
esac
done
shift $(($OPTIND - 1))

apt update -qq
apt upgrade -yqq

java_packages=
if [ -z "$skip_java" ]; then
java_packages="openjdk-17-jdk openjdk-17-jre"
fi
windows_packages=
if [ -z "$skip_windows" ]; then
windows_packages="g++-mingw-w64-x86-64"
fi
apt install --no-install-recommends unzip autoconf automake autotools-dev pkg-config build-essential libtool python3{,-dev,-pip,-virtualenv} python{,-dev}-is-python3 clang{,-format,-tidy} git swig curl cmake libssl-dev libtool-bin $java_packages curl $windows_packages valgrind jq -yqq

if [ -z "$skip_java" ]; then
update-java-alternatives -s $(basename ${JAVA_HOME})
fi

# Note --break-system-packages to allow installing our requirements system-wide
pip install valgrind-codequality -r contrib/requirements.txt --break-system-packages

pushd /opt

if [ -z "$skip_ndk" ]; then
curl -L -o ndk.zip https://dl.google.com/android/repository/android-ndk-r26b-linux.zip
echo "ad73c0370f0b0a87d1671ed2fd5a9ac9acfd1eb5c43a7fbfbd330f85d19dd632 ndk.zip" | shasum -a 256 -c
unzip ndk.zip
rm ndk.zip
fi

if [ -z "$skip_emsdk" ]; then
# Install node 20
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install nodejs -yqq
# Install emsdk
git clone https://github.com/emscripten-core/emsdk
cd emsdk
EMSDK_VERSION=3.1.52
if [ "${TARGETARCH}" = "arm64" ]; then
# very few versions of emsdk are available for linux-arm64
# https://github.com/emscripten-core/emsdk/issues/547
EMSDK_VERSION=3.1.33
fi
./emsdk install ${EMSDK_VERSION}
./emsdk activate ${EMSDK_VERSION}
# Force emsdk to use the installed node version instead of its own
sed -i "s/^NODE_JS = .*$/NODE_JS = 'node'/g" /opt/emsdk/.emscripten
# Make emsdk commands available
source ./emsdk_env.sh
fi

if [ -f /.dockerenv ]; then
# Installing dependencies into a docker image.
# Purge uneeded files to keep the image as small as possible.
apt remove --purge curl unzip -yqq
apt -yqq autoremove
apt -yqq clean
rm -rf /var/lib/apt/lists/* /var/cache/* /tmp/* /usr/share/locale/* /usr/share/man /usr/share/doc /lib/xtables/libip6* /root/.cache
fi

popd

0 comments on commit 5f07455

Please sign in to comment.