leaningtech/webvm

Custom image (busybox) usage trouble

tarampampam opened this issue · 7 comments

Hello there, and thanks for the awesome project!

I believe you can assist me in addressing the issue that arose during the custom image building process. Currently, I am utilizing the following script to generate the image:

#!/usr/bin/env sh
# reference: https://github.com/leaningtech/webvm/blob/e351ccdfa52c0e11580db90f4369c8691ef79c27/.github/workflows/deploy.yml

set -xe

# build the image
docker build --file ./Dockerfile --tag disk:local --platform=i386 .

# preallocate space for the ext2 image
fallocate -l 6M ./disk.ext2

# format to ext2 linux kernel revision 0
mkfs.ext2 -F -r 0 ./disk.ext2

# create a directory for the fs
mkdir ./mnt

# mount the ext2 image to modify it
sudo mount -o loop -t ext2 ./disk.ext2 ./mnt

# run the docker image so that we can export the container
CONTAINER_ID=$(docker run -d --dns 1.1.1.1 --dns 1.0.0.1 disk:local sleep 5m)

# copy image content
sudo docker cp -a $CONTAINER_ID:/ ./mnt/

# unmount & cleanup
docker kill $CONTAINER_ID
docker rmi -f disk:local
sudo umount ./mnt
sudo rm -Rf ./mnt
# syntax=docker/dockerfile:1
FROM --platform=i386 docker.io/i386/busybox:1.35

However, when attempting to use this image on the JavaScript side, the console displays the following error:

image

image

When I switch the image to https://disks.webvm.io/debian_large_20230522_5044875331.ext2, everything works fine. Therefore, I believe the issue lies with the image itself, correct?

Version: https://cheerpxdemos.leaningtech.com/publicdeploy/20230818_119/cx.js

P.S. I use the CloudFlare pages as a hosting

The block backend can only be used with our own image servers. For self deployment scenarios you need to use the bytes backend.

For further support consider joining our Discord: https://discord.gg/yTNZgySKGa

Could you link docs with API details?

We are in the processing of expanding the docs, but this should really be all you need:

https://github.com/leaningtech/webvm#local-deployment

After switching on the bytes it still does not work :(

image

image

Please use the network tab to make sure your web server is finding the image file and the Content-Range header is properly added.

Thanks for your answer! Is there any way to use as a device source something like Uint8Array? I mean in case I have a prefetched image - can I pass the image data directly to the .create()?

No, this latter use case is not supported. The block device infrastructure is designed for very large images which cannot be preloaded anyway.

In our view if a small image is needed the bytes backend will be sufficient anyway.

Please close this bug if the original issue is fixed and join the Discord for further help.