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

Allow caching of additional gems #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

schuam
Copy link

@schuam schuam commented Jan 18, 2024

Background and Suggested Fix

Somehow the caching as described in the README.md file didn't work for me. It might be, because I need additional gems for my Jekyll builds, but I don't exactly know. The changes in this commit seem to fix the problem.

  • The changes in the Dockerfile create a new directory for gems that someone might want to install additionally (optionally) to the ones that are already installed in the container image.
  • The changes in the entrypoint file do two things:
    • The export GEM_PATH. This is done to keep /usr/gem in the list of directories that ruby looks for gems. So far ruby only looks in /usr/gem for gems, because GEM_HOME points to that directory. But because I want to overwrite GEM_HOME with /opt/gem the /usr/gem directory has to be explicitly saved in GEM_PATH.
    • Overwrite the GEM_HOME environment variable. This way ruby looks for gems in /opt/gem.
  • The changes in README.md instruct the user of the image to mount a lokal directory on the host into the /opt/gem directory in the container. This way, additionally installed gems are stored persistently on the host and can be used in subsequent containers that are started from the container image.

Missing Tests Build

Unfortunately, I couldn't build the new image locally on my machine. It must have to do with the opts.yml files. But I have had this problem a long time (already with the images built by envygeeks). To fix this, I used the suggested changes in the pull request to build my one image on top of the images from envygeeks. And that worked.

Somehow the caching as described in the README.md file didn't work for
me. It might be, because I need additional gems for my Jekyll builds,
but I don't exactly know. The changes in this commit seem to fix the
problem.

- The changes in the Dockerfile create a new directory for gems that
  someone might want to install additionally (optionally) to the ones
  that are already installed in the container image.
- The changes in the entrypoint file do two things:
  - The export `GEM_PATH`. This is done to keep `/usr/gem` in the list
    of directories that ruby looks for gems. So far ruby only looks in
    `/usr/gem` for gems, because `GEM_HOME` points to that directory.
    But because I want to overwrite `GEM_HOME` with `/opt/gem` the
    `/usr/gem` directory has to be explicitly saved in `GEM_PATH`.
  - Overwrite the `GEM_HOME` environment variable. This way ruby looks
    for gems in `/opt/gem`.
- The changes in README.md instruct the user of the image to mount a
  lokal directory on the host into the `/opt/gem` directory in the
  container. This way, additionally installed gems are stored
  persistently on the host and can be used in subsequent containers that
  are started from the container image.
@schuam schuam requested a review from JV-conseil as a code owner January 18, 2024 20:26
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.

1 participant