Skip to content

Conversation

menotthakur
Copy link

Adding optimization for Building Dependencies

  • Use --no-cache and --no-install-recommends to reduce image size
    Clean up package cache after install

Effect:

  • Easier to maintain and update
  • More consistent with Docker community standards
  • Slightly smaller and cleaner image

Adding optimization for Building Dependencies
Copy link

github-actions bot commented Aug 6, 2025

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@r0qs
Copy link
Member

r0qs commented Sep 23, 2025

Thanks for the effort! However, since this is a multi-stage build, the APK cache cleanup in the build stage doesn't affect the final image, the entire build stage gets discarded and the final image is built FROM scratch with just the compiler binary. The multi-stage approach already eliminates all build dependencies and cache from the final image. However the addition of --no-install-recommends could speed up the building process. So, feel free to change the PR to perform only that and rename it accordingly. Otherwise I think we can close the PR in its current state.

Comment on lines +9 to +17
RUN apk update && \
apk add --no-cache --no-install-recommends \
boost-dev \
boost-static \
build-base \
cmake \
git \
clang && \
rm -rf /var/cache/apk/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're at refactoring the Dockerfiles, I'll just add that I'd prefer if we eventually switched to this style for multi-command RUN:

Suggested change
RUN apk update && \
apk add --no-cache --no-install-recommends \
boost-dev \
boost-static \
build-base \
cmake \
git \
clang && \
rm -rf /var/cache/apk/*
RUN <<-EOF
set -eou pipefail
apk update
apk add --no-install-recommends \
boost-dev \
boost-static \
build-base \
cmake \
git \
clang
rm -rf /var/cache/apk/*
EOF

It has less noise from continuations and && and does not require changing the snippet when it is moved to/from an .sh file.

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

Successfully merging this pull request may close these issues.

3 participants