mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 23:46:42 +02:00
fix(infra): use container names in build-app.sh for reliability
docker compose stop with service names can hang due to env var warnings. Using docker stop/start with container names is more reliable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cdfbfcd13e
commit
ba6b953723
1 changed files with 35 additions and 21 deletions
|
|
@ -15,21 +15,21 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||||
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.macmini.yml"
|
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.macmini.yml"
|
||||||
DOCKER="${DOCKER_CMD:-/usr/local/bin/docker}"
|
DOCKER="${DOCKER_CMD:-/usr/local/bin/docker}"
|
||||||
|
|
||||||
# Monitoring services (compose service names)
|
# Monitoring containers (by container name — more reliable than compose service names)
|
||||||
MONITORING_SERVICES=(
|
MONITORING_CONTAINERS=(
|
||||||
grafana
|
mana-mon-grafana
|
||||||
umami
|
mana-mon-umami
|
||||||
victoriametrics
|
mana-mon-victoria
|
||||||
pushgateway
|
mana-mon-pushgateway
|
||||||
cadvisor
|
mana-mon-cadvisor
|
||||||
postgres-exporter
|
mana-mon-postgres-exporter
|
||||||
redis-exporter
|
mana-mon-redis-exporter
|
||||||
node-exporter
|
mana-mon-node-exporter
|
||||||
vmalert
|
mana-mon-vmalert
|
||||||
alertmanager
|
mana-mon-alertmanager
|
||||||
alert-notifier
|
mana-mon-alert-notifier
|
||||||
glitchtip
|
mana-mon-glitchtip
|
||||||
glitchtip-worker
|
mana-mon-glitchtip-worker
|
||||||
)
|
)
|
||||||
|
|
||||||
# Track if we stopped monitoring
|
# Track if we stopped monitoring
|
||||||
|
|
@ -39,7 +39,7 @@ cleanup() {
|
||||||
if [ "$MONITORING_STOPPED" = true ]; then
|
if [ "$MONITORING_STOPPED" = true ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Restarting monitoring stack ==="
|
echo "=== Restarting monitoring stack ==="
|
||||||
$DOCKER compose -f "$COMPOSE_FILE" start "${MONITORING_SERVICES[@]}" 2>/dev/null || true
|
$DOCKER start "${MONITORING_CONTAINERS[@]}" 2>/dev/null || true
|
||||||
echo "Monitoring restored."
|
echo "Monitoring restored."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ trap cleanup EXIT
|
||||||
|
|
||||||
stop_monitoring() {
|
stop_monitoring() {
|
||||||
echo "=== Stopping monitoring to free RAM ==="
|
echo "=== Stopping monitoring to free RAM ==="
|
||||||
$DOCKER compose -f "$COMPOSE_FILE" stop "${MONITORING_SERVICES[@]}" 2>/dev/null || true
|
$DOCKER stop "${MONITORING_CONTAINERS[@]}" 2>/dev/null || true
|
||||||
MONITORING_STOPPED=true
|
MONITORING_STOPPED=true
|
||||||
|
|
||||||
# Also prune dangling build cache
|
# Also prune dangling build cache
|
||||||
|
|
@ -60,23 +60,37 @@ stop_monitoring() {
|
||||||
|
|
||||||
build_base_images() {
|
build_base_images() {
|
||||||
echo "=== Building sveltekit-base image ==="
|
echo "=== Building sveltekit-base image ==="
|
||||||
$DOCKER build -f "$PROJECT_ROOT/docker/Dockerfile.sveltekit-base" -t sveltekit-base:local "$PROJECT_ROOT" 2>&1 | tail -5
|
$DOCKER build -f "$PROJECT_ROOT/docker/Dockerfile.sveltekit-base" -t sveltekit-base:local "$PROJECT_ROOT"
|
||||||
echo "sveltekit-base:local built."
|
echo "sveltekit-base:local built."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "=== Building nestjs-base image ==="
|
echo "=== Building nestjs-base image ==="
|
||||||
$DOCKER build -f "$PROJECT_ROOT/docker/Dockerfile.nestjs-base" -t nestjs-base:local "$PROJECT_ROOT" 2>&1 | tail -5
|
$DOCKER build -f "$PROJECT_ROOT/docker/Dockerfile.nestjs-base" -t nestjs-base:local "$PROJECT_ROOT"
|
||||||
echo "nestjs-base:local built."
|
echo "nestjs-base:local built."
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
build_services() {
|
build_services() {
|
||||||
local services=("$@")
|
local services=("$@")
|
||||||
|
|
||||||
|
# Check if any service needs a base image rebuild
|
||||||
|
for svc in "${services[@]}"; do
|
||||||
|
case "$svc" in
|
||||||
|
*-web)
|
||||||
|
if ! $DOCKER image inspect sveltekit-base:local >/dev/null 2>&1; then
|
||||||
|
echo "=== Building sveltekit-base (first time) ==="
|
||||||
|
$DOCKER build -f "$PROJECT_ROOT/docker/Dockerfile.sveltekit-base" -t sveltekit-base:local "$PROJECT_ROOT"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
echo "=== Building: ${services[*]} ==="
|
echo "=== Building: ${services[*]} ==="
|
||||||
$DOCKER compose -f "$COMPOSE_FILE" build --no-cache "${services[@]}"
|
$DOCKER compose -f "$COMPOSE_FILE" build --no-cache "${services[@]}" 2>&1
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Restarting: ${services[*]} ==="
|
echo "=== Restarting: ${services[*]} ==="
|
||||||
$DOCKER compose -f "$COMPOSE_FILE" up -d --no-deps "${services[@]}"
|
$DOCKER compose -f "$COMPOSE_FILE" up -d --no-deps "${services[@]}" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Main ---
|
# --- Main ---
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue