-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathBUILD.bazel
55 lines (48 loc) · 1.3 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
load("@aspect_bazel_lib//lib:tar.bzl", "tar")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
load("@rules_rust//rust:defs.bzl", "rust_binary")
package(default_visibility = ["//visibility:public"])
rust_binary(
name = "binary",
srcs = ["main.rs"],
edition = "2018",
)
platform_transition_filegroup(
name = "wasi_binary",
srcs = ["binary"],
target_platform = "@rules_rust//rust/platform:wasi",
)
tar(
name = "wasi_layer",
srcs = ["wasi_binary"],
)
oci_image(
name = "image",
annotations = {
"module.wasm.image/variant": "compat",
"run.oci.handler": "wasm",
},
architecture = "wasm32",
cmd = ["/binary.wasm"],
os = "wasi",
tars = [
":wasi_layer",
],
)
build_test(
name = "build_test",
targets = [
":image",
],
)
# In order to run the image you need to follow instructions at https://docs.docker.com/desktop/wasm/ first.
# then run the following;
# `bazel run :tarball``
# `docker run --runtime=io.containerd.wasmedge.v1 --platform=wasi/wasm32 --pull=never gcr.io/wasm:latest`
oci_load(
name = "tarball",
image = ":image",
repo_tags = ["gcr.io/wasm:latest"],
)