Created
July 16, 2024 20:37
-
-
Save sombriks/aa3b476b4c166d2fbb1027ca0679b27f to your computer and use it in GitHub Desktop.
cassandra and init script via init-image strategy
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
#!/usr/bin/env bash | |
export RESULT=-1 | |
until [ $RESULT -eq 0 ]; do | |
sleep 3; | |
echo "attempt to create keyspace" | |
cqlsh cassandra-local \ | |
-u cassandra \ | |
-p cassandra \ | |
-e "create keyspace if not exists my_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};" | |
RESULT=$? | |
done | |
echo "keyspace created" |
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
# | |
# start this compose if you plan to use the 'local' profile and test things in a | |
# running app without rely on AWS Keyspaces | |
# | |
--- | |
services: | |
cassandra-local: | |
image: cassandra:3.11 | |
ports: | |
- "9042:9042" | |
# https://dev.to/dripto/execute-startup-scripts-in-cassandra-docker-cp2 | |
init-cassandra: | |
image: cassandra:3.11 | |
depends_on: [cassandra-local] | |
restart: "no" | |
entrypoint: ["sh", "/cassandra-init.sh"] | |
volumes: | |
- ./cassandra-init.sh:/cassandra-init.sh | |
postgres-local: | |
image: postgres:16-alpine | |
ports: | |
- "5432:5432" | |
environment: | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} | |
POSTGRES_USER: ${POSTGRES_USER:-postgres} | |
POSTGRES_DB: ${POSTGRES_DB:-myrealdb} | |
volumes: | |
- ../test/resources/initial.sql:/docker-entrypoint-initdb.d/init.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment