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"