From c9409b06660c6370ba1f857db4b84757fea2e6a0 Mon Sep 17 00:00:00 2001 From: Dusan Vojacek Date: Thu, 11 Jun 2026 15:58:00 +0200 Subject: [PATCH] =?UTF-8?q?CI:=20flyway=20validate=20funguje=20i=20v=20con?= =?UTF-8?q?tainer=20m=C3=B3du=20runneru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause rozbitého CI: docker CLI v jobu mluví s hostovským daemonem, takže -v bind mounty checkoutu ukazovaly na neexistující hostovské cesty → flyway dostal prázdné adresáře (applied migration not resolved locally). Fix: docker create + docker cp (streamuje od klienta) + start/wait/logs. Cíl /sql, ne /flyway/sql — image tam deklaruje VOLUME, který by kopii zastínil. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/ci_flyway_validate_remote.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/ci_flyway_validate_remote.sh b/scripts/ci_flyway_validate_remote.sh index 121cfd9..e83109b 100755 --- a/scripts/ci_flyway_validate_remote.sh +++ b/scripts/ci_flyway_validate_remote.sh @@ -30,15 +30,18 @@ cd "$ROOT" IMG="${FLYWAY_IMAGE:-flyway/flyway:12}" +# POZOR: žádné -v bind mounty! Docker CLI mluví s HOSTOVSKÝM daemonem; když job +# běží v kontejneru (container mód runneru), cesty checkoutu na hostu neexistují +# a flyway dostane prázdné adresáře ("applied migration not resolved locally"). +# docker cp streamuje soubory od klienta → funguje v host i container módu. +# /sql (ne /flyway/sql): image deklaruje /flyway/sql jako VOLUME — anonymní volume +# by při startu zastínil soubory nakopírované přes docker cp do vrstvy kontejneru. args=( - run --rm + create --network host - -v "$ROOT/db/migration:/flyway/sql/migration" - -v "$ROOT/db/routines:/flyway/sql/routines" - -v "$ROOT/db/views:/flyway/sql/views" -e "FLYWAY_URL=${EMS_CI_FLYWAY_URL}" -e "FLYWAY_SCHEMAS=ems" - -e "FLYWAY_LOCATIONS=filesystem:/flyway/sql/migration,filesystem:/flyway/sql/routines,filesystem:/flyway/sql/views" + -e "FLYWAY_LOCATIONS=filesystem:/sql/migration,filesystem:/sql/routines,filesystem:/sql/views" ) if [[ -n "$EMS_CI_FLYWAY_USER" ]]; then @@ -51,4 +54,13 @@ fi args+=("$IMG" validate) echo "Running Flyway validate against remote DB (schema ems)…" -docker "${args[@]}" +cid="$(docker "${args[@]}")" +cleanup() { docker rm -f "$cid" >/dev/null 2>&1 || true; } +trap cleanup EXIT + +docker cp "$ROOT/db" "$cid:/sql" + +docker start "$cid" >/dev/null +rc="$(docker wait "$cid")" +docker logs "$cid" +exit "$rc"