Skip to content

fix(docker): multi-stage build to reduce image size (#89)#188

Open
Philzwrist07 wants to merge 1 commit into
PrincessnJoy:mainfrom
Philzwrist07:fix/89-multi-stage-docker
Open

fix(docker): multi-stage build to reduce image size (#89)#188
Philzwrist07 wants to merge 1 commit into
PrincessnJoy:mainfrom
Philzwrist07:fix/89-multi-stage-docker

Conversation

@Philzwrist07
Copy link
Copy Markdown

Summary

Resolves #89.

The previous Dockerfile used a single stage, shipping the full Rust toolchain in the final image (~1.5 GB). This PR refactors it to a two-stage build:

Stage Base image Purpose
builder rust:1.75-slim-bookworm (pinned digest) Compiles WASM binaries
runtime debian:bookworm-slim (pinned digest) Ships only the .wasm artifacts

The runtime image contains no Rust toolchain, reducing the final image size by >95% and eliminating build tools from the attack surface.

Changes

  • Dockerfile — two-stage build with pinned base image digests
  • docker-compose.ymldev service targets builder; new artifacts service (profile: artifacts) targets runtime
  • README.md — documents both stages and build commands

Testing

  • docker build --target builder -t cosmosvote:builder . — builds successfully
  • docker build --target runtime -t cosmosvote:runtime . — produces minimal image with only .wasm files

- Add builder stage (rust:1.75-slim-bookworm, pinned digest) that
  compiles WASM binaries
- Add runtime stage (debian:bookworm-slim, pinned digest) that ships
  only the .wasm artifacts, eliminating the full Rust toolchain from
  the final image
- Update docker-compose.yml: dev service targets builder stage;
  new artifacts service targets runtime stage (profile: artifacts)
- Document both stages and build commands in README

Closes PrincessnJoy#89
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@Philzwrist07 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No multi-stage Docker build; image includes dev dependencies

1 participant