Skip to content

Build and release low-size images with binary only - #250

Merged
alcohol merged 1 commit into
composer:mainfrom
Wirone:standalone-binary
Oct 31, 2022
Merged

Build and release low-size images with binary only#250
alcohol merged 1 commit into
composer:mainfrom
Wirone:standalone-binary

Conversation

@Wirone

@WironeWirone commented Jul 7, 2022

Copy link
Copy Markdown
Contributor

Fixes#249

📖 Blog post with explanation.

ℹ️ INFO

I think it can be cleaned up to minimise redundancy, but I did not want refactor current process, rather follow existing convention. Dockerfiles are fully backward compatible, because the last target in the file (which is built when --target option is not defined) builds full image, same as currently.

dive output for standalone-binary and binary-with-runtime target builds:

image

image

2.4MB vs 188MB, quite a difference 😉

❓ Questions / doubts:

  • Should I add some info to the Readme?
  • As far as I understand PRs to official Docker library are created manually? Because I did not found it here. Will it be straightforward to add *-bin images there from now on?
  • can we test it by tagging some RC version?

@ciaranmcnultyciaranmcnulty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks good to me. It might be interesting in future to build them together with bake

@Seldaek
Seldaek requested a review from alcoholJuly 12, 2022 08:13
@Wirone

Copy link
Copy Markdown
ContributorAuthor

This looks good to me. It might be interesting in future to build them together with bake

@ciaranmcnulty do you mean docker buildx bake? I've never used it unfortunately, but seems like interesting idea. I rather thought about making some Github Actions matrix, so some logic could be extracted and parameterised. But I went with "good enough" approach for now 😉

Let's see what @alcohol says about it 🙂

@alcohol

Copy link
Copy Markdown
Member

I think a binary-only image is a good idea. The current build process/matrix is a bit crude admittedly, but, it works (:tm:) :sweat_smile: . Probably due for an overhaul, but this PR might do for now. Though it does not account for how the official images are generated. So in its current state, it would only apply for the community image on Docker Hub and Amazon ECR.

@Wirone

Copy link
Copy Markdown
ContributorAuthor

Though it does not account for how the official images are generated. So in its current state, it would only apply for the community image on Docker Hub and Amazon ECR.

Yes, I know and it was done like this on purpose. There's a doubt in PR's description:

As far as I understand PRs to official Docker library are created manually? Because I did not found it here. Will it be straightforward to add *-bin images there from now on?

I just thought I will follow this repository's convention and official tags will be handled somewhere else 😉 Even with regular composer/composer community image it would allow better builds using COPY --from (especially when you consider manual work required to update official registry and time overhead to make it available for download).

I think it could be solved in separate MR that could automate process of creating MRs to official Docker registry. Anyway, not a blocker IMHO.

@alcohol

alcohol commented Jul 26, 2022

Copy link
Copy Markdown
Member

I think it could be solved in separate MR that could automate process of creating MRs to official Docker registry. Anyway, not a blocker IMHO.

This is probably doable. It actually is not very complicated. I update my fork of docker-library/official-images using the generate-stackbrew-library.sh script from this repository. I redirect the output of said script to library/composer, commit and push my changes, and then submit a pull-request (which takes like 2 seconds using gh create pr from CLI). This script is also what needs to be modified if we want to submit the binary tags to the official-images repository. I think it is partially based on directory structure. I have never really dived into the inner workings of it in great detail; only enough to properly setup the alias for latest and shortened versions (1, 2, etc).

@alcohol

Copy link
Copy Markdown
Member

Sorry for taking so long to get back to this. Could you update your PR to take into account the 2.4 directory? I'll merge it ASAP then.

@Wirone
Wirone requested review from ciaranmcnulty and removed request for alcoholOctober 28, 2022 09:56
@Wirone

Copy link
Copy Markdown
ContributorAuthor

@alcohol Done 🙂 Great news!

PS. I did not remove you from review, I just clicked "request re-review" from @ciaranmcnulty 🤷‍♂️

@ciaranmcnultyciaranmcnulty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@alcohol

Copy link
Copy Markdown
Member

Cheers

@alcohol

Copy link
Copy Markdown
Member

Drats, this change seems to have broken the bashbrew script. Can't quite figure out what step though.

@Wirone

Copy link
Copy Markdown
ContributorAuthor

@alcohol can you point me to that "bashbrew script"? What's failing?

@alcohol

Copy link
Copy Markdown
Member

I managed to patch it. Turns out it wasn't really setup to parse dockerfiles with multiple FROM sources.

Sign up for freeto 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.

Introduce composer-binary low-size image

3 participants

@Wirone@alcohol@ciaranmcnulty