Doerge
October 8, 2021, 6:18pm
1
Hi,
I’m trying to build a Phoenix project for production, that I just upgraded to 1.6. It works on my machine.
I added DartSass to my project. However when attempting to build it in a Docker container for release, DartSass fails. First because of the environment: this can be “fixed” by overriding the env like:
- RUN mix deps.get --only prod && \
+ RUN mix deps.get && \
mix deps.compile
- RUN mix sass.install
+ RUN MIX_ENV=dev mix sass.install
However when attempting to use it, it fails like:
$ docker run -it <img> sh
/app # mix sass default --no-source-map --style=compressed
** (Mix) `mix sass default --no-source-map --style=compressed` exited with 2
I feel like I’m simply going down a completely wrong path here.
How do other people build their Sass for release?
Doerge
October 9, 2021, 10:51pm
2
Found out that the Dart Sass binaries doesn’t run on Alpine. I ran into this: linux - Alpine shell can't find file in docker - Server Fault and tried the suggested solution, but couldn’t get it to run
Dart Sass do provide a Javascript version. I ended up with this in my Dockerfile:
- RUN apk add --no-cache build-base
+ RUN apk add --no-cache build-base npm
+ # Install Dart Sass
+ RUN npm install -g sass
[...]
+ # build Sass -> CSS
+ RUN cd assets && \
+ sass --no-source-map --style=compressed css/app.scss ../priv/static/assets/app.css
# build assets
RUN mix assets.deploy
[...]
where mix.exs assets.deploy is:
defp aliases do
[...]
"assets.deploy": [
"esbuild default --minify",
"phx.digest"
]
end
That seemed to work
1 Like
ouven
October 10, 2021, 8:28am
3
Hi, there is an issue, open in dart_sass, where we try to find a solution for alpine. One is to install glibc on alpine:
opened 02:13PM - 05 Oct 21 UTC
closed 05:41PM - 05 Oct 21 UTC
Hi, thank you for this piece of work!
I tried to use the mix task in my build… pipeline (upon `hexpm/elixir:1.12.3-erlang-24.1.1-alpine-3.14.0`). Unfortunatly it fails because of some lib bindings.
```bash
/build # mix sass default
** (Mix) `mix sass default` exited with 2
```
```bash
/build # ./_build/sass apps/web/assets/css/app.scss
sh: ./_build/sass: not found
```
```bash
/build # ldd
musl libc (x86_64)
Version 1.2.2
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname
/build # ldd ./_build/sass
/lib64/ld-linux-x86-64.so.2 (0x7f752da95000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f752da95000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f752da95000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f752da95000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f752da95000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by ./_build/sass)
Error relocating ./_build/sass: __sbrk: symbol not found
Error relocating ./_build/sass: __isinf: symbol not found
/build #
```
It works for me now, i can run dart_sass on my alpine build pipeline.
Maybe you want to join the issue discussion.
1 Like