| FROM centos:7 |
| |
| ENV BUILD_HOME=/home/build |
| ENV RPM_BUILD_DIR=$BUILD_HOME/rpmbuild |
| ENV RPM_DIST_DIR=/dist |
| ENV CASSANDRA_DIR=$BUILD_HOME/cassandra |
| ENV ANT_VERSION=1.10.12 |
| ARG UID_ARG=1000 |
| ARG GID_ARG=1000 |
| |
| LABEL org.cassandra.buildenv=centos |
| |
| VOLUME ${RPM_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}" |
| |
| # install deps |
| RUN yum -y install \ |
| ant \ |
| git \ |
| java-1.8.0-openjdk-devel \ |
| java-11-openjdk-devel \ |
| make \ |
| rpm-build \ |
| sudo \ |
| python3-pip |
| |
| RUN until curl -f -S -s --retry 9 --retry-delay 1 http://mirror.centos.org/centos/7/os/x86_64/Packages/ant-junit-1.9.4-2.el7.noarch.rpm -o ant-junit-1.9.4-2.el7.noarch.rpm ; do echo "curl failed… trying again in 10s… " ; sleep 10 ; done |
| |
| RUN rpm -i --nodeps ant-junit-1.9.4-2.el7.noarch.rpm |
| |
| # try first downloads.a.o and then archive.a.o (as the latter has a 5GB per IP daily limit) |
| RUN until curl -f -S -s --retry 9 --retry-delay 1 https://downloads.apache.org/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz -o apache-ant-${ANT_VERSION}-bin.tar.gz || curl -f -S -s --retry 9 --retry-delay 1 https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz -o apache-ant-${ANT_VERSION}-bin.tar.gz ; do echo "curl failed… trying again in 10s… " ; sleep 10 ; done |
| |
| RUN rm -rf /etc/ant.conf |
| RUN tar xvf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt |
| RUN ln -sfn /opt/apache-ant-${ANT_VERSION} /opt/ant |
| RUN sh -c 'echo ANT_HOME=/opt/ant >> /etc/environment' |
| RUN ln -sfn /opt/ant/bin/ant /usr/bin/ant |
| |
| # jdk17 latest on x64 |
| RUN if [ "$(arch)" == "x86_64" ] ; then \ |
| until curl -f -S -s --retry 9 --retry-delay 1 https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz -o openjdk-17_bin.tar.gz ; do \ |
| echo "curl failed… trying again in 10s… " ; sleep 10 ; \ |
| done \ |
| fi |
| |
| # jdk17 latest on arm |
| RUN if [ "$(arch)" == "aarch64" ] ; then \ |
| until curl -f -S -s --retry 9 --retry-delay 1 https://download.oracle.com/java/17/latest/jdk-17_linux-aarch64_bin.tar.gz -o openjdk-17_bin.tar.gz ; do \ |
| echo "curl failed… trying again in 10s… " ; sleep 10 ; \ |
| done \ |
| fi |
| |
| RUN tar xvf openjdk-17_bin.tar.gz |
| RUN mv jdk-17* /opt/jdk-17 |
| |
| RUN alternatives --install /usr/bin/java java /opt/jdk-17/bin/java 2 --family java-17-openjdk |
| RUN alternatives --install /usr/bin/javac javac /opt/jdk-17/bin/javac 2 --family java-17-openjdk |
| |
| RUN pip3 install --upgrade pip |
| |
| # create and change to build user |
| RUN groupadd --gid ${GID_ARG} --non-unique build \ |
| && adduser --uid ${UID_ARG} --gid ${GID_ARG} build |
| RUN echo "build ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/build && \ |
| chmod 0440 /etc/sudoers.d/build |
| |
| USER build |
| |
| RUN mkdir -p $RPM_BUILD_DIR/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} |
| |
| # 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-rpms.sh $BUILD_HOME/ |