Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to multi-stage builds #589

Merged
merged 1 commit into from
Dec 14, 2022
Merged

Convert to multi-stage builds #589

merged 1 commit into from
Dec 14, 2022

Conversation

lukebakken
Copy link
Collaborator

Start with the Ubuntu template

Follow-up to #587

@lukebakken
Copy link
Collaborator Author

lukebakken commented Nov 16, 2022

@tianon I've got some minimal changes in the templates to support multi-stage builds.

I'm not sure what's up with the CI failure, however:

bashbrew version v0.1.5
Processing rabbitmq:3.11.3 ...
failed fetching repo "ubuntu:20.04"
unable to find a manifest named "ubuntu" (in "/tmp/tmp.SIfMOjytit/library" or as a remote URL)
+ strategy=

...I can reproduce the same error locally, but I'm not sure of the source of the error. It seems like generate-stackbrew-library.sh is working correctly.

Note that I had to add the setup-go action to fix a compile error in bashbrew. Apparently go 1.18 is required now? 🤷‍♂️

Assistance is appreciated! I will of course clean up commit history once this is figured out.

@tianon
Copy link
Member

tianon commented Nov 16, 2022

Sorry! If you drop your .github changes and rebase on #590, it should be fixed. 🙇

@lukebakken lukebakken marked this pull request as ready for review November 16, 2022 22:53
@lukebakken lukebakken marked this pull request as draft November 16, 2022 22:54
@lukebakken
Copy link
Collaborator Author

lukebakken commented Nov 16, 2022

This is just about ready for review. I need to figure out why the alpine image is quite a bit larger with these changes in my env:

$ docker images '*rabbit*'

REPOSITORY                                  TAG                        IMAGE ID       CREATED         SIZE
rabbitmq-local-multi-stage                  alpine-latest              fd57cc784e62   2 minutes ago   162MB
rabbitmq                                    3-alpine                   6d8788289676   4 days ago      127MB

rabbitmq-local-multi-stage                  ubuntu-latest              48b7a0359d68   5 hours ago     229MB
rabbitmq                                    3                          792f1c5d392c   6 days ago      229MB

UPDATE: hmm I really have no idea why it's 35mb larger, especially since the ubuntu one is the same size 🤔

@lukebakken
Copy link
Collaborator Author

Within the running containers the sizes are comparable:

# rabbitmq:3-alpine    # alpine multi-stage
bash-5.1# du -hs *     bash-5.1# du -hs *
2.0M    bin            2.0M    bin
0       dev            0       dev
547.0K  etc            675.0K  etc
512     home           512     home
4.2M    lib            4.2M    lib
2.0K    media          2.0K    media
512     mnt            512     mnt
24.5M   opt            24.5M   opt
512     plugins        512     plugins
1.0K    root           1.0K    root
512     run            512     run
160.0K  sbin           171.0K  sbin
512     srv            512     srv
0       sys            0       sys
1.0K    tmp            1.0K    tmp
98.8M   usr            98.3M   usr
108.0K  var            108.0K  var

@lukebakken lukebakken marked this pull request as ready for review November 18, 2022 15:39
@lukebakken
Copy link
Collaborator Author

I'm not going to worry too much about the local image size because if I build from master in the 3.11/alpine directory the size is larger than the pulled image 🤷‍♂️

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Overall pretty minor comments all around! 👍

I did compare CI builds of yours to recent master CI builds, and the sizes look comparable:

👍

Dockerfile-alpine.template Outdated Show resolved Hide resolved
Dockerfile-alpine.template Outdated Show resolved Hide resolved
Dockerfile-alpine.template Outdated Show resolved Hide resolved
Dockerfile-alpine.template Outdated Show resolved Hide resolved
Dockerfile-ubuntu.template Outdated Show resolved Hide resolved
Dockerfile-ubuntu.template Show resolved Hide resolved
generate-stackbrew-library.sh Outdated Show resolved Hide resolved
generate-stackbrew-library.sh Show resolved Hide resolved
@tianon
Copy link
Member

