blob: 03ada476cce44d22a95e606790544500eadabfb7 [file] [log] [blame]
FROM debian:bullseye
ENV DEB_DIST_DIR=/dist
ENV BUILD_HOME=/home/build
ENV CASSANDRA_DIR=$BUILD_HOME/cassandra
ARG UID_ARG=1000
ARG GID_ARG=1000
LABEL org.cassandra.buildenv=bullseye
VOLUME ${DEB_DIST_DIR}
RUN echo "Building with arguments:" \
&& echo " - DEB_DIST_DIR=${DEB_DIST_DIR}" \
&& echo " - BUILD_HOME=${BUILD_HOME}" \
&& echo " - CASSANDRA_DIR=${CASSANDRA_DIR}" \
&& echo " - UID_ARG=${UID_ARG}" \
&& echo " - GID_ARG=${GID_ARG}"
# 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 python2 sudo apt-transport-https gpg ; \
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
# jdk8 from adoptium
RUN curl -s https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor \
| tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" \
| tee /etc/apt/sources.list.d/adoptium.list
RUN until apt-get update && apt-get install -y temurin-8-jdk ; \
do echo "apt failed… trying again in 10s… " ; sleep 10 ; done
RUN update-java-alternatives --set temurin-8-jdk-$(dpkg --print-architecture)
# dh-python is incompatible with python-is-python2, so we'll link it ourselves
RUN ln -s /usr/bin/python2 /usr/bin/python
# create and change to build user
RUN groupadd --gid ${GID_ARG} --non-unique build \
&& adduser --uid ${UID_ARG} --gid ${GID_ARG} --disabled-login --gecos build build \
&& gpasswd -a build sudo
RUN echo "build ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/build && \
chmod 0440 /etc/sudoers.d/build
USER build
# clone Cassandra and cache maven artifacts
ARG CASSANDRA_GIT_URL=https://github.com/apache/cassandra.git
RUN git config --global http.postBuffer 524288000
RUN git clone ${CASSANDRA_GIT_URL} ${CASSANDRA_DIR}
WORKDIR ${CASSANDRA_DIR}
COPY build-debs.sh $BUILD_HOME/