Skip to content

Commit 0d517f8

Browse files
baijumclaude
andcommitted
fix: use JSON format for docker compose images in deploy script
The --format Go template syntax varies across compose versions. Use --format json with python3 parsing for reliable image name extraction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9d6dbc7 commit 0d517f8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

infrastructure/deploy-blue-green.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ docker compose -p "${APP_NAME}-${NEXT_SLOT}" -f "$COMPOSE_FILE" exec -T app \
163163
}
164164

165165
# Step 9: Scan built image for vulnerabilities (non-blocking)
166-
APP_IMAGE=$(docker compose -p "${APP_NAME}-${NEXT_SLOT}" -f "$COMPOSE_FILE" images app --format "{{.Repository}}:{{.Tag}}" | head -1)
166+
APP_IMAGE=$(docker compose -p "${APP_NAME}-${NEXT_SLOT}" -f "$COMPOSE_FILE" images app --format json 2>/dev/null \
167+
| python3 -c "import sys,json; imgs=json.load(sys.stdin); print(imgs[0]['Repository']+':'+imgs[0]['Tag'])" 2>/dev/null || echo "")
167168
if command -v trivy &>/dev/null && [ -n "$APP_IMAGE" ]; then
168169
info "Scanning ${APP_IMAGE} for vulnerabilities..."
169170
trivy image --severity HIGH,CRITICAL --exit-code 0 --no-progress "${APP_IMAGE}" || true

0 commit comments

Comments
 (0)