Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Allow database host to be configured and respected in the entrypoint #269

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# If we are using podman or docker compose use the repo config.toml
if [[ -f /podman_compose/kai/config.toml ]]; then
cp /podman_compose/kai/config.toml /kai/kai/config.toml
sed -i 's/^host\ =.*/host = "kai_db"/g' /kai/kai/config.toml
sed -i "s/^host =.*/host = \"${POSTGRES_HOST}\"/g" /kai/kai/config.toml
sed -i "s/^database =.*/database = \"${POSTGRES_DB}\"/g" /kai/kai/config.toml
sed -i "s/^user =.*/user = \"${POSTGRES_USER}\"/g" /kai/kai/config.toml
sed -i "s/^password =.*/password =\"${POSTGRES_PASSWORD}\"/g" /kai/kai/config.toml
fi

until PGPASSWORD="${POSTGRES_PASSWORD}" pg_isready -q -h kai_db -U "${POSTGRES_USER}" -d "${POSTGRES_DB}"; do
until PGPASSWORD="${POSTGRES_PASSWORD}" pg_isready -q -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -d "${POSTGRES_DB}"; do
sleep 1
done

Expand All @@ -19,7 +19,7 @@ if [[ ${MODE} != "importer" ]]; then
SQL_EXISTS=$(printf "\dt %s" "${TABLE}")
STDERR="Did not find any relation"
# trunk-ignore(shellcheck/SC2312)
if PGPASSWORD="${POSTGRES_PASSWORD}" psql -h kai_db -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "${SQL_EXISTS}" 2>&1 | grep -q -v "${STDERR}"; then
if PGPASSWORD="${POSTGRES_PASSWORD}" psql -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "${SQL_EXISTS}" 2>&1 | grep -q -v "${STDERR}"; then
echo "################################################"
echo "load-data has run already run, starting server.#"
echo "################################################"
Expand Down
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ x-db-variables: &db-variables
POSTGRES_DB: kai
POSTGRES_PASSWORD: dog8code
POSTGRES_USER: kai
POSTGRES_HOST: kai_db

services:
kai:
Expand Down
Loading