# syntax=docker/dockerfile:1 # # VTracer (visioncortex, MIT OR Apache-2.0), the raster-to-vector tracer, # compiled to WebAssembly for johnmcm.com's /image-to-svg: the project's own # wasm-bindgen core (nodejs/), built with wasm-pack for ES-module workers # with WebAssembly SIMD on. The page decodes the image itself and passes # RGBA pixels to vectorize_rgba(). The Rust image is pinned by digest, # VTracer 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 VTRACER_TAG=1.0.0-alpha.4 ARG VTRACER_COMMIT=2500df76b5aea0ac22d15296b22722442f825c5b RUN git clone -q --depth 1 --branch ${VTRACER_TAG} https://github.com/visioncortex/vtracer /vt \ && test "$(git -C /vt rev-parse HEAD)" = "${VTRACER_COMMIT}" # The lockfile from the first build, when there is one. COPY Cargo.lock* /vt/nodejs/ ENV RUSTFLAGS="-C target-feature=+simd128" WORKDIR /vt/nodejs RUN wasm-pack build --release --target web --out-name vtracer --out-dir /out/pkg RUN mkdir -p /out/dist \ && cp /out/pkg/vtracer.js /out/pkg/vtracer_bg.wasm /vt/nodejs/Cargo.lock /out/dist/ \ && cp /vt/LICENSE /out/dist/LICENSE \ && sha256sum /out/dist/* FROM scratch AS export COPY --from=build /out/dist/ /