From c4f500be8955dbba47532481a6b8562d1ced9fd8 Mon Sep 17 00:00:00 2001 From: ypianykh Date: Fri, 20 Feb 2026 17:20:32 +0100 Subject: [PATCH 1/2] Fix scripts for docker-compose examples to honor PostgreSQL/OpenSearch env vars Changing PostgreSQL/OpenSearch settings in compose/scripts (db host, db username) could crash on first startup because init scripts were effectively using defaults instead of the compose-provided environment. Align the example configs so init scripts honor the environment variables passed from docker-compose. --- compose/scripts/setup-postgres-es-tls.sh | 10 ++++++---- compose/scripts/setup-postgres-es.sh | 11 +++++++---- compose/scripts/setup-postgres-opensearch.sh | 11 +++++++---- compose/scripts/setup-postgres.sh | 18 +++++++++++------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/compose/scripts/setup-postgres-es-tls.sh b/compose/scripts/setup-postgres-es-tls.sh index 5b77c60..d6e1709 100755 --- a/compose/scripts/setup-postgres-es-tls.sh +++ b/compose/scripts/setup-postgres-es-tls.sh @@ -9,17 +9,19 @@ set -eu : "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}" : "${ES_USER:?ERROR: ES_USER environment variable is required}" : "${ES_PWD:?ERROR: ES_PWD environment variable is required}" + +: "${POSTGRES_SEEDS:?ERROR: POSTGRES_SEEDS environment variable is required}" : "${POSTGRES_USER:?ERROR: POSTGRES_USER environment variable is required}" echo 'Starting PostgreSQL and Elasticsearch (TLS) schema setup...' echo 'Waiting for PostgreSQL port to be available...' -nc -z -w 10 postgresql ${POSTGRES_DEFAULT_PORT:-5432} +nc -z -w 10 ${POSTGRES_SEEDS} ${POSTGRES_DEFAULT_PORT:-5432} echo 'PostgreSQL port is available' # Create and setup temporal database with TLS -temporal-sql-tool --plugin postgres12 --ep postgresql -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt create -temporal-sql-tool --plugin postgres12 --ep postgresql -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt setup-schema -v 0.0 -temporal-sql-tool --plugin postgres12 --ep postgresql -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt create +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt setup-schema -v 0.0 +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${POSTGRES_DEFAULT_PORT:-5432} --db temporal --tls --tls-ca-file /usr/local/share/ca-certificates/ca.crt update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned # Setup Elasticsearch index with TLS # temporal-elasticsearch-tool is available in v1.30+ server releases diff --git a/compose/scripts/setup-postgres-es.sh b/compose/scripts/setup-postgres-es.sh index ded7e32..5393525 100755 --- a/compose/scripts/setup-postgres-es.sh +++ b/compose/scripts/setup-postgres-es.sh @@ -8,15 +8,18 @@ set -eu : "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}" : "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}" +: "${POSTGRES_SEEDS:?ERROR: POSTGRES_SEEDS environment variable is required}" +: "${POSTGRES_USER:?ERROR: POSTGRES_USER environment variable is required}" + echo 'Starting PostgreSQL and Elasticsearch schema setup...' echo 'Waiting for PostgreSQL port to be available...' -nc -z -w 10 postgresql 5432 +nc -z -w 10 ${POSTGRES_SEEDS} ${DB_PORT:-5432} echo 'PostgreSQL port is available' # Create and setup temporal database -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal create -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal setup-schema -v 0.0 -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal create +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal setup-schema -v 0.0 +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned # Setup Elasticsearch index # temporal-elasticsearch-tool is available in v1.30+ server releases diff --git a/compose/scripts/setup-postgres-opensearch.sh b/compose/scripts/setup-postgres-opensearch.sh index 6aa7466..0005217 100755 --- a/compose/scripts/setup-postgres-opensearch.sh +++ b/compose/scripts/setup-postgres-opensearch.sh @@ -8,15 +8,18 @@ set -eu : "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}" : "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}" +: "${POSTGRES_SEEDS:?ERROR: POSTGRES_SEEDS environment variable is required}" +: "${POSTGRES_USER:?ERROR: POSTGRES_USER environment variable is required}" + echo 'Starting PostgreSQL and OpenSearch schema setup...' echo 'Waiting for PostgreSQL port to be available...' -nc -z -w 10 postgresql 5432 +nc -z -w 10 ${POSTGRES_SEEDS} ${DB_PORT:-5432} echo 'PostgreSQL port is available' # Create and setup temporal database -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal create -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal setup-schema -v 0.0 -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal create +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal setup-schema -v 0.0 +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned # Setup OpenSearch index # temporal-elasticsearch-tool is available in v1.30+ server releases diff --git a/compose/scripts/setup-postgres.sh b/compose/scripts/setup-postgres.sh index 4d150d5..7e62e7e 100755 --- a/compose/scripts/setup-postgres.sh +++ b/compose/scripts/setup-postgres.sh @@ -2,20 +2,24 @@ # @@@SNIPSTART compose-postgres-setup set -eu +# Validate required environment variables +: "${POSTGRES_SEEDS:?ERROR: POSTGRES_SEEDS environment variable is required}" +: "${POSTGRES_USER:?ERROR: POSTGRES_USER environment variable is required}" + echo 'Starting PostgreSQL schema setup...' echo 'Waiting for PostgreSQL port to be available...' -nc -z -w 10 postgresql 5432 +nc -z -w 10 ${POSTGRES_SEEDS} ${DB_PORT:-5432} echo 'PostgreSQL port is available' # Create and setup temporal database -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal create -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal setup-schema -v 0.0 -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal create +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal setup-schema -v 0.0 +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned # Create and setup visibility database -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal_visibility create -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal_visibility setup-schema -v 0.0 -temporal-sql-tool --plugin postgres12 --ep postgresql -u temporal -p 5432 --db temporal_visibility update-schema -d /etc/temporal/schema/postgresql/v12/visibility/versioned +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal_visibility create +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal_visibility setup-schema -v 0.0 +temporal-sql-tool --plugin postgres12 --ep ${POSTGRES_SEEDS} -u ${POSTGRES_USER} -p ${DB_PORT:-5432} --db temporal_visibility update-schema -d /etc/temporal/schema/postgresql/v12/visibility/versioned echo 'PostgreSQL schema setup complete' # @@@SNIPEND \ No newline at end of file From 355edb38519faa86ccae9a9a615bfaf862ad3e6c Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Sat, 7 Mar 2026 00:21:14 -0600 Subject: [PATCH 2/2] 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 --- compose/scripts/setup-cassandra-es.sh | 11 ++++++----- compose/scripts/setup-mysql-es.sh | 11 +++++++---- compose/scripts/setup-mysql.sh | 18 +++++++++++------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/compose/scripts/setup-cassandra-es.sh b/compose/scripts/setup-cassandra-es.sh index 42fce55..968de7a 100755 --- a/compose/scripts/setup-cassandra-es.sh +++ b/compose/scripts/setup-cassandra-es.sh @@ -7,22 +7,23 @@ set -eu : "${ES_PORT:?ERROR: ES_PORT environment variable is required}" : "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}" : "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}" +: "${CASSANDRA_SEEDS:?ERROR: CASSANDRA_SEEDS environment variable is required}" echo 'Starting Cassandra and Elasticsearch schema setup...' echo 'Waiting for Cassandra port to be available...' -nc -z -w 10 cassandra 9042 +nc -z -w 10 ${CASSANDRA_SEEDS} 9042 echo 'Cassandra port is available' echo 'Waiting for Cassandra to be ready...' -until temporal-cassandra-tool --ep cassandra validate-health; do +until temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} validate-health; do echo 'Cassandra not ready yet, waiting...' sleep 2 done echo 'Cassandra is ready' # Create and setup Cassandra keyspace -temporal-cassandra-tool --ep cassandra create -k temporal --rf 1 -temporal-cassandra-tool --ep cassandra -k temporal setup-schema -v 0.0 -temporal-cassandra-tool --ep cassandra -k temporal update-schema -d /etc/temporal/schema/cassandra/temporal/versioned +temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} create -k temporal --rf 1 +temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} -k temporal setup-schema -v 0.0 +temporal-cassandra-tool --ep ${CASSANDRA_SEEDS} -k temporal update-schema -d /etc/temporal/schema/cassandra/temporal/versioned # Setup Elasticsearch index # temporal-elasticsearch-tool is available in v1.30+ server releases diff --git a/compose/scripts/setup-mysql-es.sh b/compose/scripts/setup-mysql-es.sh index 731a1da..f2491d7 100755 --- a/compose/scripts/setup-mysql-es.sh +++ b/compose/scripts/setup-mysql-es.sh @@ -9,15 +9,18 @@ set -eu : "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}" : "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}" +: "${MYSQL_SEEDS:?ERROR: MYSQL_SEEDS environment variable is required}" +: "${MYSQL_USER:?ERROR: MYSQL_USER environment variable is required}" + echo 'Starting MySQL and Elasticsearch schema setup...' echo 'Waiting for MySQL port to be available...' -nc -z -w 10 mysql 3306 +nc -z -w 10 ${MYSQL_SEEDS} ${DB_PORT:-3306} echo 'MySQL port is available' # Create and setup temporal database -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal create -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal setup-schema -v 0.0 -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal create +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal setup-schema -v 0.0 +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 # Setup Elasticsearch index # temporal-elasticsearch-tool is available in v1.30+ server releases diff --git a/compose/scripts/setup-mysql.sh b/compose/scripts/setup-mysql.sh index 5b1a0dc..f47896f 100755 --- a/compose/scripts/setup-mysql.sh +++ b/compose/scripts/setup-mysql.sh @@ -2,20 +2,24 @@ # @@@SNIPSTART compose-mysql-setup set -eu +# Validate required environment variables +: "${MYSQL_SEEDS:?ERROR: MYSQL_SEEDS environment variable is required}" +: "${MYSQL_USER:?ERROR: MYSQL_USER environment variable is required}" + echo 'Starting MySQL schema setup...' echo 'Waiting for MySQL port to be available...' -nc -z -w 10 mysql 3306 +nc -z -w 10 ${MYSQL_SEEDS} ${DB_PORT:-3306} echo 'MySQL port is available' # Create and setup temporal database -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal create -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal setup-schema -v 0.0 -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal update-schema -d /etc/temporal/schema/mysql/v8/temporal/versioned +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal create +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal setup-schema -v 0.0 +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 # Create and setup visibility database -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility create -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility setup-schema -v 0.0 -temporal-sql-tool --plugin mysql8 --ep mysql -u root -p 3306 --db temporal_visibility update-schema -d /etc/temporal/schema/mysql/v8/visibility/versioned +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal_visibility create +temporal-sql-tool --plugin mysql8 --ep ${MYSQL_SEEDS} -u ${MYSQL_USER} -p ${DB_PORT:-3306} --db temporal_visibility setup-schema -v 0.0 +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 echo 'MySQL schema setup complete' # @@@SNIPEND \ No newline at end of file