diff --git a/Dockerfiles/Dockerfile.as b/Dockerfiles/Dockerfile.as new file mode 100644 index 0000000..e91041e --- /dev/null +++ b/Dockerfiles/Dockerfile.as @@ -0,0 +1,3 @@ +FROM docker.io/anihex/wasm4:2.1.0-base + +RUN npm install --global assemblyscript diff --git a/Dockerfiles/Dockerfile.base b/Dockerfiles/Dockerfile.base new file mode 100644 index 0000000..5d20446 --- /dev/null +++ b/Dockerfiles/Dockerfile.base @@ -0,0 +1,14 @@ +ARG WASI_VERSION=14 + +FROM docker.io/archlinux:latest + +WORKDIR /cart + +RUN pacman -Syu --noconfirm npm make \ + && \ + npm install --global wasm4 binaryen + +ENTRYPOINT [ "w4" ] +CMD [ "watch" ] + +EXPOSE 4444 diff --git a/Dockerfiles/Dockerfile.c b/Dockerfiles/Dockerfile.c new file mode 100644 index 0000000..7c85394 --- /dev/null +++ b/Dockerfiles/Dockerfile.c @@ -0,0 +1,27 @@ +ARG WASI_VERSION=14 + +FROM docker.io/anihex/wasm4:2.1.0-base AS downloader + +WORKDIR /setup + +ARG WASI_VERSION +ENV WASI_VERSION=$WASI_VERSION +ENV WASI_VERSION_FULL=${WASI_VERSION}.0 + +RUN pacman -Syu --noconfirm curl + +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz --output wasi-sdk.tar.gz && \ + tar -xf wasi-sdk.tar.gz + + + +FROM docker.io/anihex/wasm4:2.1.0-base AS final + +WORKDIR /cart + +ARG WASI_VERSION +ENV WASI_VERSION=$WASI_VERSION +ENV WASI_VERSION_FULL=${WASI_VERSION}.0 +ENV WASI_SDK_PATH=/opt/wasi-sdk + +COPY --from=downloader /setup/wasi-sdk-${WASI_VERSION_FULL} /opt/wasi-sdk diff --git a/Dockerfiles/Dockerfile.d b/Dockerfiles/Dockerfile.d new file mode 100644 index 0000000..c828664 --- /dev/null +++ b/Dockerfiles/Dockerfile.d @@ -0,0 +1,3 @@ +FROM docker.io/anihex/wasm4:2.1.0-c + +RUN pacman -Syu --noconfirm ldc dub lld \ No newline at end of file diff --git a/Dockerfile b/Dockerfiles/Dockerfile.full similarity index 100% rename from Dockerfile rename to Dockerfiles/Dockerfile.full diff --git a/Dockerfiles/Dockerfile.go b/Dockerfiles/Dockerfile.go new file mode 100644 index 0000000..8bcd8fa --- /dev/null +++ b/Dockerfiles/Dockerfile.go @@ -0,0 +1,18 @@ +FROM docker.io/archlinux:latest AS downloader + +WORKDIR /setup + +RUN pacman -Syu --noconfirm curl + +RUN curl -L https://github.com/tinygo-org/tinygo/releases/download/v0.21.0/tinygo0.21.0.linux-amd64.tar.gz --output tinygo.tar.gz && \ + tar -xf tinygo.tar.gz + + + +FROM docker.io/anihex/wasm4:2.1.0-base + +RUN pacman -Syu --noconfirm go + +COPY --from=downloader /setup/tinygo /opt/tinygo + +ENV PATH="/opt/tinygo/bin:${PATH}" diff --git a/Dockerfiles/Dockerfile.nelua b/Dockerfiles/Dockerfile.nelua new file mode 100644 index 0000000..4e2ed89 --- /dev/null +++ b/Dockerfiles/Dockerfile.nelua @@ -0,0 +1,21 @@ +FROM docker.io/archlinux:latest AS downloader + +WORKDIR /setup + +RUN pacman -Syu --noconfirm git curl base-devel gcc gdb llvm11 clang + +RUN git clone https://github.com/edubart/nelua-lang.git && \ + cd nelua-lang && \ + make + + + +# Step 3: Install and configure compilers +FROM docker.io/anihex/wasm4:2.1.0-c + +COPY --from=downloader /setup/nelua-lang/nelua /opt/nelua/nelua +COPY --from=downloader /setup/nelua-lang/nelua-lua /opt/nelua/nelua-lua +COPY --from=downloader /setup/nelua-lang/lib /opt/nelua/lib +COPY --from=downloader /setup/nelua-lang/lualib /opt/nelua/lualib + +ENV PATH="/opt/nelua:${PATH}" diff --git a/Dockerfiles/Dockerfile.nim b/Dockerfiles/Dockerfile.nim new file mode 100644 index 0000000..57ab031 --- /dev/null +++ b/Dockerfiles/Dockerfile.nim @@ -0,0 +1,3 @@ +FROM docker.io/anihex/wasm4:2.1.0-c + +RUN pacman -Syu --noconfirm nim nimble diff --git a/Dockerfiles/Dockerfile.odin b/Dockerfiles/Dockerfile.odin new file mode 100644 index 0000000..c70e54a --- /dev/null +++ b/Dockerfiles/Dockerfile.odin @@ -0,0 +1,24 @@ +FROM docker.io/archlinux:latest AS downloader + +WORKDIR /setup + +RUN pacman -Syu --noconfirm unzip + +RUN curl -L https://github.com/odin-lang/Odin/releases/download/dev-2021-12/odin-ubuntu-amd64-dev-2021-12.zip --output odin.zip && \ + unzip odin.zip && \ + mv ubuntu_artifacts odin && \ + chmod +x odin/odin + + + +FROM docker.io/anihex/wasm4:2.1.0-c + +COPY --from=downloader /setup/odin/odin /opt/odin/odin +COPY --from=downloader /setup/odin/core /opt/odin/core +COPY --from=downloader /setup/odin/shared /opt/odin/shared + +RUN pacman -Syu --noconfirm llvm11 lld \ + && \ + ln -s /usr/lib/libLLVM-11.so /usr/lib/libLLVM-11.so.1 + +ENV PATH="/opt/odin:${PATH}" diff --git a/Dockerfiles/Dockerfile.rust b/Dockerfiles/Dockerfile.rust new file mode 100644 index 0000000..93222f4 --- /dev/null +++ b/Dockerfiles/Dockerfile.rust @@ -0,0 +1,5 @@ +FROM docker.io/anihex/wasm4:2.1.0-c + +RUN pacman -Syu --noconfirm rustup \ + && \ + rustup update stable && rustup target add wasm32-unknown-unknown diff --git a/Dockerfiles/Dockerfile.zig b/Dockerfiles/Dockerfile.zig new file mode 100644 index 0000000..783c691 --- /dev/null +++ b/Dockerfiles/Dockerfile.zig @@ -0,0 +1,3 @@ +FROM docker.io/anihex/wasm4:2.1.0-c + +RUN pacman -Syu --noconfirm zig \ No newline at end of file diff --git a/README.md b/README.md index 0a9d791..602da03 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,46 @@ -# wasm4-docker +# wasm4 -Dockerfile to create a docker image than compiles AssemblyScript, C, Go, Rust and Zig +Docker image to create and develop games for the Fantasy Console [WASM-4](https://wasm4.org/). -Build by running `docker build --rm -t wasm4 .` +## Image variants: anihex/wasm4:- -Due to the size of the resulting image, it's not recommended to use this on PCs with little space. +All variants include the following tools: +- The `w4` CLI +- Binaryen (`wasm-opt` etc) -## Usage +Aside from that, there currently there are the following variants: `full`, `assemblyscript`, `c`, `d`, `go`, `nelua`, `nim`, `odin`, `rust` and `zig`. -### Creating a project +Almost all variants include the C-variant. Exceptions are `assemblyscript` and `go`. -This image comes with wasm4 in version 2.1.0. Therefore the following languages are currently supported: +Examples: +```shell +docker pull anihex/wasm4:2.1.0-full +docker pull anihex/wasm4:2.1.0-c +docker pull anihex/wasm4:latest # Implicit full-variant +docker pull anihex/wasm4:go +``` + +## Usage -- AssemblyScript (`--as or --assemblyscript`) -- C (`--c`) -- D (`--d`) -- Go (`--go`) -- Nelua (`--nelua`) -- Nim (`--nim`) -- Odin (`--odin`) -- Rust (`--rs or --rust`) -- WebAssembly Text (`--wat`) -- Zig (`--zig`) +The default command is `w4 watch`. This can be changed by overriding the command. If a completely different command is required, the entrypoint needs to be overridden. -The command to initialize a project is `w4 init ` +Examples: ```shell -docker run --rm -v $PWD:/cart wasm4 init --c +docker run --rm -v $PWD:/cart -p 4444:4444 anihex/wasm4:latest # Starts the watcher in the current directory +docker run --rm -v $PWD:/cart anihex/wasm4:latest new --c hello-c # Creates a new project called hello-c +docker run --rm -it $PWD:/cart -entrypoint bash anihex/wasm4:latest # Starts the bash-terminal ``` -To create a new subfolder, use `w4 new ` instead of `w4 init ` +## Ports -### Watching a project +The default port is 4444. For examples, look at `Usage`. -```shell -docker run --rm -v $PWD:/cart -p 4444:4444 wasm4 -``` +## Mounts + +The standard-mountpoint is `/cart`. For examples, look at `Usage`. + +## Contributing -## TODO - -- [X] Install AssemblyScript -- [X] Install C -- [X] Install D -- [X] Install Go and TinyGo -- [X] Install Nelua -- [X] Install Nim -- [X] Install Odin -- [X] Install Rust -- [ ] Install WABT -- [X] Install Zig +WASM-4 is OpenSource and is hosted on GitHub: https://github.com/aduros/wasm4
+The docker-files for this can be found on https://github.com/christopher-kleine/wasm4-docker \ No newline at end of file diff --git a/hello-wasm4/README.md b/hello-wasm4/README.md new file mode 100644 index 0000000..2866eed --- /dev/null +++ b/hello-wasm4/README.md @@ -0,0 +1,17 @@ +# Hello-WASM4 + +This folder contains two docker-compose files to test the current versions of the WASM4 docker images. + +## Usage + +```shell +# First create the projects +docker-compose -f docker-compose.create.yml up + +# Stop docker-compose and change the permissions +docker-compose -f docker-compose.create.yml down +sudo chown -R $USER: hello-* + +# Start the watch process +docker-compose -f docker-compose.watch.yml up -d +``` \ No newline at end of file diff --git a/hello-wasm4/docker-compose.create.yml b/hello-wasm4/docker-compose.create.yml new file mode 100644 index 0000000..650158e --- /dev/null +++ b/hello-wasm4/docker-compose.create.yml @@ -0,0 +1,60 @@ +services: + as: + image: anihex/wasm4:2.1.0-assemblyscript + volumes: + - ./:/cart + command: ["new", "--as", "hello-as"] + + c: + image: anihex/wasm4:2.1.0-c + volumes: + - ./:/cart + command: ["new", "--c", "hello-c"] + + d: + image: anihex/wasm4:2.1.0-d + volumes: + - ./:/cart + command: ["new", "--d", "hello-d"] + + go: + image: anihex/wasm4:2.1.0-go + volumes: + - ./:/cart + command: ["new", "--go", "hello-go"] + + nelua: + image: anihex/wasm4:2.1.0-nelua + volumes: + - ./:/cart + command: ["new", "--nelua", "hello-nelua"] + + nim: + image: anihex/wasm4:2.1.0-nim + volumes: + - ./:/cart + command: ["new", "--nim", "hello-nim"] + + odin: + image: anihex/wasm4:2.1.0-odin + volumes: + - ./:/cart + command: ["new", "--odin", "hello-odin"] + + rust: + image: anihex/wasm4:2.1.0-rust + volumes: + - ./:/cart + command: ["new", "--rust", "hello-rust"] + + # wat: + # image: anihex/wasm4:2.1.0-wat + # volumes: + # - ./:/cart + # command: ["new", "--rust", "hello-wat"] + + zig: + image: anihex/wasm4:2.1.0-zig + volumes: + - ./:/cart + command: ["new", "--zig", "hello-zig"] diff --git a/hello-wasm4/docker-compose.watch.yml b/hello-wasm4/docker-compose.watch.yml new file mode 100644 index 0000000..cbe9058 --- /dev/null +++ b/hello-wasm4/docker-compose.watch.yml @@ -0,0 +1,70 @@ +services: + as: + image: anihex/wasm4:2.1.0-assemblyscript + ports: + - 4440:4444 + volumes: + - ./hello-as:/cart + + c: + image: anihex/wasm4:2.1.0-c + ports: + - 4441:4444 + volumes: + - ./hello-c:/cart + + d: + image: anihex/wasm4:2.1.0-d + ports: + - 4442:4444 + volumes: + - ./hello-d:/cart + + go: + image: anihex/wasm4:2.1.0-go + ports: + - 4443:4444 + volumes: + - ./hello-go:/cart + + nelua: + image: anihex/wasm4:2.1.0-nelua + ports: + - 4444:4444 + volumes: + - ./hello-nelua:/cart + + nim: + image: anihex/wasm4:2.1.0-nim + ports: + - 4445:4444 + volumes: + - ./hello-nim:/cart + + odin: + image: anihex/wasm4:2.1.0-odin + ports: + - 4446:4444 + volumes: + - ./hello-odin:/cart + + rust: + image: anihex/wasm4:2.1.0-rust + ports: + - 4447:4444 + volumes: + - ./hello-rust:/cart + + # wat: + # image: anihex/wasm4:2.1.0-wat + # ports: + # - 4448:4444 + # volumes: + # - ./hello-wat:/cart + + zig: + image: anihex/wasm4:2.1.0-zig + ports: + - 4449:4444 + volumes: + - ./hello-zig:/cart