You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2020/04/14 13:22:14 UTC

[cassandra-builds] branch master updated: added Docker image for Debian Buster

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cassandra-builds.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f7f4ba  added Docker image for Debian Buster
1f7f4ba is described below

commit 1f7f4baa37139d2d31284921305e7b7c77af8bbd
Author: Stefan Miklosovic <st...@instaclustr.com>
AuthorDate: Mon Apr 6 10:28:00 2020 +0200

    added Docker image for Debian Buster
---
 README.md                  |  8 +++++++-
 docker/build-debs.sh       | 25 +++++++++++++++++++++++--
 docker/buster-image.docker | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 249037a..de88ae6 100644
--- a/README.md
+++ b/README.md
@@ -17,11 +17,17 @@
    ```docker build -t cass-build-rpms -f docker/centos7-image.docker docker/```
    The image will contain a clone of the Apache git repository by default. Using a different repository is possible by adding the `--build-arg CASSANDRA_GIT_URL=https://github.com/myuser/cassandra.git` parameter. All successive builds will be executed based on the repository cloned during docker image creation.
 2. Run build script through docker (specify branch, e.g. cassandra-3.0 and version, e.g. 3.0.11):
-   * Debian:
+   * Debian Jessie:
     ```docker run --rm -v `pwd`/dist:/dist `docker images -f label=org.cassandra.buildenv=jessie -q` /home/build/build-debs.sh <branch/tag>```
+   * Debian Buster
+    ```docker run --rm -v `pwd`/dist:/dist `docker images -f label=org.cassandra.buildenv=buster -q` /home/build/build-debs.sh <branch/tag>```
    * RPM:
     ```docker run --rm -v `pwd`/dist:/dist `docker images -f label=org.cassandra.buildenv=centos -q` /home/build/build-rpms.sh <branch/tag>```
 
+For the build by Debian Buster, you have the possibility to build Cassandra either by Java 8 (default) or by Java 11. You control the Java version like following. If you want to build with Java 8, just omit that last option.
+
+```docker run --rm -v `pwd`/dist:/dist `docker images -f label=org.cassandra.buildenv=buster -q` /home/build/build-debs.sh <branch/tag> 11```
+
 You should find newly created Debian and RPM packages in the `dist` directory.
 
 ### Note about versioning
diff --git a/docker/build-debs.sh b/docker/build-debs.sh
index 7da1d97..5aeec0a 100755
--- a/docker/build-debs.sh
+++ b/docker/build-debs.sh
@@ -1,12 +1,25 @@
 #!/bin/bash -x
 set -e
 
-if [ "$#" -ne 1 ]; then
-   echo "$0 <branch>"
+if [ "$#" -lt 1 ]; then
+   echo "$0 <branch> <java version>"
+   echo "if Java version is not set, it is set to 8 by default, choose from 8 or 11"
    exit 1
 fi
 
 CASSANDRA_BRANCH=$1
+JAVA_VERSION=$2
+
+if [ "$JAVA_VERSION" = "" ]; then
+    JAVA_VERSION=8
+fi
+
+regx_java_version="(8|11)"
+
+if [[ ! "$JAVA_VERSION" =~ $regx_java_version ]]; then
+   echo "Error: Java version is not set to 8 nor 11, it is set to $JAVA_VERSION"
+   exit 1
+fi
 
 cd $CASSANDRA_DIR
 git fetch
@@ -76,6 +89,14 @@ if [ $buildxml_version != $git_version ]; then
    exit 4
 fi
 
+if [ $JAVA_VERSION = "11" ]; then
+   sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
+   export CASSANDRA_USE_JDK11=true
+   echo "Cassandra will be built with Java 11"
+else
+   echo "Cassandra will be built with Java 8"
+fi
+
 # Install build dependencies and build package
 echo "y" | sudo mk-build-deps --install
 dpkg-buildpackage -uc -us
diff --git a/docker/buster-image.docker b/docker/buster-image.docker
new file mode 100644
index 0000000..08106ab
--- /dev/null
+++ b/docker/buster-image.docker
@@ -0,0 +1,42 @@
+FROM debian:buster
+
+ENV DEB_DIST_DIR=/dist
+ENV BUILD_HOME=/home/build
+ENV CASSANDRA_DIR=$BUILD_HOME/cassandra
+
+LABEL org.cassandra.buildenv=buster
+
+VOLUME ${DEB_DIST_DIR}
+
+# install deps
+RUN apt-get update && apt-get -y install \
+   ant \
+   build-essential \
+   curl \
+   devscripts \
+   git \
+   sudo \
+   python-sphinx \
+   python-sphinx-rtd-theme
+
+RUN echo 'deb http://ftp.debian.org/debian stretch main' >> /etc/apt/sources.list \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends openjdk-8-jdk openjdk-11-jdk \
+    && sed -i '$d' /etc/apt/sources.list \
+    && apt-get update \
+    && update-java-alternatives --set java-1.8.0-openjdk-amd64
+
+# create and change to build user
+RUN adduser --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://gitbox.apache.org/repos/asf/cassandra.git
+RUN git clone ${CASSANDRA_GIT_URL} ${CASSANDRA_DIR}
+WORKDIR ${CASSANDRA_DIR}
+RUN ant maven-ant-tasks-retrieve-build
+
+COPY build-debs.sh $BUILD_HOME/


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org