nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.27k stars 324 forks source link

Support wasm module in actual docker image #1003

Closed sshaplygin closed 7 months ago

sshaplygin commented 8 months ago

Hey, everyone!

I pulled default unit image from docker hub and tried usage wasm module with exec command:

docker exec -ti web curl -X PUT -d '{"helloworld": {"type":"wasm","module":"/www/helloworld/main.wasm"}}' --unix-socket  \
       /var/run/control.unit.sock http://localhost/config/applications

I had next error:

{
        "error": "Invalid configuration.",
        "detail": "The module to run \"wasm\" is not found among the available application modules."
}

Default image doesn't have wasm module?

my env:

os: macos
arch: arm64
docker version: Docker version 24.0.6, build ed223bc
image: 
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
648c40d7602f   10 days ago   /bin/sh -c #(nop)  CMD ["unitd" "--no-daemon…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  EXPOSE 80                    0B        
<missing>      10 days ago   /bin/sh -c #(nop)  ENTRYPOINT ["/usr/local/b…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  STOPSIGNAL SIGTERM           0B        
<missing>      10 days ago   /bin/sh -c #(nop) COPY multi:44b909b4ee0b15a…   3.62kB    
<missing>      10 days ago   /bin/sh -c #(nop) COPY file:8b65557c2137d1a3…   3.96kB    
<missing>      10 days ago   /bin/sh -c set -ex     && savedAptMark="$(ap…   24.2MB    
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B        
<missing>      10 days ago   /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      10 days ago   /bin/sh -c #(nop) ADD file:99dc83e8bb8c67d91…   74.4MB       
tippexs commented 8 months ago

Thanks for reaching out!

Currenlty we are working on two different wasm-modules. The one that makes use of our own SDK can be pulled by issuning

docker pull unit:wasm see https://hub.docker.com/_/unit

The other module is based on Rust and supports the Wasm Component Model and can be used with wasm-wasi-http. This can be pulled issuing docker pull nginx/unit-preview:wasm-wasi-http

To learn more about how to use is see this README

sshaplygin commented 7 months ago

thank you