FROM emscripten/emsdk:3.1.64@sha256:8847dad4171ebc8a53d9ae5cda86a2546ef5b2e68834c14dc1ba2b2962e125cc
WORKDIR /src
ADD tensorflow-v2.18.0.tar.gz /src/
COPY CMakeLists.txt iris_runtime.cc /bridge/
RUN cmake -S /src/tensorflow-2.18.0/tensorflow/lite/tools/cmake/native_tools/flatbuffers -B /host-tools -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/host -DOVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL=ON && cmake --build /host-tools -j 4 && cmake --install /host-tools
RUN --mount=type=cache,target=/build emcmake cmake -S /bridge -B /build -DTFLITE_HOST_TOOLS_DIR=/host/bin -DOVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -DEIGEN_MPL2_ONLY" && cmake --build /build --target iris_runtime -j 4 && mkdir -p /artifacts && cp /build/iris_runtime.mjs /build/iris_runtime.wasm /artifacts/ && tar -czf /artifacts/eigen-source-with-buildpatches.tar.gz -C /build eigen
COPY collect_notices.py /bridge/collect_notices.py
RUN --mount=type=cache,target=/build python3 /bridge/collect_notices.py
