Skip to content

Conversation

@stklcode
Copy link

  • merge consecutive RUN statements, if the belong to the same feature
  • clear apt cache after each setup step
  • use inline --chmod for COPY steps

This reduces the final image by 9 layers and about 20MB compressed size withuht functional changes.


Comparison of docker history for both images:

CREATED BY ID (orig) SIZE (orig) ID (red) SIZE (red)
/bin/sh -c #(nop) EXPOSE 80 443 e30dd53c1f1b 0B 2133ebe85ced 0B
/bin/sh -c #(nop) CMD ["/usr/bin/openxpkic... <missing> 0B <missing> 0B
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... <missing> 5.63kB <missing> 5.62 kB
/bin/sh -c #(nop) VOLUME /var/www/download 953dadccae04 0B ae515104e03d 0B
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... <missing> 3.07kB <missing> 3.07kB
/bin/sh -c #(nop) WORKDIR /var/log/ be42f81f25d3 0B 905974a1fcef 0B
/bin/sh -c #(nop) VOLUME /var/log/openxpki... <missing> 0B <missing> 0B
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... <missing> 2.56kB <missing> 2.56kB
/bin/sh -c #(nop) VOLUME /run/openxpkid /r... 32724467e995 0B 95ea01205edb 0B
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... <missing> 2.56kB <missing> 2.56kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 9c65b1199618 2.56kB -- --
/bin/sh -c #(nop) COPY file:f46f91712095eb... f43959311425 3.07kB 394a3134038f 3.07kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... a627406079e2 2.56kB -- --
/bin/sh -c #(nop) COPY file:67974057a5b181... 86315ec6a47d 6.14kB da5836cc73ed 6.14kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 0c8c8736064d 2.56kB -- --
/bin/sh -c #(nop) COPY file:be239d5e97f3ec... e08636d9989a 7.17kB eefe7fe71951 7.17kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... fba788433710 4.1kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 59527cfd1a1b 4.1kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 7fd44c1d4435 3.58kB 445666cf8208 6.66 kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... fd7dbc552bfa 4.1kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 15ba2c8dd4b7 13.8kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... d6fb34b9af93 17.4kB e1340e83fc0f 28.2 kB
/bin/sh -c #(nop) VOLUME /etc/openxpki 8a6a75224d70 0B 90b00a93890c 0B
/bin/sh -c #(nop) ENV LANG=en_US.UTF-8 LAN... <missing> 0B <missing> 0B
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... <missing> 50.7kB <missing> 50.7 kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... eaffeb09325a 9.22kB 7c790b466b76 9.22 kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 147d29c28b97 8.7kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 439f7cd543e2 5.12kB -- --
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 079c7928d947 378MB 745ea78437b3 378 MB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 268e363b50db 5.12kB 9784a6bb4de1 5.12 kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 31574b1184b9 4.1kB e2522367dd82 4.1 kB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... d0f49c13702b 5.21MB 074f07eef666 5.21 MB
|2 DEBIAN_FRONTEND=noninteractive OPENXPKI... 53af8ba62add 202MB c28873d198ba 182 MB
/bin/sh -c #(nop) ARG DEBIAN_FRONTEND OPEN... b3a422523a11 0B b3a422523a11 0B
/bin/sh -c #(nop) ARG DEBIAN_FRONTEND <missing> 0B <missing> 0B
# debian.sh --arch 'amd64' out/ 'bookworm'... <missing> 121MB <missing> 121MB

Comparison of compressed size reported by docker images:

REPOSITORY TAG IMAGE ID SIZE
localhost/openxpki reduced 7e681aa6f2f3 687 MB
localhost/openxpki original cbd901c12d87 707 MB

(* actually built and tested with podman, but the results should be equally valid)

* merge consecutive RUN statements, if the belong to the same feature
* clear apt cache after each setup step
* use inline --chmod for COPY steps

This reduces the final image by 9 layers and about 20MB compressed size
withuht functional changes.
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.

1 participant