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

proposal: "spin buildx" plugin #2926

Open
rajatjindal opened this issue Nov 15, 2024 · 1 comment
Open

proposal: "spin buildx" plugin #2926

rajatjindal opened this issue Nov 15, 2024 · 1 comment

Comments

@rajatjindal
Copy link
Collaborator

rajatjindal commented Nov 15, 2024

I wrote a plugin spin terminal (https://github.com/rajatjindal/spin-plugin-terminal) based on dagger, which provides a container shell with the required toolchains.

As i played around with that concept more, I thought what would be really cool is to have something like spin buildx, which reads the toolchain requirement for a specific spin app (in a .toolchains file), spins up a container with the required toolchain, run spin build and export the build artifacts back to host system.

I did a small poc of that and it seems to have worked for simple cases I tried:

$ spin new -t http-rust http-rust-buildx --accept-defaults

$ cd http-rust-buildx 

$ cat >> .toolchains<< EOF                                       
rust=1.82.0
spin=3.1.0
EOF

$ ls ./target/wasm32-wasi/release/deps/http_rust_buildx.wasm
ls: ./target/wasm32-wasi/release/deps/http_rust_buildx.wasm: No such file or directory

$ ../spin-terminal/buildx
✔ connect 0.2s
✔ loading module 0.7s
✔ parsing command line arguments 11.2s
✔ wasi: Wasi! 0.7s
✔ Wasi.build(
    source: ✔ ModuleSource.resolveDirectoryFromCaller(path: "."): Directory! 0.0s
  ): Directory! 1m24.0s
✔ Directory.export(path: "."): String! 2.4s

Full trace at https://dagger.cloud/rajatjindal/traces/4378964d0128b39a071bdd0bb8fe4993

/Users/rajatjindal/go/src/github.com/rajatjindal/http-rust-buildx
closed the terminal succcessfully

$ ls ./target/wasm32-wasi/release/deps/http_rust_buildx.wasm
./target/wasm32-wasi/release/deps/http_rust_buildx.wasm

if we include this toolchains file in examples/templates (or as a spin.toml entry as suggested by @itowlson), then using this plugin will significantly reduce friction for new users. e.g. while for rust, the toolchain requirement is simple, but for golang, we need golang, tinygo and wasm-tools and then installing specific versions of that, all that can be simplified.

Please let me know your thoughts.

@itowlson
Copy link
Contributor

itowlson commented Nov 19, 2024

I'd be keen to see this, although I'm not sure how I feel about including support for particular plugins in templates. That feels like a discussion we should have, though, as a broader thing: it's not invasive, and it would save users of relevant plugins having to copy incantations themselves. (And give the plugins themselves an It Just Works quality!)

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

No branches or pull requests

2 participants