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

Allow to load a wasm file from a remote registry #121

Open
k33g opened this issue Apr 18, 2023 · 6 comments
Open

Allow to load a wasm file from a remote registry #121

k33g opened this issue Apr 18, 2023 · 6 comments

Comments

@k33g
Copy link

k33g commented Apr 18, 2023

Is your feature request related to a problem? Please describe.

I publish my wasm plugin on wapm.io or a GitLab Generic Package registry. At the start of wws I would like to be able to set an option or an environment variable with the URL of the wasm module to download the module and then start/serve it.

Describe the solution you'd like

wws \ 
--remote-location https://gitlab.com/api/v4/projects/${PROJECT_ID}/packages/generic/${PACKAGE}/${VERSION}/${MODULE}" \
--save-to ./hello

Describe alternatives you've considered

No response

Additional context

No response

@Angelmmiguel
Copy link
Contributor

Hello @k33g!

Thank you for the issue and the suggestion 😄. To understand better the issue and solution, are those public registries exposing these resources following any specification like OCI? Are they just exposing the resources as files?

In the example, the download filename is hello. Wasm Workers Server relies on the file extension to identify the language runtime. Is the extension missed from the example or something related to the registries?

Thanks!

@k33g
Copy link
Author

k33g commented Apr 25, 2023

@Angelmmiguel
Sorry I missed some details, in this case I would say ./hello would be a directory

I used the GitLab generic package registry so it's more exposing resources as files, but OCI would be nice too

@Angelmmiguel
Copy link
Contributor

Thanks for the clarification! Yes, I agree it would be interesting support multiple remote artifacts. It reminds me how some JavaScript runtimes like Deno supports running remote scripts:

$ deno run https://deno.land/std/examples/welcome.ts
Welcome to Deno!

I would make these resources as valid paths for wws like:

wws https://example.com/index.js
wws oci://...

The protocol will determine how to handle it. I may need to give a thought about how to distinguish between scripts and compressed resources. The extension could be enough, although I'm thinking if auto-decompression may cause other kind of issues.

@Angelmmiguel
Copy link
Contributor

Angelmmiguel commented May 31, 2023

Hey @k33g!

I plan to start working on this issue and add support for git repositories. I will add support for other protocols / URLs after that 😄

@k33g
Copy link
Author

k33g commented May 31, 2023

@Angelmmiguel, that's excellent news 🤩

@Angelmmiguel
Copy link
Contributor

Angelmmiguel commented Jun 6, 2023

@k33g I just merged the changes to run a wws from a remote repository. It's not released yet, but you can already try it in the preview container we build from the main branch 😄.

There are new options for git repositories:

docker run --rm -p 8080:8080 ghcr.io/vmware-labs/wws:preview /wws --help
A WebAssembly framework to develop and run serverless applications anywhere

Usage: wws [OPTIONS] [PATH] [COMMAND]

Commands:
  runtimes  Manage the language runtimes in your project
  help      Print this message or the help of the given subcommand(s)

Arguments:
  [PATH]  Location of the wws project. It could be a local folder or a git repository [default: .]

Options:
      --host <HOSTNAME>          Hostname to initiate the server [default: 127.0.0.1]
  -p, --port <PORT>              Port to initiate the server [default: 8080]
      --prefix <PREFIX>          Prepend the given path to all URLs [default: ]
      --ignore <IGNORE>          Patterns to ignore when looking for worker files [default: ]
  -i, --install-runtimes         Install missing runtimes automatically
      --git-commit <GIT_COMMIT>  Set the commit when using a git repository as project
      --git-tag <GIT_TAG>        Set the tag when using a git repository as project
      --git-branch <GIT_BRANCH>  Set the branch when using a git repository as project
      --git-folder <GIT_FOLDER>  Change the directory when using a git repository as project
  -h, --help                     Print help
  -V, --version                  Print version

And you can now run the examples from this repo directly:

$ docker run --rm -p 8080:8080 ghcr.io/vmware-labs/wws:preview \
  /wws https://github.com/vmware-labs/wasm-workers-server.git \
  --host=0.0.0.0 --git-folder=examples/js-basic --install-runtimes

⚙️  Preparing the project from: https://github.com/vmware-labs/wasm-workers-server.git
⚙️  Loading routes from: /tmp/dd21e3cd6d0f515301e1c7070e562af06074d9e8d10566179f97dba47e74cec9/examples/js-basic
⏳ Loading workers from 1 routes...
✅ Workers loaded in 405.54775ms.
    - http://0.0.0.0:8080/
      => /tmp/dd21e3cd6d0f515301e1c7070e562af06074d9e8d10566179f97dba47e74cec9/examples/js-basic/index.js
🚀 Start serving requests at http://0.0.0.0:8080

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