Skip to content

Commit 355edb3

Browse files
chaptersixclaude
andcommitted
fix: use env vars in MySQL and Cassandra setup scripts
Apply the same fix from the PostgreSQL scripts to the MySQL and Cassandra setup scripts, replacing hardcoded hostnames, usernames, and ports with compose-provided environment variables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c4f500b commit 355edb3

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

compose/scripts/setup-cassandra-es.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@ set -eu
77
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
88
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
99
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
10+
: "${CASSANDRA_SEEDS:?ERROR: CASSANDRA_SEEDS environment variable is required}"
1011

1112
echo 'Starting Cassandra and Elasticsearch schema setup...'
1213
echo 'Waiting for Cassandra port to be available...'
13-
nc -z -w 10 cassandra 9042
14+
nc -z -w 10 ${CASSANDRA_SEEDS} 9042
1415
echo 'Cassandra port is available'
1516
echo 'Waiting for Cassandra to be ready...'
16-
until temporal-cassandra-tool --ep cassandra validate-health; do
17+
until temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} validate-health; do
1718
echo 'Cassandra not ready yet, waiting...'
1819
sleep 2
1920
done
2021
echo 'Cassandra is ready'
2122

2223
# Create and setup Cassandra keyspace
23-
temporal-cassandra-tool --ep cassandra create -k temporal --rf 1
24-
temporal-cassandra-tool --ep cassandra -k temporal setup-schema -v 0.0
25-
temporal-cassandra-tool --ep cassandra -k temporal update-schema -d /etc/temporal/schema/cassandra/temporal/versioned
24+
temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} create -k temporal --rf 1
25+
temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} -k temporal setup-schema -v 0.0
26+
temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} -k temporal update-schema -d /etc/temporal/schema/cassandra/temporal/versioned
2627

2728
# Setup Elasticsearch index
2829
# temporal-elasticsearch-tool is available in v1.30+ server releases

compose/scripts/setup-mysql-es.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ set -eu
99
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
1010
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
1111

12+
: "${MYSQL_SEEDS:?ERROR: MYSQL_SEEDS environment variable is required}"
13+
: "${MYSQL_USER:?ERROR: MYSQL_USER environment variable is required}"
14+
1215
echo 'Starting MySQL and Elasticsearch schema setup...'
1316
echo 'Waiting for MySQL port to be available...'
14-
nc -z -w 10 mysql 3306
17+
nc -z -w 10 ${MYSQL_SEEDS} ${DB_PORT:-3306}
1518
echo 'MySQL port is available'
1619

1720
# Create and setup temporal database
18-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal create
19-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal setup-schema -v 0.0
20-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned
21+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal create
22+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal setup-schema -v 0.0
23+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned
2124

2225
# Setup Elasticsearch index
2326
# temporal-elasticsearch-tool is available in v1.30+ server releases

compose/scripts/setup-mysql.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
# @@@SNIPSTART compose-mysql-setup
33
set -eu
44

5+
# Validate required environment variables
6+
: "${MYSQL_SEEDS:?ERROR: MYSQL_SEEDS environment variable is required}"
7+
: "${MYSQL_USER:?ERROR: MYSQL_USER environment variable is required}"
8+
59
echo 'Starting MySQL schema setup...'
610
echo 'Waiting for MySQL port to be available...'
7-
nc -z -w 10 mysql 3306
11+
nc -z -w 10 ${MYSQL_SEEDS} ${DB_PORT:-3306}
812
echo 'MySQL port is available'
913

1014
# Create and setup temporal database
11-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal create
12-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal setup-schema -v 0.0
13-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned
15+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal create
16+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal setup-schema -v 0.0
17+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned
1418

1519
# Create and setup visibility database
16-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility create
17-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility setup-schema -v 0.0
18-
temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility update-schema -d /etc/temporal/schema/mysql/v8/visibility/versioned
20+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal_visibility create
21+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal_visibility setup-schema -v 0.0
22+
temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal_visibility update-schema -d /etc/temporal/schema/mysql/v8/visibility/versioned
1923

2024
echo 'MySQL schema setup complete'
2125
# @@@SNIPEND

0 commit comments

Comments
 (0)