Skip to content

Commit

Permalink
Use ruby slim image instead of alpine
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ianmooney committed Nov 14, 2023
1 parent 6e19fd5 commit 2e7c468
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM ruby:3.2.1-alpine
FROM ruby:3.1.4-slim

RUN apt update && apt install -y build-essential && rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /entrypoint.sh

Expand Down
5 changes: 0 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

# This is needed as native dependencies for dartsass
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk
apk add glibc-2.34-r0.apk

gem install easol-canvas --version='~> 4.1'

canvas lint

0 comments on commit 2e7c468

Please sign in to comment.