<commit_before>ARG BASE_IMAGE=dockcross/web-wasm
FROM $BASE_IMAGE:20211015-2b6cd4a
ARG BASE_IMAGE

LABEL maintainer="<NAME> <<EMAIL>>"
LABEL org.opencontainers.image.source="https://github.com/InsightSoftwareConsortium/itk-js"

WORKDIR /

# 2021-10-03 master branch
ENV ITK_GIT_TAG 3b68b2092bc2db2978a1ed68efe5ec38fcade185
RUN git clone https://github.com/thewtex/ITK.git && \
  cd ITK && \
  git checkout ${ITK_GIT_TAG} && \
  cd ../ && \
  sed -i -e '/^option(OPJ_USE_THREAD/c\option(OPJ_USE_THREAD "use threads" OFF)' \
    /ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt
ARG CMAKE_BUILD_TYPE=Release

# For SlicerExecutionModel
RUN mkdir ITK-Native-build && \
  cd ITK-Native-build && \
  /usr/bin/cmake \
    -G Ninja \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_LEGACY_REMOVE:BOOL=ON \
    -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF \
    -DITKGroup_Core:BOOL=ON \
    -DModule_ITKCommon:BOOL=ON \
    -DModule_ITKIOXML:BOOL=ON \
    -DModule_ITKExpat:BOOL=ON \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_CXX_COMPILER=/usr/bin/c++ \
    -DCMAKE_TOOLCHAIN_FILE="" \
    ../ITK && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd ..

ENV SlicerExecutionModel_GIT_TAG dbc39c049b3721c5f3ea80f20acd32e3c8cc65f3
RUN git clone https://github.com/thewtex/SlicerExecutionModel.git && \
  cd SlicerExecutionModel && \
  git checkout ${SlicerExecutionModel_GIT_TAG} && \
  cd ../ && \
  mkdir SlicerExecutionModel-build && \
  cd SlicerExecutionModel-build && \
  /usr/bin/cmake \
    -G Ninja \
    -DSlicerExecutionModel_USE_JSONCPP:BOOL=OFF \
    -DCMAKE_BUILD_TYPE:STRING=$CMAKE_BUILD_TYPE \
    -DBUILD_SHARED_LIBS:BOOL=OFF \
    -DCMAKE_INSTALL_PREFIX:PATH=/install-prefix \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_DIR:PATH=/ITK-Native-build \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_CXX_COMPILER=/usr/bin/c++ \
    -DCMAKE_TOOLCHAIN_FILE="" \
    ../SlicerExecutionModel && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd .. && chmod -R 777 SlicerExecutionModel-build

# After the WASI exception / setjmp support may work? setjmp is lost in final
# linking otherwise.
#ENV LDFLAGS="-flto -s ALLOW_MEMORY_GROWTH=1"
#ENV CFLAGS="-Wno-warn-absolute-paths --memory-init-file 0 -flto"
#ENV LDFLAGS="-flto=thin -s ALLOW_MEMORY_GROWTH=1"

ARG LDFLAGS
ARG CFLAGS
ARG CXXFLAGS
ENV LDFLAGS=${LDFLAGS:-"-s ALLOW_MEMORY_GROWTH=1"}
ENV CFLAGS=${CFLAGS:-"-Wno-warn-absolute-paths --memory-init-file 0"}
ENV CXXFLAGS=${CXXFLAGS:-"${CFLAGS}"}

#ENV LDFLAGS="-lwasi-emulated-signal"
#ENV CFLAGS="-D_WASI_EMULATED_SIGNAL"
#ENV CXXFLAGS="${CFLAGS}"

