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

Use ruby slim image instead of alpine #12

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

ianmooney
Copy link
Contributor

@ianmooney ianmooney commented Nov 14, 2023

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.

We are also seeing this 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

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.

@ianmooney ianmooney added the bug Something isn't working label Nov 14, 2023
Dockerfile Outdated
@@ -1,4 +1,4 @@
FROM ruby:3.2.1-alpine
FROM ruby:3.1.4
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

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/*

@ianmooney ianmooney force-pushed the slug-361-canvas-linter-action-broken branch 2 times, most recently from f376275 to ee1c503 Compare November 14, 2023 16:03
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.
@ianmooney ianmooney force-pushed the slug-361-canvas-linter-action-broken branch from ee1c503 to 2e7c468 Compare November 14, 2023 16:08
@ianmooney ianmooney changed the title Use ruby base image instead of alpine Use ruby slim image instead of alpine Nov 14, 2023
@ianmooney ianmooney merged commit d592aa3 into main Nov 14, 2023
@ianmooney ianmooney deleted the slug-361-canvas-linter-action-broken branch November 14, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants