From e5a1d9e70a086b777fe9c99eccbe683c4890f63e Mon Sep 17 00:00:00 2001 From: Hintay Date: Sat, 23 May 2026 03:39:25 +0900 Subject: [PATCH] feat: support riscv64 docker and OpenWrt installs (#1551) --- .github/workflows/build.yml | 7 ++++++- Dockerfile | 1 + demo.Dockerfile | 1 + install.sh | 3 +++ tests/install_openwrt_test.sh | 37 ++++++++++++++++++++++++++++++++++- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e29be06..b683c0c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -542,7 +542,7 @@ jobs: runs-on: ubuntu-latest needs: [build, build_macos_native] env: - PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5 + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5,linux/riscv64 steps: - name: Checkout uses: actions/checkout@v6 @@ -569,6 +569,11 @@ jobs: - name: Prepare Artifacts run: chmod +x ./dist/nginx-ui-*/nginx-ui* + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm,arm64,riscv64 + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v4 diff --git a/Dockerfile b/Dockerfile index b944e896..00052a81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ RUN case "${TARGETARCH}/${TARGETVARIANT}" in \ "arm/v7"*) S6_ARCH="arm" ;; \ "arm/v6"*) S6_ARCH="arm" ;; \ "arm/v5"*) S6_ARCH="arm" ;; \ + "riscv64/"*) S6_ARCH="riscv64" ;; \ *) echo "Unsupported arch: ${TARGETARCH}/${TARGETVARIANT}" && exit 1 ;; \ esac && \ wget -O /tmp/s6-overlay-noarch.tar.xz https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz && \ diff --git a/demo.Dockerfile b/demo.Dockerfile index 6f940a0a..8311e2fb 100644 --- a/demo.Dockerfile +++ b/demo.Dockerfile @@ -21,6 +21,7 @@ RUN case "${TARGETARCH}/${TARGETVARIANT}" in \ "arm/v7"*) S6_ARCH="arm" ;; \ "arm/v6"*) S6_ARCH="arm" ;; \ "arm/v5"*) S6_ARCH="arm" ;; \ + "riscv64/"*) S6_ARCH="riscv64" ;; \ *) echo "Unsupported arch: ${TARGETARCH}/${TARGETVARIANT}" && exit 1 ;; \ esac && \ wget -O /tmp/s6-overlay-noarch.tar.xz https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz && \ diff --git a/install.sh b/install.sh index 9e2fb616..9857fd9a 100644 --- a/install.sh +++ b/install.sh @@ -209,6 +209,9 @@ identify_the_operating_system_and_architecture() { 'armv8' | 'aarch64') MACHINE='arm64-v8a' ;; + 'riscv64') + MACHINE='riscv64' + ;; *) echo -e "${FontRed}error: The architecture is not supported by this script.${FontSuffix}" exit 1 diff --git a/tests/install_openwrt_test.sh b/tests/install_openwrt_test.sh index 32250a4d..f445a03d 100644 --- a/tests/install_openwrt_test.sh +++ b/tests/install_openwrt_test.sh @@ -41,6 +41,41 @@ EOF assert_contains "$output" "SERVICE_TYPE=openwrt" "OpenWrt 25 should use OpenWrt service type" } -test_openwrt_with_apk_is_not_detected_as_openrc +test_openwrt_riscv64_is_supported() { + local sandbox output + sandbox="$(mktemp -d)" + trap 'rm -rf "$sandbox"' RETURN + mkdir -p "$sandbox/bin" "$sandbox/etc" "$sandbox/proc/1" "$sandbox/sbin" + cat > "$sandbox/bin/uname" <<'EOF' +#!/usr/bin/env bash + +if [[ "${1:-}" == "-m" ]]; then + echo 'riscv64' +else + echo 'Linux' +fi +EOF + chmod +x "$sandbox/bin/uname" + + cat > "$sandbox/etc/os-release" <<'EOF' +NAME="OpenWrt" +ID="openwrt" +VERSION_ID="25.10" +EOF + : > "$sandbox/etc/openwrt_release" + : > "$sandbox/proc/cpuinfo" + : > "$sandbox/proc/1/cgroup" + ln -s /bin/true "$sandbox/bin/apk" + + output="$(PATH="$sandbox/bin:$PATH" NGINX_UI_INSTALL_TESTING=1 "$INSTALL_SCRIPT" __test_detect "$sandbox" 2>&1)" + + assert_contains "$output" "MACHINE=riscv64" "OpenWrt riscv64 should use the linux-riscv64 artifact" + assert_contains "$output" "SERVICE_TYPE=openwrt" "OpenWrt riscv64 should use OpenWrt service type" +} + +test_openwrt_with_apk_is_not_detected_as_openrc echo "ok - install.sh detects OpenWrt 25 apk as openwrt" + +test_openwrt_riscv64_is_supported +echo "ok - install.sh detects OpenWrt riscv64 as openwrt"