Skip to content

Commit

Permalink
Implements emsdk v3.1.16 toolchain (#24)
Browse files Browse the repository at this point in the history
Implements emsdk 3.1.16 toolchain

Signed-off-by: M4tteoP <[email protected]>
  • Loading branch information
M4tteoP authored Jul 21, 2022
1 parent 96d15a3 commit 97cebc1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-wasm-plugin-static:
extract-wasm-plugin-static:
@docker rm -f $(EXTRACT_CONTAINER_NAME) || true
@docker create --rm --name $(EXTRACT_CONTAINER_NAME) $(IMAGE_NAME):$(IMAGE_VERSION) /plugin.wasm
@mkdir ./build
@mkdir -p ./build
@docker cp $(EXTRACT_CONTAINER_NAME):/plugin.wasm ./build/modsecurity-filter.wasm
@docker rm -f $(EXTRACT_CONTAINER_NAME)

36 changes: 23 additions & 13 deletions wasmplugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,26 @@ RUN git clone -b v3.9.1 https://github.com/protocolbuffers/protobuf \
ARG MODSEC_SHA=a3454df9b09a8de16d41be10cdea4fc46ef08e91

WORKDIR /root/
RUN git clone https://github.com/emscripten-core/emsdk.git -b 3.1.15 \
&& git clone https://github.com/maxfierke/libpcre.git -b mf-wasm32-wasi-cross-compile \
RUN git clone https://github.com/emscripten-core/emsdk.git -b 3.1.16 \
&& git clone https://github.com/M4tteoP/libpcre.git -b wasm-emscripten \
&& git clone https://github.com/SpiderLabs/ModSecurity.git \
&& git -C ModSecurity checkout $MODSEC_SHA \
&& git clone https://github.com/abseil/abseil-cpp -b 20211102.0 \
&& git clone https://github.com/proxy-wasm/proxy-wasm-cpp-sdk \
&& git clone https://github.com/istio/proxy.git -b 1.13.3

WORKDIR /root/emsdk
RUN ./emsdk install 2.0.7 \
&& ./emsdk activate 2.0.7 \
RUN ./emsdk install 3.1.16 \
&& ./emsdk activate 3.1.16 \
&& echo "source /root/emsdk/emsdk_env.sh" >> ~/.bashrc \
&& cd ..

RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz \
&& tar xvf wasi-sdk-12.0-linux.tar.gz -C /opt/ \
&& mv /opt/wasi-sdk-12.0/ /opt/wasi-sdk \
&& rm wasi-sdk-12.0-linux.tar.gz

ENV WASI_SDK_PATH="/opt/wasi-sdk"

WORKDIR /root/libpcre
RUN autoreconf -ivf \
&& ./build_for_crystal.sh wasm32-wasi \
&& source "/root/emsdk/emsdk_env.sh" \
&& ./build_for_wasm.sh wasm32-emscripten \
&& mkdir /usr/local/pcre \
&& cp targets/wasm32-wasi/*.a /usr/local/pcre \
&& cp targets/wasm32-emscripten/*.a /usr/local/pcre \
&& cd ..

WORKDIR /root/ModSecurity
Expand All @@ -80,6 +74,22 @@ WORKDIR /root/proxy-wasm-cpp-sdk
RUN mkdir /build /sdk \
&& cp *.cc *.h *.js *.proto Makefile* *.a /sdk/

WORKDIR /root
RUN source "/root/emsdk/emsdk_env.sh" \
&& git clone https://github.com/protocolbuffers/protobuf -b v3.9.1 protobuf-wasm \
&& cd protobuf-wasm \
&& git clone https://github.com/kwonoj/protobuf-wasm wasm-patches \
&& cd wasm-patches \
&& git checkout 4bba8b2f38b5004f87489642b6ca4525ae72fe7f \
&& cd .. \
&& git apply wasm-patches/*.patch \
&& ./autogen.sh \
&& emconfigure ./configure --disable-shared CXXFLAGS="-O3 -flto" \
&& emmake make \
&& cd .. \
&& cp protobuf-wasm/src/.libs/libprotobuf-lite.a /sdk/libprotobuf-lite.a \
&& cp protobuf-wasm/src/.libs/libprotobuf.a /sdk/libprotobuf.a

WORKDIR /root
RUN wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \
&& chmod +x /usr/local/bin/bazel
Expand Down

0 comments on commit 97cebc1

Please sign in to comment.