Skip to content

Docker environment for compiling Rust into WebAssembly (wasm).

Notifications You must be signed in to change notification settings

pjama/rust-wasm-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust -> WebAssembly -> Docker (Ubuntu)

A controlled Ubuntu environment (Docker) for compiling Rust in to WebAssembly.

Installation

docker build -t ubuntu-wasm docker/

Getting Started

In your host machine, run the Docker container.

docker run -it -v $PWD/:/var/workspace -p 8081:8081 ubuntu-wasm /bin/bash

(Mounts the present working directory to /var/workspace/ and runs bash.)

Compile Rust code within the Docker container:

rustc +nightly --target wasm32-unknown-unknown -O \
               --crate-type=cdylib src/main.rs \
               -o build/main.big.wasm

wasm-gc build/main.big.wasm build/main.wasm

Running the Docker Container

The Docker container runs a local HTTP server to host the local contents,

docker run -p 8081:8081 -v $PWD/:/var/workspace ubuntu-wasm

In a browser, http://localhost:8081.

About

Docker environment for compiling Rust into WebAssembly (wasm).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published