ktock / container2wasm

Container to WASM converter

Home Page:https://ktock.github.io/container2wasm-demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instructions for hosting locally (from a directory)

pmmccorm opened this issue · comments

Hello I think it would be very useful to post how to host the containers locally (from a directory, ie file://...).

Without all the docker running httpd stuff.

Is this possible?

Our example currently requires HTTP headers for using SharedArrayBuffer https://github.com/ktock/container2wasm/blob/b3e4d9253eb710ddebc2962494964477d2458e44/examples/wasi-browser/xterm-pty.conf If we can avoid using that, loading pages from local file will be possible.

Something like this might be helpful. I don't know how well it would work from a file url but it does work well with stuff like Github Pages.

Ah I think that is what I am looking for. Thank you. Maybe an example that can be hosted from GH pages?

It seems close but I get a strange error.

See: https://pmmccorm.github.io/container_on_browser/index.html

Error:
image

Which might be this bit from worker.js:

function startWasi(wasm, ttyClient, args, env, fds, listenfd, connfd) {
    var wasi = new WASI(args, env, fds);
    wasiHack(wasi, ttyClient, connfd);
    wasiHackSocket(wasi, listenfd, connfd);
    WebAssembly.instantiate(wasm, {
        "wasi_snapshot_preview1": wasi.wasiImport,
    }).then((inst) => {
        wasi.start(inst.instance);
    });
}

Could you check you specified the correct URL for the wasm file in your script?

You mean the out.wasm?

Aha! That did it. When I host on github pages it appears that:

location.origin

Is pointing to the top domain, but it needs to go to: location.origin + /gh_repo_name/