fix(ci): restore copied Login entrypoint execute bit and probe built image

This commit is contained in:
victorsteele428 committed 2026-11-23 10:34:42 +00:00
1 parent adc02bd2c3
commit 7d6b6d0704
1 file changed
+49
+49
View File
@@ -44,8 +44,57 @@ docker exec -w /work/v2 "$builder" sh -ec '
mkdir -m 700 -p "$context/.next"
touch "$context/.zitplane-owned-$GITHUB_RUN_ID"
docker cp "$builder:/work/v2/apps/login/.next/standalone" "$context/.next/standalone"
# The immutable upstream Git entrypoint is 100644. The upstream Dockerfile
# directly execs /app/entrypoint.sh as nextjs. Repair only this disposable
# COPY input, never the tracked source, original Dockerfile or checkout.
entry="$context/.next/standalone/entrypoint.sh"
if [ -L "$entry" ] || [ ! -f "$entry" ]; then
echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_NOT_REGULAR >&2
exit 1
fi
if [ "$(head -c 2 "$entry")" != '#!' ]; then
echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_INVALID_SHEBANG >&2
exit 1
fi
mode="$(stat -c '%a' "$entry")"
owner="$(stat -c '%u:%g' "$entry")"
case "$mode:$owner" in *[!0-9:]*|'') echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_STAT_INVALID >&2; exit 1;; esac
echo "ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_COPY_MODE=$mode OWNER=$owner"
case "$mode" in
644)
[ ! -x "$entry" ] || { echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_UNEXPECTED_EXECUTION_MODE >&2; exit 1; }
chmod 0755 "$entry"
echo ZITPLANE_CUSTOM_LOGIN_TEMP_ENTRYPOINT_MODE_FIXED_PASS
;;
755)
[ -x "$entry" ] || { echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_NOT_EXECUTABLE >&2; exit 1; }
echo ZITPLANE_CUSTOM_LOGIN_TEMP_ENTRYPOINT_ALREADY_EXECUTABLE_PASS
;;
*)
echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_UNEXPECTED_MODE >&2
exit 1
;;
esac
[ ! -L "$entry" ] && [ -f "$entry" ] && [ -x "$entry" ] &&
[ "$(stat -c '%a' "$entry")" = 755 ] || {
echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_COPY_EXECUTABILITY_BLOCKED >&2
exit 1
}
echo ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_COPY_EXECUTABLE_PASS
cp auth/ui/v2/apps/login/Dockerfile "$context/Dockerfile"
docker build --pull --label "$label" -t "$image" -f "$context/Dockerfile" "$context"
# Probe the final image under its original USER nextjs, with no network,
# credentials, host volumes or entrypoint execution; print no file contents.
docker run --rm --network none --entrypoint /bin/sh "$image" -ec '
entry=/app/entrypoint.sh
[ ! -L "$entry" ] && [ -f "$entry" ] && [ -x "$entry" ] &&
[ "$(stat -c "%a" "$entry")" = 755 ] &&
[ "$(head -c 2 "$entry")" = "#!" ]
' || {
echo ZITPLANE_CUSTOM_LOGIN_BUILT_IMAGE_ENTRYPOINT_BLOCKED >&2
exit 1
}
echo ZITPLANE_CUSTOM_LOGIN_BUILT_IMAGE_ENTRYPOINT_EXECUTABLE_PASS
actual_label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image")"
image_id="$(docker image inspect --format '{{.Id}}' "$image")"
if [ "$actual_label" != "$GITHUB_RUN_ID" ]; then