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

Split off Dockerfile components for faster build times #20678

Closed
wants to merge 0 commits into from

Conversation

moritzheiber
Copy link
Member

@moritzheiber moritzheiber commented Nov 14, 2022

This PR splits the current monolithic Dockerfile into two parts, one of which is now executed in a separate pipeline (and repository).

Why

The current Dockerfile builds a new version of Ruby every time the image is built. That's wasteful and slow, especially since we're building against other targets than linux/amd64 (which is even slower; at least until GitHub Actions finally gets native linux/arm64 support).

Additionally, the Dockerfile now relies on the official NodeJS and Ruby images from the Docker Hub to build its assets, meaning there is no more overhead for the contributors in this repository to care for updating/maintaining Ruby and NodeJS installations and stacks (but rather source them from the Hub directly).

Consequences

  • The image is now based on Debian, since the official "slim" images are based on Debian, specifically "Bullseye". I also could've gone for Alpine, but I faintly remember there being issues with Ruby on Alpine under certain conditions and especially when jemalloc is involved.
  • The image relies on a new Ruby image, built in a separate repository, for its source of the Ruby interpreter. Aside from a few cosmetic changes, its instructions haven't changed much. The plan is to move this repository into the mastodon organization as soon as it's feasible. We can also add any number of Ruby versions or supported architectures to the image itself, should it become necessary.
  • I've removed the platform instructions at beginning, as one shouldn't be cleverer than the actual operator. If you're building this image with an unsupported architecture you'll just receive an error from Docker/containerd.

Notes

Most of the stuff I either removed or left out was cosmetic or "solved" by using a different syntax (e.g. WORKDIR instead of cd, passing the --chown flag to ADD instead of using chown manually etc.)

Copy link
Member

@ineffyble ineffyble left a comment

Choose a reason for hiding this comment

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

Woo, speed!

@bobrik
Copy link

bobrik commented Nov 16, 2022

The image relies on a new Ruby image

May I interest you in #20837 to make it a bit slimmer?

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@moritzheiber
Copy link
Member Author

@bobrik Thank you for those excellent suggestions, I've included most of them!

Copy link

@bobrik bobrik left a comment

Choose a reason for hiding this comment

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

I deployed this with my comments applied and it seems to be working.

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
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