Skip to content

Commit

Permalink
v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
luca992 authored Nov 18, 2023
1 parent c34bd2d commit 4f03477
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions secret-contract-optimizer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the specified Rust image
FROM rust:1.73.0-alpine3.18

# Add the WebAssembly target
RUN rustup target add wasm32-unknown-unknown

# Set up build dependencies
RUN apk add --no-cache build-base cmake git clang

# Clone Binaryen and build it
RUN git clone --branch version_116 --recurse-submodules https://github.com/WebAssembly/binaryen.git && \
cd binaryen && \
mkdir build && \
cd build && \
cmake .. && \
make && \
make install

# Set the working directory
WORKDIR /contract

# Build, optimize, and compress the WebAssembly binaries
# Note: Since Alpine uses ash shell by default, the entrypoint is adjusted to use sh instead of bash.
ENTRYPOINT ["/bin/sh", "-c", "\
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked && \
(mkdir -p ./optimized-wasm/ && rm -f ./optimized-wasm/* && cp ./target/wasm32-unknown-unknown/release/*.wasm ./optimized-wasm/) && \
for w in ./optimized-wasm/*.wasm; do \
wasm-opt -Oz $w -o $w ; \
done && \
(cd ./optimized-wasm && gzip -n -9 -f *) \
"]

0 comments on commit 4f03477

Please sign in to comment.