From 062ce58f1327ac00d7b6dbd1ad67c220581f6e58 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Thu, 26 Nov 2026 16:51:44 +0800 Subject: [PATCH 1/5] ci(devcontainer): remove scheduled image builds Keep GHCR publication and consumer migration explicit until the pull request has been verified on the default branch. Signed-off-by: Yi Huang --- .github/workflows/docker.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 407fb47..2063f99 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,8 +29,6 @@ on: - 'scripts/opencvmini/**' - 'scripts/wasi-crypto/**' - 'scripts/wasi-nn/**' - schedule: - - cron: "0 0 */7 * *" permissions: contents: read @@ -54,9 +52,7 @@ jobs: run: | DOCKER_IMAGE=wasmedge/wasmedge VERSION=noop - if [ "${{ github.event_name }}" = "schedule" ]; then - VERSION=nightly - elif [[ $GITHUB_REF == refs/tags/* ]]; then + if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} elif [[ $GITHUB_REF == refs/heads/* ]]; then VERSION=$(printf '%s\n' "${GITHUB_REF#refs/heads/}" | sed -r 's#/+#-#g') @@ -157,7 +153,7 @@ jobs: needs: - prep - paths-filter - # Only run if files changed or if it's a scheduled/merge build + # Only run if files changed or if it's a merge build if: ${{ needs.paths-filter.outputs.alpine-base == 'true' }} name: Alpine Base (3.23) From 10dc6cc21e80715b3cb6be68f06556de75be3ef9 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Thu, 26 Nov 2026 20:34:43 +0800 Subject: [PATCH 2/5] ci(devcontainer): add GHCR image publication Publish native durable or pull request images through a reusable workflow, returning an immutable image reference without changing consumers yet. Signed-off-by: Yi Huang --- .github/scripts/devcontainer/publication.py | 45 ++++++ .../tests/devcontainer/test_publication.py | 46 ++++++ .github/workflows/devcontainer.yml | 142 ++++++++++++++++++ .github/workflows/docker.yml | 14 ++ 4 files changed, 247 insertions(+) create mode 100644 .github/scripts/devcontainer/publication.py create mode 100644 .github/tests/devcontainer/test_publication.py create mode 100644 .github/workflows/devcontainer.yml diff --git a/.github/scripts/devcontainer/publication.py b/.github/scripts/devcontainer/publication.py new file mode 100644 index 0000000..609eb66 --- /dev/null +++ b/.github/scripts/devcontainer/publication.py @@ -0,0 +1,45 @@ +"""Small GHCR publication contract.""" + +import argparse +import re + + +SHA = re.compile(r"[0-9a-f]{40}\Z") + + +def _identity_tag(prefix, source_sha, run_id, attempt): + if not SHA.fullmatch(source_sha): + raise ValueError("Invalid source SHA") + if type(run_id) is not int or run_id <= 0 or type(attempt) is not int or attempt <= 0: + raise ValueError("Run identity must be positive integers") + tag = f"{prefix}-{source_sha}-run-{run_id}-attempt-{attempt}" + if len(tag + "-stage-amd64") > 128: + raise ValueError("Image staging tag exceeds 128 characters") + return tag + + +def durable_tag(source_sha, run_id, attempt): + return _identity_tag("build", source_sha, run_id, attempt) + + +def candidate_tag(pr, source_sha, run_id, attempt): + if type(pr) is not int or pr <= 0: + raise ValueError("PR number must be positive") + return _identity_tag(f"pr-{pr}", source_sha, run_id, attempt) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("command", choices=("tag", "candidate")) + parser.add_argument("--source-sha") + parser.add_argument("--run-id", type=int) + parser.add_argument("--attempt", type=int) + parser.add_argument("--pr", type=int) + parser.add_argument("--digest") + args = parser.parse_args() + if args.command == "tag": + print(durable_tag(args.source_sha, args.run_id, args.attempt)) + elif args.command == "candidate": + print(candidate_tag(args.pr, args.source_sha, args.run_id, args.attempt)) +if __name__ == "__main__": + main() diff --git a/.github/tests/devcontainer/test_publication.py b/.github/tests/devcontainer/test_publication.py new file mode 100644 index 0000000..f2a4eff --- /dev/null +++ b/.github/tests/devcontainer/test_publication.py @@ -0,0 +1,46 @@ +"""Small GHCR publication contract tests.""" + +import importlib.util +from pathlib import Path +import unittest + + +MODULE = Path(__file__).resolve().parents[3] / ".github/scripts/devcontainer/publication.py" + + +def load_module(): + spec = importlib.util.spec_from_file_location("publication", MODULE) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +class PublicationTests(unittest.TestCase): + def setUp(self): + self.publication = load_module() + self.source = "a" * 40 + + def test_durable_tag_contains_source_run_and_attempt(self): + self.assertEqual( + self.publication.durable_tag(self.source, 44964975569, 2), + "build-" + self.source + "-run-44964975569-attempt-2", + ) + + def test_candidate_tag_uses_pr_merge_sha_run_and_attempt(self): + self.assertEqual( + self.publication.candidate_tag(123, self.source, 44964975569, 2), + "pr-123-" + self.source + "-run-44964975569-attempt-2", + ) + + def test_tags_reject_invalid_identity(self): + for function, args in ( + (self.publication.durable_tag, ("bad", 1, 1)), + (self.publication.candidate_tag, (0, self.source, 1, 1)), + (self.publication.candidate_tag, (123, "bad", 1, 1)), + (self.publication.durable_tag, (self.source, 0, 1)), + ): + with self.assertRaises(ValueError): + function(*args) + +if __name__ == "__main__": + unittest.main() diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 0000000..b98e60e --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,142 @@ +name: devcontainer GHCR publication + +on: + workflow_call: + inputs: + candidate: + type: boolean + required: false + default: false + outputs: + image_ref: + description: Immutable image reference. + value: ${{ jobs.publish.outputs.image_ref }} + +permissions: + contents: read + +jobs: + prepare: + if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate) + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.identity.outputs.tag }} + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + - id: identity + env: + SOURCE_SHA: ${{ github.sha }} + RUN_ID: ${{ github.run_id }} + ATTEMPT: ${{ github.run_attempt }} + run: | + if [ '${{ inputs.candidate }}' = true ]; then + tag=$(python3 .github/scripts/devcontainer/publication.py candidate --pr '${{ github.event.number }}' \ + --source-sha "$SOURCE_SHA" --run-id "$RUN_ID" --attempt "$ATTEMPT") + else + tag=$(python3 .github/scripts/devcontainer/publication.py tag \ + --source-sha "$SOURCE_SHA" --run-id "$RUN_ID" --attempt "$ATTEMPT") + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + + build: + needs: prepare + if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate) + runs-on: ${{ matrix.runner }} + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + target: x86_64 + arch: amd64 + - runner: ubuntu-24.04-arm + target: aarch64 + arch: arm64 + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Build and push native platform + uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 + with: + source: . + files: docker-bake.ci-image-base.hcl + targets: ${{ matrix.target }} + push: true + set: | + ${{ matrix.target }}.tags=ghcr.io/wasmedge/devcontainer:${{ needs.prepare.outputs.tag }}-stage-${{ matrix.arch }} + ${{ matrix.target }}.labels.org.opencontainers.image.source=https://github.com/WasmEdge/devcontainer + ${{ matrix.target }}.labels.org.opencontainers.image.revision=${{ github.sha }} + + publish: + needs: + - prepare + - build + if: needs.build.result == 'success' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + outputs: + image_ref: ${{ steps.publish.outputs.image_ref }} + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Assemble multi-platform index + id: publish + env: + TAG: ${{ needs.prepare.outputs.tag }} + run: | + image=ghcr.io/wasmedge/devcontainer + docker buildx imagetools create --tag "$image:$TAG" \ + "$image:$TAG-stage-amd64" "$image:$TAG-stage-arm64" + digest=$(docker buildx imagetools inspect "$image:$TAG" \ + --format '{{json .Manifest.Digest}}' | tr -d '"') + if [ -z "$digest" ] || [ "$digest" = "null" ]; then + echo "Failed to obtain image digest" >&2 + exit 1 + fi + if [ '${{ inputs.candidate }}' != true ]; then + docker buildx imagetools create --tag "$image:latest" "$image@$digest" + fi + echo "image_ref=$image@$digest" >> "$GITHUB_OUTPUT" + + summarize-publication: + needs: + - prepare + - publish + if: needs.publish.result == 'success' + runs-on: ubuntu-latest + steps: + - name: Report published image + env: + IMAGE_REF: ${{ needs.publish.outputs.image_ref }} + TAG: ${{ needs.prepare.outputs.tag }} + run: | + image=ghcr.io/wasmedge/devcontainer + { + echo "## Published GHCR image" + echo + echo "- Immutable reference: \`$image:$TAG@${IMAGE_REF#*@}\`" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2063f99..f898b84 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,6 +10,7 @@ on: - main paths: - '.github/workflows/docker.yml' + - '.github/workflows/devcontainer.yml' - 'Dockerfile.*' - 'docker-bake.*.hcl' - 'SHA256SUM.*' @@ -94,6 +95,7 @@ jobs: filters: | ci-image-base: - '.github/workflows/docker.yml' + - '.github/workflows/devcontainer.yml' - 'docker-bake.ci-image-base.hcl' - 'Dockerfile.ci-image-base' alpine-base: @@ -149,6 +151,18 @@ jobs: files: docker-bake.ci-image-base.hcl push: ${{ github.event_name != 'pull_request' }} + devcontainer-ghcr: + needs: [prep, paths-filter] + name: devcontainer GHCR publication + permissions: + contents: read + packages: write + # Fork-origin PR package permissions remain a rollout decision; keep this + # path free of fork-specific handling until that behavior is verified. + uses: ./.github/workflows/devcontainer.yml + with: + candidate: ${{ github.event_name == 'pull_request' && needs.paths-filter.outputs.ci-image-base == 'true' }} + build-alpine-base-images: needs: - prep From 347f8d81c13d5cc02ab568e6a0c7867650700eb0 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Thu, 26 Nov 2026 20:35:17 +0800 Subject: [PATCH 3/5] ci(devcontainer): consume verified GHCR image Use the verified GHCR reference when this run builds a replacement CI base image, while preserving the existing Docker Hub image when no replacement is expected. Signed-off-by: Yi Huang --- .github/workflows/docker.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f898b84..c4994cc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -209,7 +209,8 @@ jobs: - prep - paths-filter - bake-base-images - if: ${{ needs.paths-filter.outputs.ubuntu == 'true' }} + - devcontainer-ghcr + if: ${{ !cancelled() && needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.ubuntu == 'true' && (needs.paths-filter.outputs.ci-image-base != 'true' || needs.devcontainer-ghcr.result == 'success' || needs.devcontainer-ghcr.result == 'skipped') }} strategy: fail-fast: false @@ -220,8 +221,11 @@ jobs: name: Ubuntu runs-on: ubuntu-latest + permissions: + contents: read + packages: read container: - image: wasmedge/wasmedge:ci-image-base + image: ${{ needs.devcontainer-ghcr.result == 'success' && needs.devcontainer-ghcr.outputs.image_ref || 'wasmedge/wasmedge:ci-image-base' }} steps: - name: Harden the runner (Audit all outbound calls) @@ -259,7 +263,8 @@ jobs: - prep - paths-filter - bake-base-images - if: ${{ needs.paths-filter.outputs.manylinux == 'true' }} + - devcontainer-ghcr + if: ${{ !cancelled() && needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.manylinux == 'true' && (needs.paths-filter.outputs.ci-image-base != 'true' || needs.devcontainer-ghcr.result == 'success' || needs.devcontainer-ghcr.result == 'skipped') }} strategy: fail-fast: false @@ -278,8 +283,11 @@ jobs: name: ${{ matrix.name }} runs-on: ${{ matrix.host_runner }} + permissions: + contents: read + packages: read container: - image: ${{ matrix.host_container }} + image: ${{ needs.devcontainer-ghcr.result == 'success' && needs.devcontainer-ghcr.outputs.image_ref || matrix.host_container }} steps: - name: Harden the runner (Audit all outbound calls) From cd5b2639db5ecc62daa594c6d08cd1c2066bf9b7 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Fri, 27 Nov 2026 23:36:57 +0800 Subject: [PATCH 4/5] feat(docker): import WasmEdge image definitions and dependencies Import the Docker image definitions and dependency scripts from WasmEdge snapshot `512db9f513fff9facac396ac72f31748de638797`. Relocate: - `utils/docker/` -> `.` - `utils/ffmpeg/` -> `scripts/ffmpeg/` - `utils/opencvmini/` -> `scripts/opencvmini/` - `utils/wasi-crypto/` -> `scripts/wasi-crypto/` - `utils/wasi-nn/` -> `scripts/wasi-nn/` Previous snapshot: https://github.com/WasmEdge/WasmEdge/tree/b2e483553ea7a1826be117180125c71e5d0b8958 New snapshot: https://github.com/WasmEdge/WasmEdge/tree/512db9f513fff9facac396ac72f31748de638797 Synchronize the imported Dockerfiles, Bake definitions, dependency scripts, patch, checksum, and related additions, deletions, renames, and updates through the new snapshot. Adjust Dockerfile COPY paths and Bake contexts for the relocated inputs. Source provenance for changes after the previous snapshot: - https://github.com/WasmEdge/WasmEdge/commit/7485c8e2ab3564a908dfbfadb8b29226182c59c7 7485c8e2 fix(docker): fetch the apt.llvm.org key over IPv4 with retries hydai , 2026-11-10 - https://github.com/WasmEdge/WasmEdge/commit/a4cb45c3e1ff95b0984f5bf11ba18d65ce2c79e3 a4cb45c3 chore(docker): drop the OpenCV build from the plugins images hydai , 2026-11-10 - https://github.com/WasmEdge/WasmEdge/commit/536d99fc9e1bdc8e38a8bf4b840dce70d70de73f 536d99fc chore(docker): build FFmpeg in parallel hydai , 2026-11-10 - https://github.com/WasmEdge/WasmEdge/commit/e415201c203e0996355646c1d4ed48d7eb629777 e415201c ci(docker): build the Alpine base image on native runners hydai , 2026-11-10 - https://github.com/WasmEdge/WasmEdge/commit/4780c8219f5cdf559306c28d0da88e9ec093f68b 4780c821 ci(docker): link a consumer against the Debian static library hydai , 2026-11-19 - https://github.com/WasmEdge/WasmEdge/commit/512db9f513fff9facac396ac72f31748de638797 512db9f5 fix(wasi-nn): use NuGet source for Piper ONNX Runtime Yi Huang , 2026-11-27 Signed-off-by: Yi Huang --- Dockerfile.debian-static | 14 +++- Dockerfile.manylinux_2_28-plugins-deps | 7 -- Dockerfile.ubuntu-base | 2 +- Dockerfile.ubuntu-plugins-deps | 9 --- docker-bake.alpine-base.hcl | 12 ++-- scripts/ffmpeg/install-ffmpeg-v7.1.1.sh | 2 +- scripts/opencvmini/install-opencvmini.sh | 19 ------ scripts/wasi-nn/install-libpiper.sh | 47 +++++++++++-- scripts/wasi-nn/install-onnxruntime.sh | 27 -------- scripts/wasi-nn/libpiper.patch | 86 +++++++++++++++++++++--- 10 files changed, 143 insertions(+), 82 deletions(-) delete mode 100644 scripts/opencvmini/install-opencvmini.sh delete mode 100644 scripts/wasi-nn/install-onnxruntime.sh diff --git a/Dockerfile.debian-static b/Dockerfile.debian-static index 68418a0..edd231a 100644 --- a/Dockerfile.debian-static +++ b/Dockerfile.debian-static @@ -11,7 +11,7 @@ COPY --from=xx / / # Install host dependencies RUN apt-get update -y && apt-get install --no-install-recommends -y \ lsb-release ca-certificates curl wget gnupg \ - cmake ninja-build git clang xz-utils + cmake ninja-build git clang xz-utils file # Set up llvm's apt repo ARG LLVM_VERSION @@ -85,6 +85,18 @@ RUN cmake -S /src -B /build -G Ninja \ -DWASMEDGE_USE_LLVM=ON RUN cmake --build /build -- install + +# Link a consumer against the installed static library +RUN /bin/bash < /smoke.c +#include +int main(void) { return WasmEdge_VersionGet() == 0; } +EOF + xx-clang /smoke.c -I/install/include -L/install/lib -lwasmedge -lstdc++ -lm -lrt -ldl -lpthread -o /smoke + xx-verify /smoke +EOT + RUN cmake --build /build -- package RUN mv /build/WasmEdge-*-Linux.tar.gz $(echo build/WasmEdge-*-Linux.tar.gz | sed 's|WasmEdge-\(.*\)-Linux.tar.gz|WasmEdge-\1-debian'$(lsb_release -sr)'_'$(xx-info march)'_static.tar.gz|') diff --git a/Dockerfile.manylinux_2_28-plugins-deps b/Dockerfile.manylinux_2_28-plugins-deps index 4ecc921..33d2e6a 100644 --- a/Dockerfile.manylinux_2_28-plugins-deps +++ b/Dockerfile.manylinux_2_28-plugins-deps @@ -27,10 +27,6 @@ RUN cd && (yum check-update || true) && \ ### deps for all ### FROM deps-${TARGETARCH} AS final -COPY scripts/opencvmini/install-opencvmini.sh . -ENV OPENCV_VERSION="4.8.0" -RUN [ "/bin/bash", "install-opencvmini.sh" ] - COPY scripts/wasi-crypto/build-openssl.sh . ENV OpenSSL_DIR="/root/openssl-1.1.1n/openssl" RUN [ "/bin/bash", "build-openssl.sh" ] @@ -43,9 +39,6 @@ ENV LD_LIBRARY_PATH=/root/FFmpeg-n7.1.1/output/lib${LD_LIBRARY_PATH:+:${LD_LIBRA ENV OPENVINO_VERSION="2025.0.0" ENV OPENVINO_YEAR="2025" -COPY scripts/wasi-nn/install-onnxruntime.sh . -RUN [ "/bin/bash", "install-onnxruntime.sh" ] - COPY scripts/wasi-nn/libpiper.patch . COPY scripts/wasi-nn/install-libpiper.sh . RUN [ "/bin/bash", "install-libpiper.sh" ] diff --git a/Dockerfile.ubuntu-base b/Dockerfile.ubuntu-base index 0fc6118..a966211 100644 --- a/Dockerfile.ubuntu-base +++ b/Dockerfile.ubuntu-base @@ -22,7 +22,7 @@ FROM base AS deps-20 RUN curl -sSf https://apt.kitware.com/kitware-archive.sh | sh RUN apt-get install -y cmake -RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ +RUN curl -4 -sSfL --retry 5 https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/apt.llvm.org.asc \ && echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-18 main" | tee /etc/apt/sources.list.d/llvm.list RUN apt-get install -y \ diff --git a/Dockerfile.ubuntu-plugins-deps b/Dockerfile.ubuntu-plugins-deps index a4b843a..dbc39ff 100644 --- a/Dockerfile.ubuntu-plugins-deps +++ b/Dockerfile.ubuntu-plugins-deps @@ -47,10 +47,6 @@ FROM deps-${UBUNTU_VER} AS deps-all WORKDIR /root -COPY scripts/opencvmini/install-opencvmini.sh . -ENV OPENCV_VERSION="4.8.0" -RUN [ "/bin/bash", "install-opencvmini.sh" ] - COPY scripts/wasi-nn/install-pytorch.sh . ENV PYTORCH_VERSION="2.12.1" ENV PYTORCH_INSTALL_TO="/usr/local/libtorch" @@ -72,9 +68,6 @@ RUN [ "/bin/bash", "install-openvino-genai.sh" ] RUN [ "ls", "-al" ] RUN [ "/bin/bash", "-c", "echo \"source ./openvino_genai/setupvars.sh\" >> .bashrc" ] -COPY scripts/wasi-nn/install-onnxruntime.sh . -RUN [ "/bin/bash", "install-onnxruntime.sh" ] - COPY scripts/wasi-nn/libpiper.patch . COPY scripts/wasi-nn/install-libpiper.sh . RUN [ "/bin/bash", "install-libpiper.sh" ] @@ -86,11 +79,9 @@ RUN [ "/bin/bash", "install-chattts.sh" ] FROM deps-all AS clean-apt RUN rm -f \ - install-opencvmini.sh \ install-ffmpeg-v7.1.1.sh \ install-pytorch.sh \ install-openvino.sh \ - install-onnxruntime.sh \ install-openvino-genai.sh \ install-chattts.sh \ install-libpiper.sh diff --git a/docker-bake.alpine-base.hcl b/docker-bake.alpine-base.hcl index e64a83b..8ebd12d 100644 --- a/docker-bake.alpine-base.hcl +++ b/docker-bake.alpine-base.hcl @@ -5,8 +5,12 @@ group "default" { target "alpine-base" { dockerfile = "Dockerfile.alpine-base" context = "." - # Build for both major architectures at once - platforms = ["linux/amd64", "linux/arm64"] - # Tag it clearly so we can use it later - tags = ["wasmedge/wasmedge:alpine-base-3.23"] + + matrix = { + arch = ["amd64", "arm64"] + } + + name = "alpine-base-${arch}" + platforms = ["linux/${arch}"] + tags = ["wasmedge/wasmedge:alpine-base-3.23-${arch}"] } diff --git a/scripts/ffmpeg/install-ffmpeg-v7.1.1.sh b/scripts/ffmpeg/install-ffmpeg-v7.1.1.sh index 4e04994..4466a9b 100644 --- a/scripts/ffmpeg/install-ffmpeg-v7.1.1.sh +++ b/scripts/ffmpeg/install-ffmpeg-v7.1.1.sh @@ -8,7 +8,7 @@ unzip ffmpeg.zip mkdir -p FFmpeg-n7.1.1/output cd FFmpeg-n7.1.1 ./configure --prefix=$(pwd)/output --enable-gpl --enable-nonfree --enable-shared --disable-static -make && make install +make -j"$(nproc)" && make install cd .. rm -rf ffmpeg.zip diff --git a/scripts/opencvmini/install-opencvmini.sh b/scripts/opencvmini/install-opencvmini.sh deleted file mode 100644 index ec2da38..0000000 --- a/scripts/opencvmini/install-opencvmini.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# SPDX-FileCopyrightText: Copyright The WasmEdge Authors -OPENCV_VERSION=${OPENCV_VERSION:-4.8.0} - -wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/${OPENCV_VERSION}.zip - -unzip opencv.zip -mv opencv-${OPENCV_VERSION} opencv - -mkdir -p opencv/build && cd opencv/build -# Configure -cmake -GNinja .. -# Build -cmake --build . -# Install to system -cmake --install . - -cd - && rm -rf opencv opencv.zip diff --git a/scripts/wasi-nn/install-libpiper.sh b/scripts/wasi-nn/install-libpiper.sh index d2242fd..d2a4733 100755 --- a/scripts/wasi-nn/install-libpiper.sh +++ b/scripts/wasi-nn/install-libpiper.sh @@ -13,18 +13,53 @@ if [ ! -f "${PATCH_PATH}" ]; then fi PIPER_REPO="https://github.com/OHF-Voice/piper1-gpl.git" -PIPER_COMMIT="32b95f8c1f0dc0ce27a6acd1143de331f61af777" +PIPER_COMMIT="639388b6317fc4731e91d53da42aea68fd4166ff" PIPER_INSTALL_TO="/usr/local" +ONNXRUNTIME_VERSION="1.22.0" case "$(uname -m)" in - 'x86_64') ;; - 'aarch64') ;; + 'x86_64') + ONNXRUNTIME_ARCH="x64" + ONNXRUNTIME_RID="linux-x64" + ;; + 'aarch64') + ONNXRUNTIME_ARCH="aarch64" + ONNXRUNTIME_RID="linux-arm64" + ;; *) echo "Unsupported architecture for libpiper: $(uname -m)" >&2 exit 1 ;; esac +ONNXRUNTIME_NAME="onnxruntime-linux-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}" +ONNXRUNTIME_PACKAGE="microsoft.ml.onnxruntime.${ONNXRUNTIME_VERSION}.nupkg" +ONNXRUNTIME_URL="https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PACKAGE}" +ONNXRUNTIME_PACKAGE_SHA256="d571e63a2329baacb713f441e65ad75284de354db6e1ac435fe4bebbb417986a" + +rm -rf "${ONNXRUNTIME_NAME}" "${ONNXRUNTIME_PACKAGE}" +DOWNLOADED=0 +for _ in 1 2 3 4 5; do + if curl -fL -o "${ONNXRUNTIME_PACKAGE}" "${ONNXRUNTIME_URL}"; then + DOWNLOADED=1 + break + fi + sleep 10 +done +[ "${DOWNLOADED}" -eq 1 ] +echo "${ONNXRUNTIME_PACKAGE_SHA256} ${ONNXRUNTIME_PACKAGE}" | sha256sum -c +mkdir -p "${ONNXRUNTIME_NAME}/include" "${ONNXRUNTIME_NAME}/lib" +unzip -q "${ONNXRUNTIME_PACKAGE}" \ + "build/native/include/*" \ + "runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime.so" \ + "runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime_providers_shared.so" \ + -d .onnxruntime-package +cp -R .onnxruntime-package/build/native/include/. "${ONNXRUNTIME_NAME}/include/" +cp .onnxruntime-package/runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime.so "${ONNXRUNTIME_NAME}/lib/" +cp .onnxruntime-package/runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime_providers_shared.so "${ONNXRUNTIME_NAME}/lib/" +rm -rf .onnxruntime-package +ONNXRUNTIME_DIR="$(pwd)/${ONNXRUNTIME_NAME}" + rm -rf piper-source git clone --depth 1 "${PIPER_REPO}" piper-source cd piper-source @@ -37,9 +72,11 @@ cd libpiper cmake -Bbuild \ -DCMAKE_BUILD_TYPE=Release \ + -DPIPER_BUILD_EXE=OFF \ -DCMAKE_INSTALL_PREFIX="${PIPER_INSTALL_TO}" \ -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" cmake --build build --parallel $(nproc) cmake --install build @@ -75,6 +112,6 @@ else fi cd ../.. -rm -rf piper-source +rm -rf piper-source "${ONNXRUNTIME_NAME}" "${ONNXRUNTIME_PACKAGE}" ldconfig diff --git a/scripts/wasi-nn/install-onnxruntime.sh b/scripts/wasi-nn/install-onnxruntime.sh deleted file mode 100644 index 4943833..0000000 --- a/scripts/wasi-nn/install-onnxruntime.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: Apache-2.0 -# SPDX-FileCopyrightText: Copyright The WasmEdge Authors - -set -e - -case "$(uname -m)" in - 'x86_64') ARCH='x64' ;; - 'aarch64') ARCH='aarch64' ;; - *) - echo 'Cannot determine architecture for onnxruntime' >&2 - exit 1 - ;; -esac - -: ${ONNXRUNTIME_VERSION:=1.14.1} - -ONNXRUNTIME_NAME="onnxruntime-linux-${ARCH}-${ONNXRUNTIME_VERSION}" -ONNXRUNTIME_TGZ="${ONNXRUNTIME_NAME}.tgz" - -curl -LO "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_TGZ}" -tar zxf "${ONNXRUNTIME_TGZ}" -mv "${ONNXRUNTIME_NAME}/include/"* /usr/local/include/ -mv "${ONNXRUNTIME_NAME}/lib/"* /usr/local/lib/ -rm -rf "${ONNXRUNTIME_TGZ}" "${ONNXRUNTIME_NAME}" - -ldconfig diff --git a/scripts/wasi-nn/libpiper.patch b/scripts/wasi-nn/libpiper.patch index e74cb4b..0fedba8 100644 --- a/scripts/wasi-nn/libpiper.patch +++ b/scripts/wasi-nn/libpiper.patch @@ -1,22 +1,92 @@ diff --git a/libpiper/CMakeLists.txt b/libpiper/CMakeLists.txt -index 57349c1..2e7ddd8 100644 +index d43e714..a59d625 100644 --- a/libpiper/CMakeLists.txt +++ b/libpiper/CMakeLists.txt -@@ -2,6 +2,8 @@ +@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.26) project(piper LANGUAGES C CXX) - + +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) ++option(PIPER_BUILD_EXE "Build the piper command line tool" ON) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -@@ -112,7 +114,7 @@ endif() - + +@@ -141,7 +144,7 @@ endif() + include(ClangTidy.cmake) # ---- libpiper --- - + -add_library(piper SHARED +add_library(piper ${CMAKE_CURRENT_SOURCE_DIR}/src/piper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/chinese_phonemizer.cpp ) - +@@ -159,10 +162,12 @@ target_link_libraries(piper + ) + + # ---- piper exe --- +-add_subdirectory(src/main) ++if(PIPER_BUILD_EXE) ++ add_subdirectory(src/main) ++endif() + + # ---- version +-file(READ ${CMAKE_SOURCE_DIR}/../setup.py SETUP_PY_CONTENTS) ++file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../setup.py SETUP_PY_CONTENTS) + string(REGEX MATCH "version=\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _ ${SETUP_PY_CONTENTS}) + set(PIPER_VERSION ${CMAKE_MATCH_1}) + +diff --git a/libpiper/src/piper.cpp b/libpiper/src/piper.cpp +index 56b61b0..608b5be 100644 +--- a/libpiper/src/piper.cpp ++++ b/libpiper/src/piper.cpp +@@ -4,6 +4,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -22,6 +23,7 @@ + #define PIPER_VERSION "0.0.1" + #endif + ++#include + #include + + using json = nlohmann::json; +@@ -95,13 +97,19 @@ auto piper_create_with_options(const piper_create_options *options) + phoneme_type = config["phoneme_type"].get(); + } + +- if (phoneme_type == PhonemeType::Espeak && +- espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, 0, final_espeak_data_path, +- 0) < 0) { +- return nullptr; ++ if (phoneme_type == PhonemeType::Espeak) { ++ espeak_ng_InitializePath(final_espeak_data_path); ++ espeak_ng_ERROR_CONTEXT espeak_context = nullptr; ++ espeak_ng_STATUS espeak_status = espeak_ng_Initialize(&espeak_context); ++ if (espeak_status != ENS_OK) { ++ espeak_ng_PrintStatusCodeMessage(espeak_status, stderr, espeak_context); ++ espeak_ng_ClearErrorContext(&espeak_context); ++ return nullptr; ++ } ++ espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS, 0, nullptr); + } + +- auto *synth = new piper_synthesizer(); ++ std::unique_ptr synth(new piper_synthesizer()); + synth->phoneme_type = phoneme_type; + + // Load config options +@@ -280,7 +288,7 @@ auto piper_create_with_options(const piper_create_options *options) + synth->session = std::make_unique( + Ort::Session(ort_env, model_path_ort, synth->session_options)); + +- return synth; ++ return synth.release(); + } + + auto piper_create(const char *model_path, const char *config_path, From f76a9157243579a6a8aced2df4cef3c7fda10a67 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Mon, 30 Nov 2026 16:06:50 +0800 Subject: [PATCH 5/5] docs(devcontainer): pin current WasmEdge snapshot Signed-off-by: Yi Huang --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4db1b3f..9544c1b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ > [!WARNING] > **Work in Progress** +Current WasmEdge snapshot: `512db9f513fff9facac396ac72f31748de638797` + This repository owns the Dockerfiles, dependency scripts, Bake definitions, and image-building workflow for reusable WasmEdge development environments. The consolidated `.github/workflows/docker.yml` builds CI base, Ubuntu,