cassandra/.build/docker/debian-build.docker

118 lines
6.0 KiB
Docker

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
FROM debian:bullseye
LABEL org.opencontainers.image.authors="Apache Cassandra <dev@cassandra.apache.org>"
# CONTEXT is expected to be cassandra/.build
ENV DIST_DIR=/dist
ENV BUILD_HOME=/home/build
ENV CASSANDRA_DIR=$BUILD_HOME/cassandra
LABEL org.cassandra.buildenv=debian_build
RUN echo "Building with arguments:" \
&& echo " - DIST_DIR=${DIST_DIR}" \
&& echo " - BUILD_HOME=${BUILD_HOME}" \
&& echo " - CASSANDRA_DIR=${CASSANDRA_DIR}"
# configure apt to retry downloads
RUN echo 'APT::Acquire::Retries "99";' > /etc/apt/apt.conf.d/80-retries
RUN echo 'Acquire::http::Timeout "60";' > /etc/apt/apt.conf.d/80proxy.conf
RUN echo 'Acquire::ftp::Timeout "60";' >> /etc/apt/apt.conf.d/80proxy.conf
# install deps
RUN until apt-get update && apt-get -y install ant build-essential curl devscripts ed git sudo \
python3-pip rsync procps dh-python quilt bash-completion pandoc wget ; \
do echo "apt failed… trying again in 10s… " ; sleep 10 ; done
RUN until apt-get install -y --no-install-recommends openjdk-11-jdk openjdk-17-jdk; \
do echo "apt failed… trying again in 10s… " ; sleep 10 ; done
# Download and install OpenJDK 21.0.2 for the current architecture
RUN sh -c '\
set -ex ;\
JDK_OS=linux ;\
JDK_TAR="openjdk-21.0.2_${JDK_OS}-$(uname -m | sed "s/x86_64/x64/")_bin.tar.gz" ;\
JDK_VERSION_SHAS="08db1392a48d4eb5ea5315cf8f18b89dbaf36cda663ba882cf03c704c9257ec2 a2def047a73941e01a73739f92755f86b895811afb1f91243db214cff5bdac3f 8fd09e15dc406387a0aba70bf5d99692874e999bf9cd9208b452b5d76ac922d3 b3d588e16ec1e0ef9805d8a696591bd518a5cea62567da8f53b5ce32d11d22e4" ;\
curl -L --fail --silent --retry 2 --retry-delay 5 --max-time 3600 "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/${JDK_TAR}" -o $JDK_TAR ;\
JDK_SHA="$(sha256sum $JDK_TAR | cut -d" " -f2)" ;\
echo "$JDK_VERSION_SHAS" | sed "s/ /\n/g" | grep -q "$JDK_SHA" || { echo "SHA256 mismatch for $JDK_TAR $JDK_SHA"; exit 1; } ;\
mkdir -p /usr/lib/jvm/java-21-openjdk-$(dpkg --print-architecture) ;\
tar -C /usr/lib/jvm/java-21-openjdk-$(dpkg --print-architecture) --strip-components=1 -xzf $JDK_TAR ;\
rm $JDK_TAR'
# Add OpenJDK 21 to update-alternatives
RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-21-openjdk-$(dpkg --print-architecture)/bin/java 1
RUN update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-21-openjdk-$(dpkg --print-architecture)/bin/javac 1
RUN update-alternatives --set java /usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)/bin/java
RUN update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)/bin/javac
# python3 is needed for the gen-doc target
RUN pip install --upgrade pip
# dependencies for .build/ci/ci_parser.py
RUN pip install beautifulsoup4==4.12.3 jinja2==3.1.3
# Install Node.js for Antora (documentation generation)
RUN sh -c '\
set -ex ;\
NODE_VERSION="v20.16.0" ;\
NODE_PLATFORM=x64 ;\
[ $(uname -m) = "aarch64" ] && NODE_PLATFORM=arm64 ;\
NODE_VERSION_SHAS="c30af7dfea46de7d8b9b370fa33b8b15440bc93f0a686af8601bbb48b82f16c0 1d9929e72f692179f884cd676b2dfabd879cb77defa7869dc8cfc802619277fb" ;\
NODE_TAR="node-${NODE_VERSION}-linux-${NODE_PLATFORM}.tar.xz" ;\
wget "https://nodejs.org/dist/${NODE_VERSION}/${NODE_TAR}" --no-check-certificate ;\
NODE_SHA="$(sha256sum ${NODE_TAR} | cut -d" " -f1)" ;\
echo "$NODE_VERSION_SHAS" | sed "s/ /\n/g" | grep -q "$NODE_SHA" || { echo "SHA256 mismatch for ${NODE_TAR} ${NODE_SHA}"; exit 1; } ;\
tar -xJf "${NODE_TAR}" -C /usr/local --strip-components=1 ;\
rm "${NODE_TAR}" ;\
ln -s /usr/local/bin/node /usr/local/bin/nodejs'
# Install Antora for documentation generation
RUN npm i -g @antora/cli@2.3 @antora/site-generator-default@2.3 @djencks/asciidoctor-openblock
# install golang. GO_VERSION_SHA must be updated with VERSION
RUN sh -c '\
set -ex ;\
GO_VERSION="1.26.1" ;\
GO_VERSION_SHAS="031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7 65773dab2f8cc4cd23d93ba6d0a805de150ca0b78378879292be0b903b8cdd08 353df43a7811ce284c8938b5f3c7df40b7bfb6f56cb165b150bc40b5e2dd541f" ;\
GO_OS=linux ;\
GO_TAR="go${GO_VERSION}.${GO_OS}-$(dpkg --print-architecture).tar.gz" ;\
curl -L --fail --silent --retry 2 --retry-delay 5 --max-time 3600 https://go.dev/dl/$GO_TAR -o $GO_TAR ;\
GO_SHA="$(sha256sum $GO_TAR | cut -d" " -f2)" ;\
echo "$GO_VERSION_SHAS" | sed "s/ /\n/g" | grep -q "$GO_SHA" || { echo "SHA256 mismatch for $GO_TAR $GO_SHA"; exit 1; } ;\
tar -C /usr/local -xzf $GO_TAR ;\
rm $GO_TAR'
ENV GOROOT="/usr/local/go"
ENV GOPATH="$BUILD_HOME/go"
ENV PATH="$PATH:/usr/local/go/bin"
# allow lower UIDs and GIDs
RUN sed -i 's/UID_MIN 1000/UID_MIN 100/' /etc/login.defs
RUN sed -i 's/UID_MIN 1000/UID_MIN 10/' /etc/login.defs
# suppress warnings about mismatching ownership
RUN git config --global --add safe.directory ${CASSANDRA_DIR}
# Prepopulate Maven repository with dependencies from all branches. see _create_user.sh
COPY docker/_prepopulate_maven_deps.sh /tmp/_prepopulate_maven_deps.sh
RUN mkdir -p /home/image-cache && chmod -R a+rwx /home/image-cache
RUN bash /tmp/_prepopulate_maven_deps.sh /home/image-cache/.m2/repository && rm /tmp/_prepopulate_maven_deps.sh
RUN cp -a /root/.gradle /home/image-cache/.gradle