diff --git a/cassandra/Dockerfile b/cassandra/Dockerfile new file mode 100644 index 00000000..0f8f6136 --- /dev/null +++ b/cassandra/Dockerfile @@ -0,0 +1,30 @@ +FROM itzg/ubuntu-openjdk-7 + +MAINTAINER itzg + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y wget && \ + apt-get clean + +ENV CASSANDRA_VERSION 2.0.12 + +RUN wget -qO /tmp/apache-cassandra.tgz http://mirrors.ibiblio.org/apache/cassandra/$CASSANDRA_VERSION/apache-cassandra-$CASSANDRA_VERSION-bin.tar.gz +RUN tar -C /opt -zxvf /tmp/apache-cassandra.tgz && \ + rm /tmp/apache-cassandra.tgz + + +RUN mv /opt/apache-cassandra-$CASSANDRA_VERSION /opt/cassandra +ENV CASSANDRA_HOME /opt/cassandra +ENV CASSANDRA_CONF /conf +ENV CASSANDRA_DATA /data +WORKDIR $CASSANDRA_HOME + +RUN ln -s $CASSANDRA_HOME/bin/* /usr/local/bin +VOLUME ["/data","/conf"] + +EXPOSE 9042 9160 7000 7001 + +ADD cassandra.in.sh $CASSANDRA_HOME/cassandra.in.sh +RUN mv $CASSANDRA_HOME/bin/cassandra.in.sh $CASSANDRA_HOME/bin/orig.cassandra.in.sh + +CMD ["/opt/cassandra/bin/cassandra", "-f"] diff --git a/cassandra/README.md b/cassandra/README.md new file mode 100644 index 00000000..0b526f56 --- /dev/null +++ b/cassandra/README.md @@ -0,0 +1,9 @@ +Yet another Cassandra image, but this one got container and non-container access right. + +# Basic Usage + +To support access from both Docker containers and external, non-Docker clients: + + docker run -d --name cassandra -e PUBLISH_AS=192.168.59.103 -p 9160:9160 itzg/cassandra + +replacing `192.168.59.103` with your Docker host's LAN IP address. diff --git a/cassandra/cassandra.in.sh b/cassandra/cassandra.in.sh new file mode 100755 index 00000000..a2237a85 --- /dev/null +++ b/cassandra/cassandra.in.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +sed -i -e 's/log4j.rootLogger=.*/log4j.rootLogger=INFO,stdout/' $CASSANDRA_HOME/conf/log4j-server.properties + +cassYml=$CASSANDRA_HOME/conf/cassandra.yaml + +privateAddr=$(hostname -i) + +seeds=${SEEDS:-${PUBLISH_AS:-$privateAddr}} + +sed -i -e "s/- seeds:.*/- seeds: \"$seeds\"/" $cassYml + +sed -i -e "s/listen_address:.*/listen_address: $privateAddr/" $cassYml +sed -i -e "s/rpc_address:.*/rpc_address: $privateAddr/" $cassYml + +sed -i -e "s#- /var/lib/cassandra/data#- $CASSANDRA_DATA#" $cassYml + +if [ -n "$PUBLISH_AS" ]; then + sed -i -e "s/\(\s*#\)\?\s*broadcast_address:.*/broadcast_address: $PUBLISH_AS/" $cassYml +fi + +# Copy over our tweaked files, but non-clobbering to let user have ultimate control +cp -rn $CASSANDRA_HOME/conf/* $CASSANDRA_CONF + +# source the original +. $CASSANDRA_HOME/bin/orig.cassandra.in.sh +