# syntax=docker/dockerfile:1 # # Google's woff2 library with brotli, compiled to WebAssembly for # johnmcm.com's /font-converter (and WOFF2 opening in /font-inspector). Both # are MIT. The Emscripten image is pinned by version and digest, both # libraries by commit (see README.md). # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . ARG EMSDK_IMAGE=emscripten/emsdk:6.0.10@sha256:e077d54e2b8970575ebc4f185ac1de0b95c05f2b266134d4ba27449af7aebf65 FROM ${EMSDK_IMAGE} AS build ARG WOFF2_COMMIT=fb9c3379f2605b10f3e8f1d9636664ab5576775c # brotli v1.2.0 ARG BROTLI_COMMIT=028fb5a23661f123017c060daa546b55cf4bde29 RUN git clone -q https://github.com/google/woff2 /woff2 \ && git -C /woff2 checkout -q ${WOFF2_COMMIT} \ && test "$(git -C /woff2 rev-parse HEAD)" = "${WOFF2_COMMIT}" \ && git clone -q https://github.com/google/brotli /brotli \ && git -C /brotli checkout -q ${BROTLI_COMMIT} \ && test "$(git -C /brotli rev-parse HEAD)" = "${BROTLI_COMMIT}" WORKDIR /build COPY src/wrapper.cpp . RUN mkdir -p /out \ && W="font glyph normalize table_tags transform variable_length woff2_common woff2_dec woff2_enc woff2_out" \ && SRCS="wrapper.cpp $(for f in $W; do echo /woff2/src/$f.cc; done) $(ls /brotli/c/common/*.c /brotli/c/dec/*.c /brotli/c/enc/*.c)" \ && em++ -O3 -fno-exceptions -I/woff2/include -I/brotli/c/include $SRCS -o /out/woff2.mjs \ -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createWoff2 \ -sENVIRONMENT=web,worker,node \ -sALLOW_MEMORY_GROWTH=1 \ -sMAXIMUM_MEMORY=1073741824 \ -sFILESYSTEM=0 \ -sDYNAMIC_EXECUTION=0 \ -sINCOMING_MODULE_JS_API=print,printErr,locateFile \ -sEXPORTED_FUNCTIONS=_w2_alloc,_w2_free,_w2_decode,_w2_decoded,_w2_max_encoded_size,_w2_encode \ -sEXPORTED_RUNTIME_METHODS=HEAPU8,HEAPU32 FROM scratch AS export COPY --from=build /out/ /