Add Cassandra support and update README.md

This commit is contained in:
2024-03-10 22:33:35 +04:00
parent fa999fea14
commit 89237193f4
12 changed files with 335 additions and 1 deletions

View File

@ -0,0 +1,6 @@
FROM cassandra:4
RUN sed -i -r 's/authenticator: AllowAllAuthenticator/authenticator: PasswordAuthenticator/' /etc/cassandra/cassandra.yaml
# RUN sed -i -r 's/user_defined_functions_enabled: false/user_defined_functions_enabled: true/' /etc/cassandra/cassandra.yaml
CMD ["cassandra", "-f"]

View File

@ -0,0 +1,6 @@
FROM cassandra:4
COPY init-cassandra.sh /init-cassandra.sh
RUN chmod +x init-cassandra.sh
CMD ["/init-cassandra.sh"]

View File

@ -0,0 +1,5 @@
CASSANDRA_USERNAME=username
CASSANDRA_PASSWORD=password
CASSANDRA_KEYSPACE=keyspace
MAX_HEAP_SIZE=2G
HEAP_NEWSIZE=500M

View File

@ -0,0 +1,19 @@
#!/bin/bash
if [ -z "$CASSANDRA_USERNAME" ] || [ -z "$CASSANDRA_PASSWORD" ]; then
echo "Error: Username or password environment variables are not set."
exit 1
fi
until cqlsh -u cassandra -p cassandra -e "DESCRIBE KEYSPACES" ohmyurl-cassandra-1 || cqlsh -u $CASSANDRA_USERNAME -p $CASSANDRA_PASSWORD -e "DESCRIBE KEYSPACES" ohmyurl-cassandra-1; do
echo >&2 "Cassandra is unavailable - sleeping"
sleep 1
done
echo >&2 "Cassandra is up - executing command"
cqlsh -u cassandra -p cassandra -e "CREATE ROLE IF NOT EXISTS $CASSANDRA_USERNAME WITH PASSWORD = '$CASSANDRA_PASSWORD' AND SUPERUSER = true AND LOGIN = true;" ohmyurl-cassandra-1
cqlsh -u $CASSANDRA_USERNAME -p $CASSANDRA_PASSWORD -e "ALTER ROLE cassandra WITH PASSWORD='abcdef' AND SUPERUSER=false AND LOGIN = false;" ohmyurl-cassandra-1
cqlsh -u $CASSANDRA_USERNAME -p $CASSANDRA_PASSWORD -e "CREATE KEYSPACE IF NOT EXISTS $CASSANDRA_KEYSPACE WITH REPLICATION = {'class': 'NetworkTopologyStrategy', 'datacenter1': 3};" ohmyurl-cassandra-1
exit 0