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

Review bundle groups in Gemfile #4291

Open
bencomp opened this issue Aug 29, 2024 · 6 comments
Open

Review bundle groups in Gemfile #4291

bencomp opened this issue Aug 29, 2024 · 6 comments
Assignees

Comments

@bencomp
Copy link
Contributor

bencomp commented Aug 29, 2024

In an effort to create a small-ish Docker/Podman image for running FromThePage in production, I would like to not install gems that are not necessary for running the application. I think capistrano may not be needed, for example.

Would it be possible to review the current :test, :development and :assets groups of gems and perhaps add one for deployment? When building the image, it is then clearer which groups can be left out.

Maybe the sassc-rails gem can be moved to the :assets group?

@benwbrum
Copy link
Owner

We can take a look at this, although we use capistrano to do all of our deployments to FromThePage.com.

This presents an interesting issue -- an installation is either using capistrano or using containers, but almost certainly not both. Any idea on how to structure a Gemfile to handle that?

@bencomp
Copy link
Contributor Author

bencomp commented Aug 29, 2024

If you put gems related to deployment into a group (like the existing groups in the Gemfile), I can tell Bundler to exclude that group during installation, while building the container image.
I was hoping you could tell which gems are only included for deployment 😊

@bencomp
Copy link
Contributor Author

bencomp commented Sep 3, 2024

I just found out that not installing gems in certain groups causes the application to fail during startup, because

Bundler.require(*Rails.groups)

explicitly loads all gems. Is it possible to be more cautious in loading gems? I'm thinking it could make FromThePage run with a smaller memory footprint too. I don't want to use OpenAI or Bento, so I don't want to install, let alone load those gems.

Edit: I created #4316 to address this specific line of code.

@benwbrum
Copy link
Owner

benwbrum commented Sep 3, 2024

@WillNigel23, what do you think?

@WillNigel23
Copy link
Collaborator

Sounds good, but I think we do indeed need to review it.

I have been slowly grouping relevant gems together (I think in rails upgrade PR I did some gem cleanup there) but still needs a lot more

@bencomp
Copy link
Contributor Author

bencomp commented Sep 9, 2024

While "we" are reviewing: I believe the uglifier gem is not used anymore. The terser gem is presented as a replacement and that is used in the production environment.

I did notice that #4237 reordered gems in the Gemfile, although I don't know what most of them do and cannot say which gems would better go in which group. As long as all gems are required on startup, grouping doesn't really matter.

By the way, I realised that me not wanting to use and install OpenAI and Bento is a different issue, because they are used in the application itself, not for development, testing, building or deploying the application.

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

No branches or pull requests

3 participants