CargoSense / dart_sass

Install and run Dart Sass using Elixir.
https://hex.pm/packages/dart_sass
MIT License
104 stars 23 forks source link

Small documentation note #19

Closed paul-norman closed 2 years ago

paul-norman commented 2 years ago

I recently tried out Elixir for the first time yesterday and decided to use an Alpine Linux Docker container for this test (as I do with many things that I try out). I wanted to add SASS support to Phoenix, but I didn't really want an entire Node ecosystem tagged on and lacked the Elixir understanding to do it myself. I found this project and it is great! Well done!

However, sadly my journey wasn't straight forward (details below) and it might be worth noting in the docs somewhere that this project requires bash and glibc (neither of which ship with Alpine or some other distros). In fact, apparently using glibc on Alpine is very naughty and the project that I used to add it to my (dev-only) container is rather unsafe (or at best unpredictable).


Details on what happens without these dependencies follows. My only error on boot (interspersed with many other messages) was:

env: can't execute 'bash': No such file or directory

(no indication that this had anything to do with SASS) and when I added bash it became:

/app/_build/dev/lib/dart_sass/priv/dart_sass.bash: line 13: /app/_build/sass: No such file or directory

Which is absolutely untrue, that file existed in my _build directory.

After some searching, I found that SASS relied upon gclib, so I added that in the clunkiest way possible (since Alpine uses musl):

ENV GLIBC_VERSION=2.34-r0
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget -q -O /tmp/glibc.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk && \
    apk add /tmp/glibc.apk && \
    rm -rf /tmp/glibc.apk

And only then did the system build my CSS file.

mcrumm commented 2 years ago

Hi @paul-norman, thanks for the detailed report! I just merged #14 which adds an FAQ for Alpine Linux to the README, but after reading your note I wonder if it should be updated to highlight some of the issues you pointed out. Would you be able to send a PR?

The bash requirement comes from the wrapper script we use to ensure that we don't leave behind zombie processes when running as a watcher in a Phoenix app. I am not sure if the wrapper script can be written without the bash requirement, but I will look into it, thanks!

mjansing commented 1 year ago

On newer alpine images we use this:

ENV GLIBC_VERSION=2.34-r0
COPY docker/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
RUN wget -q -O /tmp/glibc.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk && \
    mv /etc/nsswitch.conf /etc/nsswitch.conf.bak && \
    apk add --no-cache --force-overwrite /tmp/glibc.apk && \
    mv /etc/nsswitch.conf.bak /etc/nsswitch.conf && \
    rm -rf /tmp/glibc.apk
grrrisu commented 4 months ago

set version to latest GLIBC_VERSION=2.35-r1 if you encounter this error:

ERROR: glibc-2.34-r0: trying to overwrite etc/nsswitch.conf owned by alpine-baselayout-data-3.4.3-r2