fix(deploy): skip bundled postgres for external databases
This commit is contained in:
@@ -42,6 +42,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
required: false
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST: ${POSTGRES_HOST:-postgres}
|
POSTGRES_HOST: ${POSTGRES_HOST:-postgres}
|
||||||
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
|
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ compose_profiles=""
|
|||||||
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
||||||
compose_profiles="--profile cache"
|
compose_profiles="--profile cache"
|
||||||
fi
|
fi
|
||||||
|
postgres_scale=""
|
||||||
|
if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then
|
||||||
|
postgres_scale="--scale postgres=0"
|
||||||
|
fi
|
||||||
|
|
||||||
compose() {
|
compose() {
|
||||||
# Intentional word splitting: compose_profiles is either empty or two arguments.
|
# Intentional word splitting: compose_profiles is either empty or two arguments.
|
||||||
@@ -33,6 +37,12 @@ compose() {
|
|||||||
docker compose $compose_profiles "$@"
|
docker compose $compose_profiles "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compose_up() {
|
||||||
|
# Intentional word splitting: postgres_scale is either empty or two arguments.
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
compose up -d --remove-orphans $postgres_scale
|
||||||
|
}
|
||||||
|
|
||||||
wait_for_stack() {
|
wait_for_stack() {
|
||||||
readiness_path="$1"
|
readiness_path="$1"
|
||||||
attempt=1
|
attempt=1
|
||||||
@@ -119,7 +129,11 @@ rollback() {
|
|||||||
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
||||||
compose_profiles="--profile cache"
|
compose_profiles="--profile cache"
|
||||||
fi
|
fi
|
||||||
compose up -d --remove-orphans
|
postgres_scale=""
|
||||||
|
if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then
|
||||||
|
postgres_scale="--scale postgres=0"
|
||||||
|
fi
|
||||||
|
compose_up
|
||||||
wait_for_stack health
|
wait_for_stack health
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +141,7 @@ compose config -q
|
|||||||
create_backup
|
create_backup
|
||||||
compose pull
|
compose pull
|
||||||
|
|
||||||
if ! compose up -d --remove-orphans || ! wait_for_stack ready; then
|
if ! compose_up || ! wait_for_stack ready; then
|
||||||
compose ps >&2 || true
|
compose ps >&2 || true
|
||||||
rollback
|
rollback
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -28,10 +28,18 @@ compose_profiles=""
|
|||||||
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then
|
||||||
compose_profiles="--profile cache"
|
compose_profiles="--profile cache"
|
||||||
fi
|
fi
|
||||||
|
postgres_scale=""
|
||||||
|
if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then
|
||||||
|
postgres_scale="--scale postgres=0"
|
||||||
|
fi
|
||||||
compose() {
|
compose() {
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker compose $compose_profiles "$@"
|
docker compose $compose_profiles "$@"
|
||||||
}
|
}
|
||||||
|
compose_up() {
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
compose up -d --remove-orphans $postgres_scale
|
||||||
|
}
|
||||||
|
|
||||||
compose stop admin-api mcp-server ui
|
compose stop admin-api mcp-server ui
|
||||||
|
|
||||||
@@ -54,7 +62,7 @@ docker run --rm --volumes-from "$admin_container" \
|
|||||||
-v "$backup_dir:/backup:ro" alpine:3.21 sh -eu -c \
|
-v "$backup_dir:/backup:ro" alpine:3.21 sh -eu -c \
|
||||||
"find '$storage_root' -mindepth 1 -delete; tar -C '$storage_root' -xzf /backup/artifacts.tar.gz"
|
"find '$storage_root' -mindepth 1 -delete; tar -C '$storage_root' -xzf /backup/artifacts.tar.gz"
|
||||||
|
|
||||||
compose up -d --remove-orphans
|
compose_up
|
||||||
attempt=1
|
attempt=1
|
||||||
while [ "$attempt" -le 45 ]; do
|
while [ "$attempt" -le 45 ]; do
|
||||||
if curl --fail --silent http://127.0.0.1:3000/ >/dev/null \
|
if curl --fail --silent http://127.0.0.1:3000/ >/dev/null \
|
||||||
|
|||||||
Reference in New Issue
Block a user