-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use ruby slim image instead of alpine #12
Conversation
Dockerfile
Outdated
@@ -1,4 +1,4 @@ | |||
FROM ruby:3.2.1-alpine | |||
FROM ruby:3.1.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that this works suggests there's a package we could install into the slim
version to get it to work.
Is adding
RUN apt install -y build-essential
enough to get this to work with the slim image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I get the following error - E: Unable to locate package build-essential
https://github.com/easolhq/alchemist-theme/actions/runs/6863696394/job/18671649930
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it works with the following:
RUN apt update
RUN apt install -y build-essential
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to do that on one line and clear the package data to keep the image size down, otherwise it caches the intermediate layers, and we end up with a larger image:
RUN apt update && apt install -y build-essential && rm -rf /var/lib/apt/lists/*
f376275
to
ee1c503
Compare
We are seeing the following error when this Github action is executed: ERROR: glibc-2.34-r0: trying to overwrite etc/nsswitch.conf owned by alpine-baselayout-data-3.2.0-r23. There seems to be a problem when it attempts to install glibc, which is needed as a native dependency for dartsass. This commit resolves this by using a slim image instead of alpine, which already includes the `glibc` package, so it doesn't need to be explicitly installed. We need to install the `build-essential` package so that native gem dependencies are installed successfully. Otherwise we recieve the following error when installing native dependencies for the racc gem, which is a dependency of nokogiri: current directory: /usr/local/bundle/gems/racc-1.7.3/ext/racc/cparse make DESTDIR\= sitearchdir\=./.gem.20231114-7-jo9434 sitelibdir\=./.gem.20231114-7-jo9434 clean current directory: /usr/local/bundle/gems/racc-1.7.3/ext/racc/cparse make DESTDIR\= sitearchdir\=./.gem.20231114-7-jo9434 sitelibdir\=./.gem.20231114-7-jo9434 make failedNo such file or directory - make The `rm -rf /var/lib/apt/lists/*` part will clear the package data and help keep the overall image size small. We are targeting ruby v3.1.4, as this matches the version we currently use in the easol Rails app.
ee1c503
to
2e7c468
Compare
We are seeing the following error when this Github action is executed:
There seems to be a problem when it attempts to install glibc, which is needed as a native dependency for dartsass.
We are also seeing this error when installing native dependencies for the racc gem, which is a dependency of nokogiri:
This commit solves both these errors by using the base image for ruby, instead of the alpine image. The base image is about 10x larger but solves the problem and doesn't seem to slow down the build too much.
Targeting ruby v3.1.4, as this matches the version we currently use in the easol Rails app.