diff --git a/.bazelignore b/.bazelignore index 3c3629e6..becc8ca0 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1 +1,3 @@ +.github node_modules +wasm-cc diff --git a/.bazelrc b/.bazelrc index 2c605df3..c52e51bb 100644 --- a/.bazelrc +++ b/.bazelrc @@ -16,5 +16,7 @@ common:examples --action_env=BUILDKIT_PROGRESS common:examples --host_action_env=BUILDKIT_PROGRESS common:examples --sandbox_writable_path=/var/run/docker.sock +common --@rules_python//python/config_settings:bootstrap_impl=script + try-import %workspace%/user.bazelrc try-import %workspace%/repo.bazelrc diff --git a/.github/workflows/_verify_wasm.yml b/.github/workflows/_verify_wasm.yml new file mode 100644 index 00000000..7d47f60c --- /dev/null +++ b/.github/workflows/_verify_wasm.yml @@ -0,0 +1,21 @@ +name: Verify/Wasm + +permissions: + contents: read + +on: + workflow_call: + + +jobs: + wasm: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - run: | + docker pull envoyproxy/envoy:dev + DEV_CONTAINER_ID=$(docker inspect --format='{{.Id}}' envoyproxy/envoy:dev) + echo "DEV_CONTAINER_ID=${DEV_CONTAINER_ID}" >> $GITHUB_ENV + - run: | + ./verify.sh + working-directory: wasm-cc diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 59f2ec87..fc201eb4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -27,13 +27,15 @@ jobs: path: examples - run: | export UID - docker compose run --quiet --quiet-pull --quiet-build docs + echo 'load("@envoy_examples//bazel:env.bzl", "envoy_examples_env")' >> ../envoy/WORKSPACE + echo 'envoy_examples_env()' >> ../envoy/WORKSPACE + docker compose run docs working-directory: examples env: BAZEL_BUILD_EXTRA_OPTIONS: >- --override_repository=envoy_examples=../examples --config=ci --@rules_python//python/config_settings:bootstrap_impl=script - DOCKER_BUILDKIT: 1 - COMPOSE_BAKE: true BUILDKIT_PROGRESS: quiet + COMPOSE_BAKE: true + DOCKER_BUILDKIT: 1 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index a1fa6d0a..3ca875b2 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -17,3 +17,5 @@ concurrency: jobs: examples: uses: ./.github/workflows/_verify_examples.yml + wasm: + uses: ./.github/workflows/_verify_wasm.yml diff --git a/BUILD b/BUILD index 97d58507..436e8dd8 100644 --- a/BUILD +++ b/BUILD @@ -4,6 +4,7 @@ load("//:examples.bzl", "envoy_examples") licenses(["notice"]) # Apache 2 +# Excluding build tests - eg wasm - these should be run directly EXAMPLE_TESTS = [ "brotli", "cache", @@ -40,7 +41,6 @@ EXAMPLE_TESTS = [ "udp", "vrp-litmus", # "vrp-local", - # "wasm-cc", "websocket", "zipkin", "zstd", @@ -66,7 +66,7 @@ filegroup( "postgres/*", "kafka/*.yaml", ], - ), + ) + ["@envoy-example-wasmcc//:configs"], visibility = ["//visibility:public"], ) @@ -95,7 +95,7 @@ filegroup( filegroup( name = "docs_rst", - srcs = glob(["**/example.rst"]) + ["//wasm-cc:example.rst"], + srcs = glob(["**/example.rst"]) + ["@envoy-example-wasmcc//:example.rst"], ) pkg_files( @@ -112,8 +112,12 @@ genrule( cmd = """ TEMP=$$(mktemp -d) for location in $(locations :docs_rst); do - example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1) - cp -a $$location "$${TEMP}/$${example}.rst" + if [[ "$$location" == *"/envoy-example"* ]]; then + example="$$(echo "$$location" | cut -d- -f3- | cut -d/ -f1)" + else + example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1) + fi + cp -aL $$location "$${TEMP}/$${example}.rst" echo " $${example}" >> "$${TEMP}/_toctree.rst" done echo ".. toctree::" > "$${TEMP}/toctree.rst" @@ -121,7 +125,7 @@ genrule( echo "" >> "$${TEMP}/toctree.rst" cat "$${TEMP}/_toctree.rst" | sort >> "$${TEMP}/toctree.rst" rm "$${TEMP}/_toctree.rst" - tar czf $@ -C $${TEMP} . + tar chzf $@ -C $${TEMP} . """, ) @@ -134,24 +138,21 @@ filegroup( filegroup( name = "files", srcs = glob( - [ - "**/*", - ], + ["**/*"], exclude = [ "**/*~", "**/.*", "**/#*", ".*/**/*", "BUILD", - ".git/**/*", + "README.md", + "WORKSPACE", "bazel-*/**/*", "**/node_modules/**", "**/*.rst", "win32*", ], - ) + [ - "//wasm-cc:files", - ], + ), ) pkg_tar( @@ -159,7 +160,10 @@ pkg_tar( srcs = [":examples_files"], extension = "tar.gz", package_dir = "start/sandboxes", - deps = [":examples_docs"], + deps = [ + ":examples_docs", + "@envoy-example-wasmcc//:includes", + ], visibility = ["//visibility:public"], ) diff --git a/WORKSPACE b/WORKSPACE index 4b8ac916..c79f8d3a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,4 +1,7 @@ -workspace(name = "envoy-examples") +workspace(name = "envoy_examples") + +load("//bazel:env.bzl", "envoy_examples_env") +envoy_examples_env() load("//bazel:archives.bzl", "load_envoy_examples_archives") load_envoy_examples_archives() @@ -8,3 +11,6 @@ resolve_envoy_examples_dependencies() load("//bazel:toolchains.bzl", "load_envoy_examples_toolchains") load_envoy_examples_toolchains() + +load("//bazel:packages.bzl", "load_envoy_examples_packages") +load_envoy_examples_packages() diff --git a/bazel/archives.bzl b/bazel/archives.bzl index 111b1ee2..b6489865 100644 --- a/bazel/archives.bzl +++ b/bazel/archives.bzl @@ -1,4 +1,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@envoy-example-wasmcc//bazel:archives.bzl", "load_envoy_example_wasmcc_archives") load("//bazel:versions.bzl", "VERSIONS") def load_github_archives(): @@ -36,3 +37,4 @@ def load_http_archives(): def load_envoy_examples_archives(): load_github_archives() load_http_archives() + load_envoy_example_wasmcc_archives() diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 51a597d6..460ec646 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -1,6 +1,8 @@ +load("@envoy-example-wasmcc//bazel:deps.bzl", "resolve_envoy_example_wasmcc_dependencies") load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") load("@rules_python//python:repositories.bzl", "py_repositories") def resolve_envoy_examples_dependencies(): go_rules_dependencies() py_repositories() + resolve_envoy_example_wasmcc_dependencies() diff --git a/bazel/env.bzl b/bazel/env.bzl new file mode 100644 index 00000000..5da94b7c --- /dev/null +++ b/bazel/env.bzl @@ -0,0 +1,16 @@ +load("//bazel:nested.bzl", "load_envoy_nested_examples") + +def _impl(ctx): + need = ctx.os.environ.get("ENVOY_EXAMPLES_LLVM_ENABLED") == "1" + ctx.file("llvm_flag.bzl", content = "LLVM_ENABLED = %s\n" % need) + ctx.file("WORKSPACE", content = "") + ctx.file("BUILD", content = "") + +_envoy_examples_env = repository_rule( + implementation = _impl, + environ = ["ENVOY_EXAMPLES_LLVM_ENABLED"], +) + +def envoy_examples_env(): + _envoy_examples_env(name = "envoy_examples_env") + load_envoy_nested_examples() diff --git a/bazel/nested.bzl b/bazel/nested.bzl new file mode 100644 index 00000000..e8740f0b --- /dev/null +++ b/bazel/nested.bzl @@ -0,0 +1,28 @@ + +def _example_repo_impl(ctx): + example_resources = [ + "WORKSPACE", + "BUILD", + "bazel", + "envoy.yaml", + "example.rst", + "envoy_filter_http_wasm_updated_example.cc", + "envoy_filter_http_wasm_example.cc", + "Dockerfile-proxy", + ] + for d in example_resources: + ctx.symlink(ctx.path(ctx.attr.examples_root).dirname.get_child(ctx.attr.path).get_child(d), d) + +example_repository = repository_rule( + implementation = _example_repo_impl, + attrs = { + "examples_root": attr.label(default = "@envoy_examples//:BUILD"), + "path": attr.string(mandatory=True), + }, +) + +def load_envoy_nested_examples(): + example_repository( + name = "envoy-example-wasmcc", + path = "wasm-cc", + ) diff --git a/bazel/packages.bzl b/bazel/packages.bzl new file mode 100644 index 00000000..d77b7078 --- /dev/null +++ b/bazel/packages.bzl @@ -0,0 +1,8 @@ +load("@envoy_examples_env//:llvm_flag.bzl", "LLVM_ENABLED") +load("@envoy-example-wasmcc//bazel:packages.bzl", "load_envoy_example_wasmcc_packages") +load("@envoy-example-wasmcc//bazel:toolchains_extra.bzl", "load_envoy_example_wasmcc_toolchains_extra") + +def load_envoy_examples_packages(): + load_envoy_example_wasmcc_packages() + if LLVM_ENABLED: + load_envoy_example_wasmcc_toolchains_extra() diff --git a/bazel/toolchains.bzl b/bazel/toolchains.bzl index c5c07d69..48741e3d 100644 --- a/bazel/toolchains.bzl +++ b/bazel/toolchains.bzl @@ -1,3 +1,4 @@ +load("@envoy-example-wasmcc//bazel:toolchains.bzl", "load_envoy_example_wasmcc_toolchains") load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") load("@rules_python//python:repositories.bzl", "python_register_toolchains") load("//bazel:versions.bzl", "VERSIONS") @@ -8,3 +9,4 @@ def load_envoy_examples_toolchains(): name = "python%s" % VERSIONS["python"].replace(".", "_"), python_version = VERSIONS["python"].replace("-", "_"), ) + load_envoy_example_wasmcc_toolchains(go=False) diff --git a/docker-compose.yml b/docker-compose.yml index ce2e1d49..222abf90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,7 @@ services: - | ./ci/do_ci.sh docs environment: + DOCS_BUILD_RST: "${DOCS_BUILD_RST:-}" BAZEL_BUILD_EXTRA_OPTIONS: >- ${BAZEL_BUILD_EXTRA_OPTIONS:- --override_repository=envoy_examples=../examples diff --git a/shared/build/Dockerfile b/shared/build/Dockerfile index 92ea0ad5..e74f1123 100644 --- a/shared/build/Dockerfile +++ b/shared/build/Dockerfile @@ -1,7 +1,6 @@ -FROM envoyproxy/envoy-build-ubuntu:f94a38f62220a2b017878b790b6ea98a0f6c5f9c@sha256:2dd96b6f43c08ccabd5f4747fce5854f5f96af509b32e5cf6493f136e9833649 +FROM envoyproxy/envoy-build:ci-cdfbb76bc18c115270127132c6f7c67000cd2e74@sha256:48a8b1bc24ed771560126642dcbba33c50c6b837722ba9c75270b858ef7ab3a6 ENV DEBIAN_FRONTEND=noninteractive RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ - apt-get -qq install --no-install-recommends -y gosu \ - && groupadd -f envoygroup \ - && useradd -g envoygroup -m -d /home/envoybuild envoybuild + apt-get -qq update \ + && apt-get -qq install --no-install-recommends -y gosu diff --git a/shared/build/build-entrypoint.sh b/shared/build/build-entrypoint.sh index 7b824337..8737944d 100755 --- a/shared/build/build-entrypoint.sh +++ b/shared/build/build-entrypoint.sh @@ -5,9 +5,9 @@ set -e if [[ $(id -u envoybuild) != "${BUILD_UID}" ]]; then usermod -u "${BUILD_UID}" envoybuild chown envoybuild /home/envoybuild + chown envoybuild /home/envoybuild/.cache fi chown envoybuild /output -chmod 1777 /tmp exec gosu envoybuild "$@" diff --git a/wasm-cc/.bazelignore b/wasm-cc/.bazelignore new file mode 100644 index 00000000..9b8d0a56 --- /dev/null +++ b/wasm-cc/.bazelignore @@ -0,0 +1,2 @@ +# only directories can be ignored, and no globbing +.github diff --git a/wasm-cc/.bazelrc b/wasm-cc/.bazelrc new file mode 100644 index 00000000..7f7fc81a --- /dev/null +++ b/wasm-cc/.bazelrc @@ -0,0 +1,7 @@ +common --enable_bzlmod=0 +common --color=yes +common:ci --noshow_progress +common:ci --noshow_loading_progress +common:ci --test_output=errors + +common --@rules_python//python/config_settings:bootstrap_impl=script diff --git a/wasm-cc/.bazelversion b/wasm-cc/.bazelversion new file mode 100644 index 00000000..93c8ddab --- /dev/null +++ b/wasm-cc/.bazelversion @@ -0,0 +1 @@ +7.6.0 diff --git a/wasm-cc/BUILD b/wasm-cc/BUILD index 0d5fedec..9ea0f641 100644 --- a/wasm-cc/BUILD +++ b/wasm-cc/BUILD @@ -1,5 +1,6 @@ load("@bazel_skylib//lib:selects.bzl", "selects") -# load("@envoy//bazel/wasm:wasm.bzl", "envoy_wasm_cc_binary") +load("@envoy//bazel/wasm:wasm.bzl", "envoy_wasm_cc_binary") +load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") licenses(["notice"]) # Apache 2 @@ -8,8 +9,8 @@ exports_files(["example.rst"]) selects.config_setting_group( name = "include_wasm_config", match_all = [ - "//bazel:x86", - "//bazel:wasm_v8", + "@envoy//bazel:x86", + "@envoy//bazel:wasm_v8", ], ) @@ -31,18 +32,34 @@ filegroup( visibility = ["//visibility:public"], ) -# envoy_wasm_cc_binary( -# name = "envoy_filter_http_wasm_example.wasm", -# srcs = ["envoy_filter_http_wasm_example.cc"], -# ) +envoy_wasm_cc_binary( + name = "envoy_filter_http_wasm_example.wasm", + srcs = ["envoy_filter_http_wasm_example.cc"], +) -# envoy_wasm_cc_binary( -# name = "envoy_filter_http_wasm_updated_example.wasm", -# srcs = ["envoy_filter_http_wasm_updated_example.cc"], -# ) +envoy_wasm_cc_binary( + name = "envoy_filter_http_wasm_updated_example.wasm", + srcs = ["envoy_filter_http_wasm_updated_example.cc"], +) filegroup( name = "files", - srcs = glob(["**/*"], exclude = ["example.rst", "BUILD"]), + srcs = glob( + ["**/*"], + exclude = [ + "**/*~", + "**/.*", + ".*/**/*", + "example.rst", + "BUILD", + "README.md", + "WORKSPACE", + ]), +) + +pkg_tar( + name = "includes", + srcs = [":files"], + package_dir = "_include/wasm-cc", visibility = ["//visibility:public"], ) diff --git a/wasm-cc/WORKSPACE b/wasm-cc/WORKSPACE new file mode 100644 index 00000000..6b7a9752 --- /dev/null +++ b/wasm-cc/WORKSPACE @@ -0,0 +1,16 @@ +workspace(name = "envoy-example-wasmcc") + +load("//bazel:archives.bzl", "load_envoy_example_wasmcc_archives") +load_envoy_example_wasmcc_archives() + +load("//bazel:deps.bzl", "resolve_envoy_example_wasmcc_dependencies") +resolve_envoy_example_wasmcc_dependencies() + +load("//bazel:toolchains.bzl", "load_envoy_example_wasmcc_toolchains") +load_envoy_example_wasmcc_toolchains() + +load("//bazel:packages.bzl", "load_envoy_example_wasmcc_packages") +load_envoy_example_wasmcc_packages() + +load("//bazel:toolchains_extra.bzl", "load_envoy_example_wasmcc_toolchains_extra") +load_envoy_example_wasmcc_toolchains_extra() diff --git a/wasm-cc/bazel/BUILD b/wasm-cc/bazel/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/wasm-cc/bazel/archives.bzl b/wasm-cc/bazel/archives.bzl new file mode 100644 index 00000000..ae658da5 --- /dev/null +++ b/wasm-cc/bazel/archives.bzl @@ -0,0 +1,38 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//bazel:versions.bzl", "VERSIONS") + +def load_github_archives(): + for k, v in VERSIONS.items(): + if type(v) == type("") or v.get("type") != "github_archive": + continue + kwargs = dict(name = k, **v) + # Format string values, but not lists + formatted_kwargs = {} + for arg_k, arg_v in kwargs.items(): + if arg_k in ["repo", "type", "version"]: + continue + if type(arg_v) == type(""): + formatted_kwargs[arg_k] = arg_v.format(**kwargs) + else: + formatted_kwargs[arg_k] = arg_v + http_archive(**formatted_kwargs) + +def load_http_archives(): + for k, v in VERSIONS.items(): + if type(v) == type("") or v.get("type") != "http_archive": + continue + kwargs = dict(name = k, **v) + # Format string values, but not lists + formatted_kwargs = {} + for arg_k, arg_v in kwargs.items(): + if arg_k in ["type", "version"]: + continue + if type(arg_v) == type(""): + formatted_kwargs[arg_k] = arg_v.format(**kwargs) + else: + formatted_kwargs[arg_k] = arg_v + http_archive(**formatted_kwargs) + +def load_envoy_example_wasmcc_archives(): + load_github_archives() + load_http_archives() diff --git a/wasm-cc/bazel/deps.bzl b/wasm-cc/bazel/deps.bzl new file mode 100644 index 00000000..712b0b05 --- /dev/null +++ b/wasm-cc/bazel/deps.bzl @@ -0,0 +1,43 @@ +load("@emsdk//:deps.bzl", emsdk_deps = "deps") +load("@envoy//bazel:api_binding.bzl", "envoy_api_binding") +load("@envoy_toolshed//sysroot:sysroot.bzl", "setup_sysroots") +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") +load("@rules_perl//perl:deps.bzl", "perl_rules_dependencies") +load("@rules_python//python:repositories.bzl", "py_repositories") +load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") +load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") +load("//bazel:versions.bzl", "VERSIONS") + +def resolve_envoy_example_wasmcc_dependencies( + cmake_version=VERSIONS["cmake"], + llvm_version=VERSIONS["llvm"], + ninja_version=VERSIONS["ninja"], + setup_autotools_toolchain=True): + envoy_api_binding() + py_repositories() + bazel_toolchain_dependencies() + rules_foreign_cc_dependencies( + register_preinstalled_tools = True, + register_default_tools = True, + cmake_version = cmake_version, + ninja_version = ninja_version, + ) + emsdk_deps() + perl_rules_dependencies() + rules_fuzzing_dependencies( + oss_fuzz = True, + honggfuzz = False, + ) + setup_sysroots() + if llvm_version != False: + llvm_toolchain( + name = "llvm_toolchain", + llvm_version = llvm_version, + sysroot = { + "linux-x86_64": "@sysroot_linux_amd64//:sysroot", + "linux-aarch64": "@sysroot_linux_arm64//:sysroot", + } + ) + go_rules_dependencies() diff --git a/wasm-cc/bazel/packages.bzl b/wasm-cc/bazel/packages.bzl new file mode 100644 index 00000000..b6ee9b76 --- /dev/null +++ b/wasm-cc/bazel/packages.bzl @@ -0,0 +1,18 @@ +load("@bazel_features//:deps.bzl", "bazel_features_deps") +load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") +load("@emsdk//:emscripten_deps.bzl", "emscripten_deps") +load("@envoy//bazel:repositories.bzl", "default_envoy_build_config") +load("@rules_python//python:pip.bzl", "pip_parse") +load("//bazel:versions.bzl", "VERSIONS") + +def load_envoy_example_wasmcc_packages(): + # This is empty - it should be overridden in your repo + pip_parse( + name = "toolshed_pip3", + requirements_lock = "@envoy_toolshed//:requirements.txt", + python_interpreter_target = "@python3_12_host//:python", + ) + bazel_features_deps() + emscripten_deps(emscripten_version = "4.0.6") + default_envoy_build_config(name = "envoy_build_config") + proto_bazel_features(name = "proto_bazel_features") diff --git a/wasm-cc/bazel/toolchains.bzl b/wasm-cc/bazel/toolchains.bzl new file mode 100644 index 00000000..388927e0 --- /dev/null +++ b/wasm-cc/bazel/toolchains.bzl @@ -0,0 +1,19 @@ +load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains") +load("@envoy//bazel:api_repositories.bzl", "envoy_api_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") +load("@rules_perl//perl:deps.bzl", "perl_register_toolchains") +load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains") +load("@rules_python//python:repositories.bzl", "python_register_toolchains") +load("//bazel:versions.bzl", "VERSIONS") + +def load_envoy_example_wasmcc_toolchains(go=True): + envoy_api_dependencies() + register_emscripten_toolchains() + python_register_toolchains( + name = "python%s" % VERSIONS["python"].replace(".", "_"), + python_version = VERSIONS["python"].replace("-", "_"), + ) + if go: + go_register_toolchains(VERSIONS["go"]) + rules_proto_grpc_toolchains() + perl_register_toolchains() diff --git a/wasm-cc/bazel/toolchains_extra.bzl b/wasm-cc/bazel/toolchains_extra.bzl new file mode 100644 index 00000000..1f190a00 --- /dev/null +++ b/wasm-cc/bazel/toolchains_extra.bzl @@ -0,0 +1,4 @@ +load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") + +def load_envoy_example_wasmcc_toolchains_extra(): + llvm_register_toolchains() diff --git a/wasm-cc/bazel/versions.bzl b/wasm-cc/bazel/versions.bzl new file mode 100644 index 00000000..4bfa2ef7 --- /dev/null +++ b/wasm-cc/bazel/versions.bzl @@ -0,0 +1,171 @@ + +VERSIONS = { + "cmake": "3.23.2", + "go": "1.23.1", + "llvm": "18.1.8", + "ninja": "1.12.0", + "python": "3.12", + + "aspect_bazel_lib": { + "type": "github_archive", + "repo": "aspect-build/bazel-lib", + "version": "2.16.0", + "sha256": "092f841dd9ea8e736ea834f304877a25190a762d0f0a6c8edac9f94aac8bbf16", + "strip_prefix": "bazel-lib-{version}", + "url": "https://github.com/{repo}/archive/v{version}.tar.gz", + }, + + "bazel_skylib": { + "type": "github_archive", + "repo": "bazelbuild/bazel-skylib", + "version": "1.4.2", + "sha256": "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", + "url": "https://github.com/{repo}/releases/download/{version}/bazel-skylib-{version}.tar.gz", + }, + + "com_github_grpc_grpc": { + "type": "github_archive", + "repo": "grpc/grpc", + "version": "1.72.0", + "sha256": "4a8aa99d5e24f80ea6b7ec95463e16af5bd91aa805e26c661ef6491ae3d2d23c", + "strip_prefix": "grpc-{version}", + "url": "https://github.com/{repo}/archive/v{version}.tar.gz", + }, + + "emsdk": { + "type": "github_archive", + "repo": "emscripten-core/emsdk", + "strip_prefix": "emsdk-{version}/bazel", + "version": "4.0.6", + "sha256": "2d3292d508b4f5477f490b080b38a34aaefed43e85258a1de72cb8dde3f8f3af", + "url": "https://github.com/emscripten-core/emsdk/archive/refs/tags/{version}.tar.gz", + "patch_args": ["-p2"], + "patches": ["@envoy//bazel:emsdk.patch"], + }, + + "envoy": { + "type": "github_archive", + "repo": "envoyproxy/envoy", + "version": "b230d0459019af6fd27d0f0dbbf896d73cb6695b", + "sha256": "b5a5758000f89712fb6cd9ad914615305790ab301aa0f8c073306501d67c1e91", + "url": "https://github.com/{repo}/archive/{version}.tar.gz", + "strip_prefix": "envoy-{version}", + }, + + "envoy_toolshed": { + "type": "github_archive", + "repo": "envoyproxy/toolshed", + "version": "0.3.3", + "sha256": "1ac69d5b1cbc138f779fc3858f06a6777455136260e1144010f0b51880f69814", + "url": "https://github.com/{repo}/archive/bazel-v{version}.tar.gz", + "patch_args": ["-p1"], + "strip_prefix": "toolshed-bazel-v{version}/bazel", + }, + + "io_bazel_rules_go": { + "type": "github_archive", + "repo": "bazelbuild/rules_go", + "version": "0.53.0", + "sha256": "b78f77458e77162f45b4564d6b20b6f92f56431ed59eaaab09e7819d1d850313", + "url": "https://github.com/bazelbuild/rules_go/releases/download/v{version}/rules_go-v{version}.zip", + }, + + "proxy_wasm_cpp_host": { + "type": "github_archive", + "repo": "proxy-wasm/proxy-wasm-cpp-host", + "version": "c4d7bb0fda912e24c64daf2aa749ec54cec99412", + "sha256": "3ea005e85d2b37685149c794c6876fd6de7f632f0ad49dc2b3cd580e7e7a5525", + "strip_prefix": "proxy-wasm-cpp-host-{version}", + "url": "https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz", + "patch_args": ["-p1"], + "patches": ["@envoy//bazel:proxy_wasm_cpp_host.patch"], + }, + + "proxy_wasm_cpp_sdk": { + "type": "github_archive", + "repo": "proxy-wasm/proxy-wasm-cpp-sdk", + "version": "dc4f37efacd2ff7bf2e8f36632f22e1e99347f3e", + "sha256": "487aef94e38eb2b717eb82aa5e3c7843b7da0c8b4624a5562c969050a1f3fa33", + "strip_prefix": "proxy-wasm-cpp-sdk-{version}", + "url": "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/{version}.tar.gz", + }, + + "rules_cc": { + "type": "github_archive", + "repo": "bazelbuild/rules_cc", + "version": "0.1.1", + "sha256": "712d77868b3152dd618c4d64faaddefcc5965f90f5de6e6dd1d5ddcd0be82d42", + "url": "https://github.com/{repo}/releases/download/{version}/rules_cc-{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "rules_foreign_cc": { + "type": "github_archive", + "repo": "bazelbuild/rules_foreign_cc", + "version": "0.14.0", + "sha256": "e0f0ebb1a2223c99a904a565e62aa285bf1d1a8aeda22d10ea2127591624866c", + "url": "https://github.com/{repo}/releases/download/{version}/{name}-{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "rules_fuzzing": { + "type": "github_archive", + "repo": "bazelbuild/rules_fuzzing", + "version": "0.5.3", + "sha256": "08274422c4383416df5f982943e40d58141f749c09008bb780440eece6b113e4", + "url": "https://github.com/{repo}/archive/v{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "rules_perl": { + "type": "github_archive", + "repo": "bazel-contrib/rules_perl", + "version": "0.4.1", + "sha256": "e09ba7ab6a52059a5bec71cf9a8a5b4e512c8592eb8d15af94ed59e048a2ec6d", + "url": "https://github.com/{repo}/archive/refs/tags/{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "rules_pkg": { + "type": "github_archive", + "repo": "bazelbuild/rules_pkg", + "version": "1.1.0", + "sha256": "b7215c636f22c1849f1c3142c72f4b954bb12bb8dcf3cbe229ae6e69cc6479db", + "url": "https://github.com/bazelbuild/rules_pkg/releases/download/{version}/rules_pkg-{version}.tar.gz", + }, + + "rules_proto_grpc": { + "type": "github_archive", + "repo": "rules-proto-grpc/rules_proto_grpc", + "version": "4.6.0", + "sha256": "2a0860a336ae836b54671cbbe0710eec17c64ef70c4c5a88ccfd47ea6e3739bd", + "url": "https://github.com/{repo}/releases/download/{version}/rules_proto_grpc-{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "rules_python": { + "type": "github_archive", + "repo": "bazelbuild/rules_python", + "version": "1.4.1", + "sha256": "9f9f3b300a9264e4c77999312ce663be5dee9a56e361a1f6fe7ec60e1beef9a3", + "url": "https://github.com/{repo}/releases/download/{version}/{name}-{version}.tar.gz", + "strip_prefix": "{name}-{version}", + }, + + "toolchains_llvm": { + "type": "github_archive", + "repo": "bazel-contrib/toolchains_llvm", + "version": "1.4.0", + "sha256": "fded02569617d24551a0ad09c0750dc53a3097237157b828a245681f0ae739f8", + "url": "https://github.com/{repo}/releases/download/v{version}/{name}-v{version}.tar.gz", + "strip_prefix": "{name}-v{version}", + }, + + "rules_rust": { + "type": "github_archive", + "repo": "bazelbuild/rules_rust", + "version": "0.56.0", + "sha256": "f1306aac0b258b790df01ad9abc6abb0df0b65416c74b4ef27f4aab298780a64", + "url": "https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-{version}.tar.gz", + }, +} diff --git a/wasm-cc/docker-compose-wasm.yaml b/wasm-cc/docker-compose-wasm.yaml index e9527a2f..34a7d583 100644 --- a/wasm-cc/docker-compose-wasm.yaml +++ b/wasm-cc/docker-compose-wasm.yaml @@ -2,37 +2,41 @@ services: wasm_compile_update: build: context: ../shared/build - command: > - bash -c " - bazel build --experimental_repository_downloader_retries=2 --disk_cache=/tmp/disk_cache - --repository_cache=/tmp/repository_cache --experimental_repository_cache_hardlinks - //examples/wasm-cc:envoy_filter_http_wasm_updated_example.wasm - && cp -a bazel-bin/examples/wasm-cc/*updated*.wasm /output" - entrypoint: /source/examples/shared/build/build-entrypoint.sh + command: + - bash + - -c + - | + set -eo pipefail + rm -f bazel-bin/*updated*.wasm + bazel build --experimental_repository_downloader_retries=2 --disk_cache=/tmp/disk_cache \ + --repository_cache=/tmp/repository_cache --experimental_repository_cache_hardlinks \ + //:envoy_filter_http_wasm_updated_example.wasm + cp -af bazel-bin/*updated*.wasm /output environment: - BUILD_UID=${UID:-1000} - - TEST_TMPDIR=/tmp - working_dir: /source + entrypoint: /source/shared/build/build-entrypoint.sh + working_dir: /source/wasm-cc volumes: - - ${ENVOY_DOCKER_BUILD_DIR:-/tmp/envoy-docker-build}:/tmp - - ../..:/source + - ${ENVOY_EXAMPLES_CACHE_DIR:-${HOME}/.cache/envoy/examples}:/home/envoybuild/.cache + - ..:/source - ./lib:/output wasm_compile: build: context: ../shared/build - command: > - bash -c " - bazel build --experimental_repository_downloader_retries=2 --disk_cache=/tmp/disk_cache - --repository_cache=/tmp/repository_cache --experimental_repository_cache_hardlinks - //examples/wasm-cc:envoy_filter_http_wasm_example.wasm - && cp -a bazel-bin/examples/wasm-cc/* /output" - entrypoint: /source/examples/shared/build/build-entrypoint.sh + command: + - bash + - -c + - | + bazel build --experimental_repository_downloader_retries=2 --disk_cache=/tmp/disk_cache \ + --repository_cache=/tmp/repository_cache --experimental_repository_cache_hardlinks \ + //:envoy_filter_http_wasm_example.wasm + cp -af bazel-bin/*.wasm /output environment: - BUILD_UID=${UID:-1000} - - TEST_TMPDIR=/tmp + user: envoybuild working_dir: /source volumes: - - ${ENVOY_DOCKER_BUILD_DIR:-/tmp/envoy-docker-build}:/tmp + - ${ENVOY_EXAMPLES_CACHE_DIR:-${HOME}/.cache/envoy/examples}:/home/envoybuild/.cache - ../..:/source - ./lib:/output diff --git a/wasm-cc/docker-compose.yaml b/wasm-cc/docker-compose.yaml index 7f2c9e7a..faa03737 100644 --- a/wasm-cc/docker-compose.yaml +++ b/wasm-cc/docker-compose.yaml @@ -11,6 +11,5 @@ services: - "8001:8001" web_service: - image: ${COMPOSE_PROJECT_NAME}-echo build: context: ../shared/echo diff --git a/wasm-cc/verify.sh b/wasm-cc/verify.sh index 9fa9bc0b..64940521 100755 --- a/wasm-cc/verify.sh +++ b/wasm-cc/verify.sh @@ -26,7 +26,7 @@ run_log "Bring down the proxy" "${DOCKER_COMPOSE[@]}" stop proxy run_log "Compile updated Wasm filter" -"${DOCKER_COMPOSE[@]}" -f docker-compose-wasm.yaml up --quiet-pull --remove-orphans wasm_compile_update +"${DOCKER_COMPOSE[@]}" -f docker-compose-wasm.yaml run --quiet-pull --remove-orphans wasm_compile_update run_log "Check for the compiled update" ls -l lib/*updated*wasm