Cassandra single instance Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM abh1nav/java7 | |
# Download and extract Cassandra | |
RUN \ | |
mkdir /opt/cassandra; \ | |
wget -O - http://www.us.apache.org/dist/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz \ | |
| tar xzf - --strip-components=1 -C "/opt/cassandra"; | |
ADD cassandra.yaml /opt/cassandra/conf/ | |
ADD run.sh /tmp/ | |
# Expose ports | |
EXPOSE 7199 | |
WORKDIR /opt/cassandra | |
CMD ["/tmp/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Grab the container IP | |
ADDR=$(/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') | |
echo "IP Address is: $ADDR" | |
# Check if a seed was provided | |
SEED=${SEED:=$ADDR} | |
echo "Seed is: $SEED" | |
if [ ! -f /root/.cassconfig ]; then | |
echo "Filling in the blanks inside cassandra.yaml" | |
# Target files | |
ENV_FILE=/opt/cassandra/conf/cassandra-env.sh | |
CONF_FILE=/opt/cassandra/conf/cassandra.yaml | |
# Add heap settings | |
echo MAX_HEAP_SIZE="4G" >> $ENV_FILE | |
echo HEAP_NEWSIZE="800M" >> $ENV_FILE | |
# Add broadcast IPs | |
echo "listen_address: $ADDR" >> $CONF_FILE | |
echo "broadcast_rpc_address: $ADDR" >> $CONF_FILE | |
echo "rpc_address: 0.0.0.0" >> $CONF_FILE | |
# Add seed info | |
echo "seed_provider:" >> $CONF_FILE | |
echo " - class_name: org.apache.cassandra.locator.SimpleSeedProvider" >> $CONF_FILE | |
echo " parameters:" >> $CONF_FILE | |
echo " - seeds: \"$SEED\"" >> $CONF_FILE | |
touch /root/.cassconfig | |
fi | |
# Start server | |
cd /opt/cassandra | |
bin/cassandra -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment