diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4f72f9d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git/ +target/ +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec1911a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# This is a simple, stand-alone server image for hosting the WASM file. +# It is not intended to integrate with other webpages, webservers, or sites +# on an existing server. For that, you must patch the code yourself. +FROM rust AS builder + +# Install build tools +RUN rustup target add wasm32-unknown-unknown +RUN cargo install --locked wasm-bindgen-cli + +# Build the program + +# Copy in only the Rust source so the builder doesn't discard any cached build +# layers just because the README changed. +COPY src/ src/ +COPY Cargo.toml Cargo.toml +COPY Cargo.lock Cargo.lock +COPY .cargo .cargo + +RUN cargo build --locked --target wasm32-unknown-unknown --release +RUN wasm-bindgen \ + --no-typescript \ + --target web \ + --out-dir out/ \ + --out-name "chaos-game-rs" \ + target/wasm32-unknown-unknown/release/chaos-game-rs.wasm + + +# Copy WASM & JS to a new image for use +FROM busybox:musl +RUN mkdir -p /var/www +COPY --from=builder out/ /var/www +COPY index.html /var/www/index.html + +WORKDIR /var/www + +EXPOSE 8080/tcp + +CMD ["httpd", "-f"]