Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support --platform=wasip1/wasm #1095

Closed
wants to merge 1 commit into from
Closed

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Jul 14, 2023

In order to use this, you need:

go run ./ build ./test --platform wasip1/wasm

When run this way, instead of producing /ko-app/test, it produces /ko-app/test.wasm on top of an empty base image.

You can run this image with:

docker run \                                         
  --runtime=io.containerd.wasmedge.v1 \
  --platform=wasip1/wasm \
  ${IMAGE}

Or, all together in one big blob:

$ docker run \                                         
  --runtime=io.containerd.wasmedge.v1 \
  --platform=wasip1/wasm \
  $(KO_DOCKER_REPO=ttl.sh/jason KO_GO_PATH=go1.21rc2 go run ./ build ./test --platform wasip1/wasm) --wait=false
...
Unable to find image 'ttl.sh/jason/test-46c4b272b3716c422d5ff6dfc7547fa9@sha256:a0c4ec41385b5739a22e2557d374298938dea07385d6cf4c1d2e09931df7c7de' locally
a0c4ec41385b: Download complete 
d37e65aa4221: Download complete 
3827f8e0b338: Download complete 
2023/07/14 00:22:01 version = default
2023/07/14 00:22:01 Hello, adventurous wasm user!

Known issues:

  • go version -m test.wasm doesn't work, so the SBOM is empty
  • --platform=linux/amd64,wasip1/wasm doesn't work, and it's unclear if anything could run it anyway

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Merging #1095 (278c337) into main (77c116b) will decrease coverage by 0.26%.
The diff coverage is 0.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main    #1095      +/-   ##
==========================================
- Coverage   49.23%   48.97%   -0.26%     
==========================================
  Files          44       44              
  Lines        3650     3669      +19     
==========================================
  Hits         1797     1797              
- Misses       1621     1639      +18     
- Partials      232      233       +1     
Files Changed Coverage Δ
pkg/build/gobuild.go 56.06% <0.00%> (-1.23%) ⬇️

@imjasonh
Copy link
Member Author

Spin

$ docker run \
  --runtime=io.containerd.spin.v1 \    
  --platform=wasip1/wasm \
  ${IMAGE} --wait=false
...
docker: Error response from daemon: Cannot read spin.toml manifest from "/var/run/desktop-containerd/daemon/io.containerd.runtime.v2.task/moby/1560897a091b6698b942f477ac782110df9c31364ea8d6733ddfd937ade3b6ce/rootfs/spin.toml": unknown.
ERRO[0000] error waiting for container: context canceled 

💥

Slight

$ docker run \
  --runtime=io.containerd.spin.v1 \    
  --platform=wasip1/wasm \
  ${IMAGE} --wait=false

(no output 😶 )

Wasmtime

$ docker run \
  --runtime=io.containerd.wasmtime.v1 \    
  --platform=wasip1/wasm \
  ${IMAGE} --wait=false
2023/07/14 00:42:10 version = default
2023/07/14 00:42:10 Hello, adventurous wasm user!

🎉

@shivaylamba
Copy link

This is really awesome work!

@sonatard
Copy link

Great!! This wasm image can run on Cloud run?

@imjasonh
Copy link
Member Author

Great!! This wasm image can run on Cloud run?

I don't believe so, at least not yet.

Luckily Cloud Run has great support for regular containers, so I don't think there's any real benefit to using wasm.

@BobyMCbobs
Copy link

This'd be pretty awesome for building wasm to use with Istio+Envoy!
I can see a powerful use case there to speed up development.

@imjasonh
Copy link
Member Author

This'd be pretty awesome for building wasm to use with Istio+Envoy!
I can see a powerful use case there to speed up development.

Yeah that sounds like a good use case. Do you have any docs about the current development process, that I could try to replicate with this change?

@BobyMCbobs
Copy link

This'd be pretty awesome for building wasm to use with Istio+Envoy!
I can see a powerful use case there to speed up development.

Yeah that sounds like a good use case. Do you have any docs about the current development process, that I could try to replicate with this change?

This is how I've built WASM for use with Envoy
https://github.com/ii/registry.k8s.io/tree/master/envoy-wasm

for putting together an Envoy-compatible WASM public, I've used this package
https://github.com/tetratelabs/proxy-wasm-go-sdk
then once it's built and pushed as an OCI image, it can be picked up here
https://istio.io/latest/docs/reference/config/proxy_extensions/wasm-plugin/

Let me know if I can help in any way

not as useful but for C++ https://github.com/istio-ecosystem/wasm-extensions

@imjasonh imjasonh changed the title WIP: support --platform=wasip1/wasm support --platform=wasip1/wasm Aug 8, 2023
@imjasonh imjasonh marked this pull request as ready for review August 8, 2023 19:44
@imjasonh imjasonh enabled auto-merge (squash) August 8, 2023 19:45
Copy link

github-actions bot commented Nov 8, 2023

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

@github-actions github-actions bot closed this Dec 8, 2023
auto-merge was automatically disabled December 8, 2023 01:25

Pull request was closed

@BobyMCbobs
Copy link

@imjasonh, thank you for the efforts so far. Is there any plan to eventually get this PR merged? Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants