https://github.com/albertoimpl/wasm-docker-hello
https://github.com/albertoimpl/wasm-docker-hello
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/albertoimpl/wasm-docker-hello
- Owner: Albertoimpl
- Created: 2022-10-26T13:46:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T12:16:22.000Z (about 3 years ago)
- Last Synced: 2025-03-17T11:50:53.785Z (11 months ago)
- Language: Dockerfile
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker and WASM
Testing https://docs.docker.com/desktop/wasm/
## Install WASI SDK
https://github.com/WebAssembly/wasi-sdk
```shell
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-macos.tar.gz
tar xvf wasi-sdk-16.0-macos.tar.gz
```
## Creating a WASM module using WASI SDK
```shell
export WASI_SDK_PATH=`pwd`/wasi-sdk-16.0
CC="${WASI_SDK_PATH}/bin/clang"
$CC hello-world.c -o hello-world.wasm
```
## Building a docker image
https://github.com/docker/docs/blob/main/desktop/wasm/index.md
```shell
docker buildx build . --file=Dockerfile --tag=albertoimpl/hello-wasm-docker --platform wasi/wasm32
```
Just 9.65kB!
```shell
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
albertoimpl/hello-wasm-docker latest 22617e0cb703 8 days ago 9.65kB
hello-world latest e18f0a777aef 8 days ago 7.04kB
```
## Running the docker image
```shell
docker run --runtime=io.containerd.wasmedge.v1 --platform=wasi/wasm32 albertoimpl/hello-wasm-docker
```
As fast as a docker hello world:
```asciidoc
time docker run hello-world
0.07s user 0.04s system 17% cpu 0.584 total
time docker run --runtime=io.containerd.wasmedge.v1 --platform=wasi/wasm32 albertoimpl/hello-wasm-docker
0.07s user 0.03s system 18% cpu 0.548 total
```