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

no-conversion without imagemounter #306

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

samyfodil
Copy link

Using imagemounter, which works great for browsers, comes with some unnecessary overhead. This is an alternative solution that bypasses the network and uses the built-in WASI capability to map folders. WASI filesystem does not have permissions. To overcome this, we export the container rootfs as a SquashFS image.

Goal:

wazero run --mount /tmp/riscv-python:/ext/bundle riscv64-squash.wasm python

Or,

wazero run --mount /tmp/riscv-python:/some/folder riscv64-squash.wasm --external-bundle /some/folder python

Copy link
Owner

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

nit: could you rebase the commit on the latest main to pass CI.

Dockerfile Outdated
RUN apt-get update -y && apt-get install -y mkisofs
RUN apt-get update -y && apt-get install -y squashfs-tools
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashfs comes with some overhead, right?. Can we default to isofs and enable squashfs only for d2oci usage?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. It adds a bit of overhead but cut's the size of the image by about half. I'll add a built option

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added iso back. Added erofs (faster as it aligns data).

Comment on lines +1 to +2
package main

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we implement this to c2w and enable this using a flag like --to-squashfs?


} else {
if info.bundle != "" {
if info.bundle[0] != '/' {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use filepath.IsAbs https://pkg.go.dev/path/filepath#IsAbs ?


# Run the Container
```console
wazero run --mount /tmp/riscv-python:/ext/bundle riscv64-squash.wasm python
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add docs about /ext/bundle? Or, this path should be configurable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's configurable. I'll add clarifications to readme.

@ktock ktock added this to the v0.7.0 milestone Aug 28, 2024
@ktock
Copy link
Owner

ktock commented Aug 28, 2024

Please fix linter errors as well.

https://github.com/ktock/container2wasm/actions/runs/10580983966/job/29343917175?pr=306#step:3:33

   cmd/d2oci/main.go:93:10: Error return value of `os.Mkdir` is not checked (errcheck)
  	os.Mkdir(dstImgPath, 0750)
  	        ^
  cmd/d2oci/main.go:98:10: Error return value of `os.Mkdir` is not checked (errcheck)
  	os.Mkdir(dstImgPath+"/rootfs", 0750)
  	        ^
  cmd/d2oci/main.go:171:10: Error return value of `os.Mkdir` is not checked (errcheck)
  	os.Mkdir(path.Join(dstImgPath, "config"), 0755)
  	        ^
  cmd/d2oci/main.go:294:25: printf: fmt.Errorf call has arguments but no formatting directives (govet)
  		return nil, fmt.Errorf("Failed to unpack the image as an OCI image:", err)

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

Successfully merging this pull request may close these issues.

2 participants