Builds on top of #53 to use the builder pattern. Here, we do general work in a temporary builder stage and copy only the required files into the rust-optimizer and workspace-optimizer images. Anything that doesn't get copied into the final images is thrown away. This reduces image sizes by ~10% to 900MB. Note that rust:1.54.0-alpine is 786MB before we add any wasm specific stuff, so only adding ~100MB is quite good.
❯ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
cosmwasm/rust-optimizer 0.12.1 4f80eb3b2ad0 3 hours ago 902MB
cosmwasm/workspace-optimizer 0.12.1 b7bb3c9473e4 3 hours ago 924MB
cosmwasm/workspace-optimizer 0.12.0 b9f4ed28322e 4 hours ago 1.03GB
cosmwasm/rust-optimizer 0.12.0 517921e0c25b 4 hours ago 1.06GB
The way the Dockerfiles were written before meant that files that were removed in separate RUN commands were still present in other layers, e.g.
Builds on top of #53 to use the builder pattern. Here, we do general work in a temporary builder stage and copy only the required files into the rust-optimizer and workspace-optimizer images. Anything that doesn't get copied into the final images is thrown away. This reduces image sizes by ~10% to 900MB. Note that rust:1.54.0-alpine is 786MB before we add any wasm specific stuff, so only adding ~100MB is quite good.
The way the Dockerfiles were written before meant that files that were removed in separate
RUN
commands were still present in other layers, e.g.https://github.com/CosmWasm/rust-optimizer/blob/5a519d85ec6a69fe46b7864607b0092267ade209/Dockerfile#L20-L23
The 0.12.0 and 0.12.1 containers produce identical wasm files: