Sign inSign up

wasm/toolchain

By wasm

Updated about 8 years ago

Ridiculously large (2GB) image with gcc, clang, rust, and emsdk for building WebAssembly modules

Image
4

1.2K

wasm/toolchain repository overview

WASM Toolchain built on top of Ubuntu

This (hopefully) gives you everything you need to compile WebAssembly modules written in C, Rust, or Emscripten (WAT). Some additional Ubuntu apt packages are installed to satisfy build requirements. This image compressed comes to 2GB, but with its base layers the total on disk is 4.69GB. Compiling this yourself will use less bandwidth but can take several hours. Feedback? Discuss: https://keybase.io/team/webassembly

To use, docker run -it --rm -v .:/project wasm/toolchain:latest /bin/bash --login or something similar, where:

  • docker run spins up the container from the image
  • -it specifies that you want an interactive TTY
  • --rm tells it to remove this temporary image when it exits
  • -v . mounts a volume on this directory and :/project makes a project directory within the container mapped to it
  • /bin/bash --login tells the container to run a login bash shell inside the container

This should drop you in to the container with access to your files (you did run this command from within your wasm project folder's root directory, yes?) where you can cd /project and then rustc myfile.rs or whatever you feel compelled to do at that point. :)

Dockerfile

Successful build achieved with this Dockerfile Sunday, July 15, 2018:

# vim:set ft=dockerfile:
FROM ubuntu:latest
RUN set -x \
    && apt-get update \
    && apt-get upgrade -y \
    && apt-get dist-upgrade -y \
    && apt-get autoclean \
    && apt-get autoremove \
    && apt-get install bash python2.7 nodejs cmake curl git gcc clang default-jre -y
SHELL ["/bin/bash", "-c"]
RUN set -x \
    && git clone https://github.com/juj/emsdk.git \
    && cd emsdk \
    && ./emsdk install --build=Release sdk-incoming-64bit binaryen-master-64bit \
    && ./emsdk activate --build=Release sdk-incoming-64bit binaryen-master-64bit \
    && . ./emsdk_env.sh --build=Release \
    && curl https://sh.rustup.rs -sSf -o rustup.rs.sh \
    && /bin/sh ./rustup.rs.sh -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN set -x \
    && rustup update \
    && rustup install nightly \
    && rustup target add wasm32-unknown-unknown --toolchain nightly
RUN set -x \
    && cargo +nightly install wasm-bindgen-cli

# References
# EMSDK https://webassembly.org/getting-started/developers-guide/
# https://rustwasm.github.io/book/game-of-life/setup.html#setup

Special note for Windows users:

.:/project probably won't work for you. Specify a full path to the folder on your drive, e.g.: docker run -it --rm -v C:\Users\David\MyWasmProjectExample:/project wasm/toolchain:latest /bin/bash --login

Sharing Drives

If you get an error that your drive is not shared, open Docker's settings and add the drive you're attempting to share under the "Shared Drives" settings.

(Example Windows Drive Sharing Error:

See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.```)

See also: https://hub.docker.com/r/webassembly/toolchain/ which is the same but has a slightly longer name and a :dx tag that includes emacs, screen, zsh, htop, etc.

Unofficial build by @DavidCanHelp

Tag summary

Content type

Image

Digest

Size

2.1 GB

Last updated

about 8 years ago

docker pull wasm/toolchain