# syntax=docker/dockerfile:1 # # MathCAT (DAISY Consortium / Neil Soiffer, MIT), which turns MathML into # speech and braille, compiled to WebAssembly for johnmcm.com's Equation # Editor (Accessibility tab: Nemeth and UEB braille). A tiny wasm-bindgen # wrapper (src/lib.rs) exposes braille(mathml, code) and version(). MathCAT's # Rules directory is embedded in the .wasm as a zip (its include-zip feature), # limited to the English rules and the Nemeth and UEB braille rules. # The Rust image is pinned by digest, MathCAT by tag and commit, the crates by # Cargo.lock (generated by the first build and kept here). # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . ARG RUST_IMAGE=rust:1.89-bookworm@sha256:948f9b08a66e7fe01b03a98ef1c7568292e07ec2e4fe90d88c07bb14563c84ff FROM ${RUST_IMAGE} AS build RUN rustup target add wasm32-unknown-unknown \ && cargo install --locked wasm-pack --version 0.13.1 ARG MATHCAT_TAG=v0.7.7 ARG MATHCAT_COMMIT=764d24d1241b20c0973e9dbcee62d022c1f99a4a RUN git clone -q --depth 1 --branch ${MATHCAT_TAG} https://github.com/daisy/MathCAT /mathcat \ && test "$(git -C /mathcat rev-parse HEAD)" = "${MATHCAT_COMMIT}" WORKDIR /wrap COPY Cargo.toml ./ COPY Cargo.lock* ./ COPY src ./src COPY stub ./stub COPY notices.sh ./ RUN wasm-pack build --release --target web --out-name mathcat --out-dir /out/pkg RUN mkdir -p /out/dist \ && cp /out/pkg/mathcat.js /out/pkg/mathcat_bg.wasm /wrap/Cargo.lock /out/dist/ \ && cp /mathcat/LICENSE /out/dist/LICENSE \ && sh /wrap/notices.sh > /out/dist/THIRD-PARTY.txt \ && sha256sum /out/dist/* FROM scratch AS export COPY --from=build /out/dist/ /