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

Improve Docker image builld #62

Open
pierresouchay opened this issue Apr 17, 2020 · 2 comments
Open

Improve Docker image builld #62

pierresouchay opened this issue Apr 17, 2020 · 2 comments

Comments

@pierresouchay
Copy link
Contributor

As suggested by @simongareste, there is room for improvement for Docker Image as explained in #61 (comment) :

However, I believe you still have an issue in the repository, as the Gemfile.lock provided here states

BUNDLED WITH
2.1.4

whereas the docker image ruby:2.5 comes with bundler 1.17.2. Because of this, building the image by directly building the Dockerfile upon clone won't work :

[...]
Step 5/10 : RUN bundle install
 ---> Running in 6507a122ed1f
You must use Bundler 2 or greater with this lockfile.
The command '/bin/sh -c bundle install' returned a non-zero code: 20

I see a few options to fix this:

  • update rubygems in the Dockerfile before running bundle install: RUN gem update --system. This leads to a warning (Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.1.4.), but compiles successfully, and works (my consul-ui is working fine)
  • do not ship the Gemfile.lock in the image, by adding Gemfile.lock to the .dockerignore file (or even remove the Gemfile.lock altogether). This would lead to a variation of gems in the image, depending on the time/date of the build, which may or may not be a super idea. May I suggest, however, to lighten the image and speed up the build by removing everything that is not necessary, starting with the .git folder and a few others files? I can do a pull request for this one.
  • upgrade the ruby image used, to one that is using the same bundle version as the one in your Gemfile.lock. This looks messy.
  • rebuild and recommit the Gemfile.lock with a 1.17.x version.
  • other options: I'm pretty sure there are a lot more options, these are the simplest that come to mind :)
@simongareste
Copy link

Hello,

So, I have a working PR for this, however it would lead to changes in the gemspec file, as it wouldn't have the .git folder anymore, thus not have access to git ls-files.

Basically, my PR would (I believe) improve the docker image produced, in terms of content and size, but lead to an less elegant way of producing the gem, so I'm not sure if it's really worth it, given that you seem to not use the image much.

@pierresouchay
Copy link
Contributor Author

@simongareste I am Ok for the change as long as it works :-)
I am Ok with:

  • removing the samples/* directory from spec.files (that where most of the changes are anyway)
  • include only what is needed for the Gem to work well
  • include only the files from lib/, bin/ using a simple find

This would actually decrease the size of the GEM, so, that would be a good thing.
So, feel free to do your PR, I'll be glad to review it to have a better Docker file and a better Gem

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

2 participants