fix: DOCKER_CMD function instead of string for proper arg passing
sg docker -c docker compose expands 'compose' as arg to sg, not docker. Replaced with bash function docker_cmd() that uses sudo docker as fallback. This works immediately after usermod without re-login.
This commit is contained in:
+6
-6
@@ -155,9 +155,9 @@ fi
|
|||||||
|
|
||||||
# Use sudo for docker commands if the current shell can't run docker directly
|
# Use sudo for docker commands if the current shell can't run docker directly
|
||||||
if docker info &>/dev/null 2>&1; then
|
if docker info &>/dev/null 2>&1; then
|
||||||
DOCKER_CMD="docker"
|
docker_cmd() { docker "$@"; }
|
||||||
else
|
else
|
||||||
DOCKER_CMD="sg docker -c docker"
|
docker_cmd() { sudo docker "$@"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Clone / Pull ─────────────────────────────────
|
# ── Clone / Pull ─────────────────────────────────
|
||||||
@@ -193,22 +193,22 @@ log "Data directory ready"
|
|||||||
|
|
||||||
# ── Build & Start ────────────────────────────────
|
# ── Build & Start ────────────────────────────────
|
||||||
info "Building Docker image (this may take a few minutes)..."
|
info "Building Docker image (this may take a few minutes)..."
|
||||||
$DOCKER_CMD compose build web
|
docker_cmd compose build web
|
||||||
log "Build complete"
|
log "Build complete"
|
||||||
|
|
||||||
info "Starting containers..."
|
info "Starting containers..."
|
||||||
$DOCKER_CMD compose up -d
|
docker_cmd compose up -d
|
||||||
log "Containers are running"
|
log "Containers are running"
|
||||||
|
|
||||||
# ── Wait for health ──────────────────────────────
|
# ── Wait for health ──────────────────────────────
|
||||||
info "Waiting for web service to be healthy..."
|
info "Waiting for web service to be healthy..."
|
||||||
for i in $(seq 1 30); do
|
for i in $(seq 1 30); do
|
||||||
if $DOCKER_CMD compose exec -T web wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/health &>/dev/null; then
|
if docker_cmd compose exec -T web wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/health &>/dev/null; then
|
||||||
log "Web service is healthy"
|
log "Web service is healthy"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [ "$i" -eq 30 ]; then
|
if [ "$i" -eq 30 ]; then
|
||||||
warn "Timed out waiting for health check — check logs with: $DOCKER_CMD compose logs web"
|
warn "Timed out waiting for health check — check logs with: docker compose logs web"
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user