RUN mkdir ITK-build && \
  cd ITK-build && \
  cmake \
    -G Ninja \
    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DCMAKE_BUILD_TYPE:STRING=$CMAKE_BUILD_TYPE \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_LEGACY_REMOVE:BOOL=ON \
    -DITK_BUILD_DEFAULT_MODULES:BOOL=ON \
    -DITKGroup_IO:BOOL=ON \
    -DH5_HAVE_GETPWUID:BOOL=OFF \
    -DModule_ITKIOMINC:BOOL=ON \
    -DModule_MGHIO:BOOL=ON \
    -DModule_IOScanco:BOOL=ON \
    -DModule_IOFDF:BOOL=ON \
    -DModule_ITKImageFunction:BOOL=ON \
    -DModule_SmoothingRecursiveYvvGaussianFilter:BOOL=ON \
    -DModule_MorphologicalContourInterpolation:BOOL=ON \
    -DModule_Cuberille:BOOL=ON \
    -DModule_TotalVariation:BOOL=ON \
    -DModule_IOMeshSTL:BOOL=ON \
    -DModule_GenericLabelInterpolator:BOOL=ON \
    -DDO_NOT_BUILD_ITK_TEST_DRIVER:BOOL=ON \
    -DOPJ_USE_THREAD:BOOL=OFF \
    ../ITK && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd .. && chmod -R 777 ITK-build

ENV RAPIDJSON_GIT_TAG v1.1.0
RUN git clone https://github.com/Tencent/rapidjson.git && \
  cd rapidjson && \
  git checkout ${RAPIDJSON_GIT_TAG}

ENV IPFS_TAG v0.10.0
RUN curl -O https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/${IPFS_TAG}/go-ipfs_${IPFS_TAG}_linux-amd64.tar.gz && \
  tar xvzf go-ipfs_${IPFS_TAG}_linux-amd64.tar.gz && \
  cp go-ipfs/ipfs /usr/local/bin/ && \
  rm -rf go-ipfs
ENV IPFS_PATH /home/ipfs/.ipfs
RUN mkdir -p $IPFS_PATH && \
 ipfs init && \
 chmod -R 777 $IPFS_PATH

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG IMAGE=insighttoolkit/itk-js-base
ARG VERSION=latest
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
      org.label-schema.name=$IMAGE \
      org.label-schema.version=$VERSION \
      org.label-schema.vcs-ref=$VCS_REF \
      org.label-schema.vcs-url=$VCS_URL \
      org.label-schema.schema-version="1.0"
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION}
WORKDIR /work
<commit_msg>build(Docker): Use GitHub Release for IPFS download<commit_after>ARG BASE_IMAGE=dockcross/web-wasm
FROM $BASE_IMAGE:20211015-2b6cd4a
ARG BASE_IMAGE

LABEL maintainer="<NAME> <<EMAIL>>"
LABEL org.opencontainers.image.source="https://github.com/InsightSoftwareConsortium/itk-js"

WORKDIR /

# 2021-10-03 master branch
ENV ITK_GIT_TAG 3b68b2092bc2db2978a1ed68efe5ec38fcade185
RUN git clone https://github.com/thewtex/ITK.git && \
  cd ITK && \
  git checkout ${ITK_GIT_TAG} && \
  cd ../ && \
  sed -i -e '/^option(OPJ_USE_THREAD/c\option(OPJ_USE_THREAD "use threads" OFF)' \
    /ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt
ARG CMAKE_BUILD_TYPE=Release

# For SlicerExecutionModel
RUN mkdir ITK-Native-build && \
  cd ITK-Native-build && \
  /usr/bin/cmake \
    -G Ninja \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_LEGACY_REMOVE:BOOL=ON \
    -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF \
    -DITKGroup_Core:BOOL=ON \
    -DModule_ITKCommon:BOOL=ON \
    -DModule_ITKIOXML:BOOL=ON \
    -DModule_ITKExpat:BOOL=ON \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_CXX_COMPILER=/usr/bin/c++ \
    -DCMAKE_TOOLCHAIN_FILE="" \
    ../ITK && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd ..

ENV SlicerExecutionModel_GIT_TAG dbc39c049b3721c5f3ea80f20acd32e3c8cc65f3
RUN git clone https://github.com/thewtex/SlicerExecutionModel.git && \
  cd SlicerExecutionModel && \
  git checkout ${SlicerExecutionModel_GIT_TAG} && \
  cd ../ && \
  mkdir SlicerExecutionModel-build && \
  cd SlicerExecutionModel-build && \
  /usr/bin/cmake \
    -G Ninja \
    -DSlicerExecutionModel_USE_JSONCPP:BOOL=OFF \
    -DCMAKE_BUILD_TYPE:STRING=$CMAKE_BUILD_TYPE \
    -DBUILD_SHARED_LIBS:BOOL=OFF \
    -DCMAKE_INSTALL_PREFIX:PATH=/install-prefix \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_DIR:PATH=/ITK-Native-build \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_CXX_COMPILER=/usr/bin/c++ \
    -DCMAKE_TOOLCHAIN_FILE="" \
    ../SlicerExecutionModel && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd .. && chmod -R 777 SlicerExecutionModel-build

