mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(podman): bound setup image builds
This commit is contained in:
@@ -29,6 +29,7 @@ PLATFORM_NAME="$(uname -s 2>/dev/null || echo unknown)"
|
|||||||
HOST_GATEWAY_PORT="${OPENCLAW_PODMAN_GATEWAY_HOST_PORT:-${OPENCLAW_GATEWAY_PORT:-18789}}"
|
HOST_GATEWAY_PORT="${OPENCLAW_PODMAN_GATEWAY_HOST_PORT:-${OPENCLAW_GATEWAY_PORT:-18789}}"
|
||||||
QUADLET_GATEWAY_PORT="18789"
|
QUADLET_GATEWAY_PORT="18789"
|
||||||
PODMAN_PULL_TIMEOUT="${OPENCLAW_PODMAN_SETUP_PULL_TIMEOUT:-600s}"
|
PODMAN_PULL_TIMEOUT="${OPENCLAW_PODMAN_SETUP_PULL_TIMEOUT:-600s}"
|
||||||
|
PODMAN_BUILD_TIMEOUT="${OPENCLAW_PODMAN_SETUP_BUILD_TIMEOUT:-1800s}"
|
||||||
|
|
||||||
require_cmd() {
|
require_cmd() {
|
||||||
if ! command -v "$1" >/dev/null 2>&1; then
|
if ! command -v "$1" >/dev/null 2>&1; then
|
||||||
@@ -57,6 +58,18 @@ run_podman_pull() {
|
|||||||
podman pull "$image"
|
podman pull "$image"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_podman_build() {
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
if timeout --kill-after=1s 1s true >/dev/null 2>&1; then
|
||||||
|
timeout --kill-after=30s "$PODMAN_BUILD_TIMEOUT" podman build "$@"
|
||||||
|
else
|
||||||
|
timeout "$PODMAN_BUILD_TIMEOUT" podman build "$@"
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
podman build "$@"
|
||||||
|
}
|
||||||
|
|
||||||
validate_single_line_value() {
|
validate_single_line_value() {
|
||||||
local label="$1"
|
local label="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
@@ -390,7 +403,7 @@ fi
|
|||||||
|
|
||||||
if [[ "$OPENCLAW_IMAGE" == "openclaw:local" ]]; then
|
if [[ "$OPENCLAW_IMAGE" == "openclaw:local" ]]; then
|
||||||
echo "Building image $OPENCLAW_IMAGE ..."
|
echo "Building image $OPENCLAW_IMAGE ..."
|
||||||
podman build -t "$OPENCLAW_IMAGE" -f "$REPO_PATH/Dockerfile" "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}" "$REPO_PATH"
|
run_podman_build -t "$OPENCLAW_IMAGE" -f "$REPO_PATH/Dockerfile" "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}" "$REPO_PATH"
|
||||||
else
|
else
|
||||||
if podman image exists "$OPENCLAW_IMAGE" >/dev/null 2>&1; then
|
if podman image exists "$OPENCLAW_IMAGE" >/dev/null 2>&1; then
|
||||||
echo "Using existing image $OPENCLAW_IMAGE"
|
echo "Using existing image $OPENCLAW_IMAGE"
|
||||||
|
|||||||
@@ -147,6 +147,20 @@ describe("test-install-sh-docker", () => {
|
|||||||
expect(script).not.toContain('podman pull "$OPENCLAW_IMAGE"');
|
expect(script).not.toContain('podman pull "$OPENCLAW_IMAGE"');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("bounds Podman setup image builds", () => {
|
||||||
|
const script = readFileSync(PODMAN_SETUP_PATH, "utf8");
|
||||||
|
|
||||||
|
expect(script).toContain(
|
||||||
|
'PODMAN_BUILD_TIMEOUT="${OPENCLAW_PODMAN_SETUP_BUILD_TIMEOUT:-1800s}"',
|
||||||
|
);
|
||||||
|
expect(script).toContain("run_podman_build()");
|
||||||
|
expect(script).toContain("timeout --kill-after=1s 1s true");
|
||||||
|
expect(script).toContain('timeout --kill-after=30s "$PODMAN_BUILD_TIMEOUT" podman build "$@"');
|
||||||
|
expect(script).toContain('timeout "$PODMAN_BUILD_TIMEOUT" podman build "$@"');
|
||||||
|
expect(script).toContain('run_podman_build -t "$OPENCLAW_IMAGE"');
|
||||||
|
expect(script).not.toContain('podman build -t "$OPENCLAW_IMAGE"');
|
||||||
|
});
|
||||||
|
|
||||||
it("bounds detached Podman launches without timing out onboarding", () => {
|
it("bounds detached Podman launches without timing out onboarding", () => {
|
||||||
const script = readFileSync(PODMAN_RUN_PATH, "utf8");
|
const script = readFileSync(PODMAN_RUN_PATH, "utf8");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user