You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sdap.apache.org by GitBox <gi...@apache.org> on 2018/09/10 23:33:52 UTC

[GitHub] fgreg closed pull request #30: SDAP-139 Update Cassandra Image Version

fgreg closed pull request #30: SDAP-139 Update Cassandra Image Version
URL: https://github.com/apache/incubator-sdap-nexus/pull/30
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/data-access/config/schemas/cassandra/nexustiles.cql b/data-access/config/schemas/cassandra/nexustiles.cql
index f0b8e36..43304a7 100644
--- a/data-access/config/schemas/cassandra/nexustiles.cql
+++ b/data-access/config/schemas/cassandra/nexustiles.cql
@@ -1,8 +1,6 @@
 CREATE KEYSPACE IF NOT EXISTS nexustiles WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
 
-DROP TABLE IF EXISTS nexustiles.sea_surface_temp;
-
-CREATE TABLE nexustiles.sea_surface_temp  (
+CREATE TABLE IF NOT EXISTS nexustiles.sea_surface_temp  (
 	tile_id    	uuid PRIMARY KEY,
 	tile_blob  	blob
 );
diff --git a/docker/cassandra/Dockerfile b/docker/cassandra/Dockerfile
index e9c93b7..60acb5a 100644
--- a/docker/cassandra/Dockerfile
+++ b/docker/cassandra/Dockerfile
@@ -13,10 +13,19 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM cassandra:2.2.8
+FROM cassandra:2.2
 
 MAINTAINER Apache SDAP "dev@sdap.apache.org"
 
 RUN apt-get update && apt-get -y install git && rm -rf /var/lib/apt/lists/*
 
-RUN cd / && git clone https://github.com/apache/incubator-sdap-nexus.git && cp -r /incubator-sdap-nexus/data-access/config/schemas/cassandra/nexustiles.cql /tmp/. && rm -rf /incubator-sdap-nexus
+RUN mkdir -p /docker-entrypoint-initdb.d && \
+  chown -R cassandra:cassandra /docker-entrypoint-initdb.d && \
+	chmod 777 /docker-entrypoint-initdb.d && \
+  cd /tmp && \
+  git clone https://github.com/apache/incubator-sdap-nexus.git && \
+  cp -r /tmp/incubator-sdap-nexus/data-access/config/schemas/cassandra/nexustiles.cql /docker-entrypoint-initdb.d/nexustiles.cql && \
+  rm -rf /tmp/incubator-sdap-nexus
+
+COPY docker-entrypoint.sh /usr/local/bin/
+ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/docker/cassandra/docker-entrypoint.sh b/docker/cassandra/docker-entrypoint.sh
new file mode 100755
index 0000000..b6410ed
--- /dev/null
+++ b/docker/cassandra/docker-entrypoint.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+set -e
+
+# first arg is `-f` or `--some-option`
+# or there are no args
+if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
+	set -- cassandra -f "$@"
+fi
+
+# allow the container to be started with `--user`
+if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then
+	chown -R cassandra /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG"
+	exec gosu cassandra "$BASH_SOURCE" "$@"
+fi
+
+_ip_address() {
+	# scrape the first non-localhost IP address of the container
+	# in Swarm Mode, we often get two IPs -- the container IP, and the (shared) VIP, and the container IP should always be first
+	ip address | awk '
+		$1 == "inet" && $NF != "lo" {
+			gsub(/\/.+$/, "", $2)
+			print $2
+			exit
+		}
+	'
+}
+
+if [ "$1" = 'cassandra' ]; then
+	: ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}
+
+	: ${CASSANDRA_LISTEN_ADDRESS='auto'}
+	if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
+		CASSANDRA_LISTEN_ADDRESS="$(_ip_address)"
+	fi
+
+	: ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}
+
+	if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
+		CASSANDRA_BROADCAST_ADDRESS="$(_ip_address)"
+	fi
+	: ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}
+
+	if [ -n "${CASSANDRA_NAME:+1}" ]; then
+		: ${CASSANDRA_SEEDS:="cassandra"}
+	fi
+	: ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"}
+
+	sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"
+
+	for yaml in \
+		broadcast_address \
+		broadcast_rpc_address \
+		cluster_name \
+		endpoint_snitch \
+		listen_address \
+		num_tokens \
+		rpc_address \
+		start_rpc \
+	; do
+		var="CASSANDRA_${yaml^^}"
+		val="${!var}"
+		if [ "$val" ]; then
+			sed -ri 's/^(# )?('"$yaml"':).*/\2 '"$val"'/' "$CASSANDRA_CONFIG/cassandra.yaml"
+		fi
+	done
+
+	for rackdc in dc rack; do
+		var="CASSANDRA_${rackdc^^}"
+		val="${!var}"
+		if [ "$val" ]; then
+			sed -ri 's/^('"$rackdc"'=).*/\1 '"$val"'/' "$CASSANDRA_CONFIG/cassandra-rackdc.properties"
+		fi
+	done
+fi
+
+for f in /docker-entrypoint-initdb.d/*; do
+    case "$f" in
+        *.sh)     echo "$0: running $f"; . "$f" ;;
+        *.cql)    echo "$0: running $f" && until cqlsh -f "$f"; do >&2 echo "Cassandra is unavailable - sleeping"; sleep 2; done & ;;
+        *)        echo "$0: ignoring $f" ;;
+    esac
+    echo
+done
+
+exec "$@"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services