# After the WASI exception / setjmp support may work? setjmp is lost in final
# linking otherwise.
#ENV LDFLAGS="-flto -s ALLOW_MEMORY_GROWTH=1"
#ENV CFLAGS="-Wno-warn-absolute-paths --memory-init-file 0 -flto"
#ENV LDFLAGS="-flto=thin -s ALLOW_MEMORY_GROWTH=1"

ARG LDFLAGS
ARG CFLAGS
ARG CXXFLAGS
ENV LDFLAGS=${LDFLAGS:-"-s ALLOW_MEMORY_GROWTH=1"}
ENV CFLAGS=${CFLAGS:-"-Wno-warn-absolute-paths --memory-init-file 0"}
ENV CXXFLAGS=${CXXFLAGS:-"${CFLAGS}"}

#ENV LDFLAGS="-lwasi-emulated-signal"
#ENV CFLAGS="-D_WASI_EMULATED_SIGNAL"
#ENV CXXFLAGS="${CFLAGS}"

RUN mkdir ITK-build && \
  cd ITK-build && \
  cmake \
    -G Ninja \
    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DCMAKE_BUILD_TYPE:STRING=$CMAKE_BUILD_TYPE \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DITK_LEGACY_REMOVE:BOOL=ON \
    -DITK_BUILD_DEFAULT_MODULES:BOOL=ON \
    -DITKGroup_IO:BOOL=ON \
    -DH5_HAVE_GETPWUID:BOOL=OFF \
    -DModule_ITKIOMINC:BOOL=ON \
    -DModule_MGHIO:BOOL=ON \
    -DModule_IOScanco:BOOL=ON \
    -DModule_IOFDF:BOOL=ON \
    -DModule_ITKImageFunction:BOOL=ON \
    -DModule_SmoothingRecursiveYvvGaussianFilter:BOOL=ON \
    -DModule_MorphologicalContourInterpolation:BOOL=ON \
    -DModule_Cuberille:BOOL=ON \
    -DModule_TotalVariation:BOOL=ON \
    -DModule_IOMeshSTL:BOOL=ON \
    -DModule_GenericLabelInterpolator:BOOL=ON \
    -DDO_NOT_BUILD_ITK_TEST_DRIVER:BOOL=ON \
    -DOPJ_USE_THREAD:BOOL=OFF \
    ../ITK && \
  ninja -j7 && \
  find . -name '*.o' -delete && \
  cd .. && chmod -R 777 ITK-build

ENV RAPIDJSON_GIT_TAG v1.1.0
RUN git clone https://github.com/Tencent/rapidjson.git && \
  cd rapidjson && \
  git checkout ${RAPIDJSON_GIT_TAG}

ENV IPFS_TAG v0.10.0
RUN curl -LO https://github.com/ipfs/go-ipfs/releases/download/${IPFS_TAG}/go-ipfs_${IPFS_TAG}_linux-amd64.tar.gz && \
  tar xvzf go-ipfs_${IPFS_TAG}_linux-amd64.tar.gz && \
  cp go-ipfs/ipfs /usr/local/bin/ && \
  rm -rf go-ipfs
ENV IPFS_PATH /home/ipfs/.ipfs
RUN mkdir -p $IPFS_PATH && \
 ipfs init && \
 chmod -R 777 $IPFS_PATH

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG IMAGE=insighttoolkit/itk-js-base
ARG VERSION=latest
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
      org.label-schema.name=$IMAGE \
      org.label-schema.version=$VERSION \
      org.label-schema.vcs-ref=$VCS_REF \
      org.label-schema.vcs-url=$VCS_URL \
      org.label-schema.schema-version="1.0"
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION}
WORKDIR /work

{'fraction_non_alphanumeric': 0.1401341710148014, 'fraction_numerical': 0.020019167287828772, 'mean_word_length': 3.430188679245283, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3810571', 'n_tokens_mistral': 4079, 'n_tokens_neox': 3877, 'n_words': 544}