tianon commented Nov 18, 2022

(To be explicit: I think the readonly suggestion is the only one of those I'd make a blocker - everything else is fine as-is if you don't want to change it. 👍)

@lukebakken
Copy link
Collaborator Author

lukebakken commented Nov 18, 2022

I've always wondered exactly why shellcheck flags that use of readonly, and thanks to your example I understand why now.

@lukebakken lukebakken requested a review from tianon November 18, 2022 21:14
@lukebakken
Copy link
Collaborator Author

@tianon thanks for the review. Seems like multiple builds are being generated for the same Docker image?

https://github.com/docker-library/rabbitmq/actions/runs/3500314277

...not sure if that's due to my changes or something in bashbrew

@tianon
Copy link
Member

tianon commented Nov 18, 2022

Seems like multiple builds are being generated for the same Docker image?

That's intentional -- note the (i386) at the end. It's doing a 32bit build for images which support it (in our case only Alpine since Ubuntu dropped it) as a rough smoke test for our multiarch support. 👍

Dockerfile-ubuntu.template Outdated Show resolved Hide resolved
@lukebakken lukebakken requested a review from tianon November 18, 2022 22:58
@tianon tianon requested a review from yosifkit November 18, 2022 23:38
@lukebakken
Copy link
Collaborator Author

@tianon I'll resolve the conflicts. Anything else need to be done?

@lukebakken
Copy link
Collaborator Author

Hmm, investigating the latest round of alpine build failures.

Follow-up to #587

Use buildkit
@tianon
Copy link
Member

tianon commented Dec 5, 2022

Ah, that's probably #592 -- Alpine 3.17 updated the default OpenSSL in the distro to OpenSSL 3, so maybe that's conflicting somehow (I thought we had some mitigations to avoid that but maybe they broke or something)?

@lukebakken
Copy link
Collaborator Author

@tianon ha, no it was much simpler... I didn't update the final base image to alpine:3.17, so there were mismatches in which packages were added for Erlang run-time deps.

It did prompt me to ask this - #596

@lukebakken lukebakken requested a review from yosifkit December 8, 2022 21:25
@lukebakken
Copy link
Collaborator Author

@tianon are we waiting on one more review here? Do you need anything else from me?

@tianon
Copy link
Member

tianon commented Dec 13, 2022

Yeah, just waiting for @yosifkit to get some time to go through it again 👍

@yosifkit yosifkit merged commit 86ae345 into docker-library:master Dec 14, 2022
@lukebakken lukebakken deleted the lukebakken/multi-stage-2 branch December 14, 2022 01:23
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Dec 14, 2022
Changes:

- docker-library/rabbitmq@86ae345: Merge pull request docker-library/rabbitmq#589 from lukebakken/lukebakken/multi-stage-2
- docker-library/rabbitmq@625a9a2: Update 3.11 to 3.11.5
- docker-library/rabbitmq@175c1b8: Update 3.10 to 3.10.13
- docker-library/rabbitmq@9afab9b: Update 3.9 to 3.9.27
- docker-library/rabbitmq@99d3ad5: Convert to multi-stage builds
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Dec 14, 2022
Changes:

- docker-library/rabbitmq@878cc31: Update 3.9 to otp 25.2
- docker-library/rabbitmq@eb98ea3: Update 3.11 to otp 25.2
- docker-library/rabbitmq@3d32bb2: Update 3.10 to otp 25.2
- docker-library/rabbitmq@86ae345: Merge pull request docker-library/rabbitmq#589 from lukebakken/lukebakken/multi-stage-2
- docker-library/rabbitmq@625a9a2: Update 3.11 to 3.11.5
- docker-library/rabbitmq@175c1b8: Update 3.10 to 3.10.13
- docker-library/rabbitmq@9afab9b: Update 3.9 to 3.9.27
- docker-library/rabbitmq@99d3ad5: Convert to multi-stage builds
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.

3 participants