SymfonyCasts / sass-bundle

Delightful Sass Support for Symfony + AssetMapper
https://symfony.com/bundles/SassBundle/current/index.html
MIT License
37 stars 18 forks source link

[DOCS] add a note that this bundle does not work with alpine #31

Closed jaapio closed 10 months ago

jaapio commented 12 months ago

This bundle is downloading dart-sass automatically which is perfectly ok when running on windows, macos, linux. Except for some distro's like alpine. Alpine is quite popular for people using docker because of the image size. But this comes with a different libc, which is not the version dart-sass is compiled with.

Their is no alternative download available with musl-libc. See https://github.com/sass/embedded-host-node/issues/155

WebMamba commented 11 months ago

I had a similar issue, do you know if there is a way to install some packages on Alpine to make it compatible?

smnandre commented 11 months ago

If the usage is in a docker, maybe naive question, but is it not possible to add dart-sass to your build ?

https://pkgs.alpinelinux.org/package/edge/testing/x86_64/dart-sass

jaapio commented 11 months ago

That's a test repo you link. There is no stable release yet. But as this is definitely not going to work for everyone, I think it's wise for the maintainers of this project to state that alpine is not supported. Until a real solution is available for everyone..

Yoann-TYT commented 11 months ago

Here, they talk about an unofficial build of SDK

https://github.com/sass/dart-sass/issues/617#issuecomment-1687043337

I tried this build https://github.com/dart-musl/dart-sass/releases and it works successfully on alpine.

/app/var/dart-sass # wget https://github.com/dart-musl/dart-sass/releases/downlo
ad/1.69.5/dart-sass-1.69.5-linux-arm64.tar.gz
tar -xvzf dart-sass-1.69.5-linux-arm64.tar.gz
/app/var/dart-sass # ./sass 
Compile Sass to CSS.
WebMamba commented 11 months ago

Ho so nice! Thanks for sharing! We can do a PR, that detects if the os is Alpine, and if so download this non official build

smnandre commented 11 months ago

We can do a PR, that detects if the os is Alpine, and if so download this non official build

I'm not sure you should vouch for a non-official binary like that.. but just my 2 cents :)

And if you do it for Alpine, will you too for ?

For me you would better:

Yoann-TYT commented 11 months ago

@smnandre I agree with you , relying it on unofficial binary can be a bit risky ;)

I my case, I use https://github.com/dunglas/symfony-docker Adding documentation to describe what we should add in a Dockerfile to build this binary seems like a good idea

LaurentSanson commented 11 months ago

Hi @Yoann-TYT ,

I agree to add a documentation as I'm completely in the same position here. I've been working with Kevin's template and I can't make this bundle work...

Could you please share how you manage it within your Dockerfile?

Thanks !

haivala commented 10 months ago

Here, they talk about an unofficial build of SDK

sass/dart-sass#617 (comment)

I tried this build https://github.com/dart-musl/dart-sass/releases and it works successfully on alpine.

/app/var/dart-sass # wget https://github.com/dart-musl/dart-sass/releases/downlo
ad/1.69.5/dart-sass-1.69.5-linux-arm64.tar.gz
tar -xvzf dart-sass-1.69.5-linux-arm64.tar.gz
/app/var/dart-sass # ./sass 
Compile Sass to CSS.

I'm using php:8.2-fpm-alpine image and I get this error message when I try to run sass dart-sass/src/dart: line 1: syntax error: unexpected word (expecting ")") Has anyone solved this one with this workaround above?

Yoann-TYT commented 10 months ago

It is because my script is for Mac.

I wrote a custom shell to fetch the right binary https://gist.github.com/Yoann-TYT/560b85aa6af5f1c9530bc9c634b87d80

And I add it in my Dockerfile

COPY --link --chmod=755 frankenphp/fetch-dart-sass.sh /usr/local/bin/fetch-dart-sass
RUN fetch-dart-sass

Hope it will be useful for you @LaurentSanson @haivala :)

haivala commented 10 months ago

ah, true. Why didn't I see that

LaurentSanson commented 10 months ago

Thanks @Yoann-TYT , I'm gonna give it another try today :tada:

Hopefully this bundle will soon work with alpine !

weaverryan commented 10 months ago

It probably makes sense to add a note somewhere in the docs about Alpine and just point to this issue for now. Can someone make a PR?

smnandre commented 10 months ago

Things are moving on the Sass side : https://github.com/sass/dart-sass/pull/2149

smnandre commented 10 months ago

It is released: https://github.com/sass/dart-sass/releases/tag/1.69.6

Provide official releases for musl LibC and for Android.

smnandre commented 10 months ago

If someone (using Alpine) can test this patch and say what is working / not that'd be great :)

https://github.com/smnandre/sass-bundle/tree/feat/download-alpine-binary

LaurentSanson commented 10 months ago

I'll give it a try tomorrow @smnandre 💪

LaurentSanson commented 10 months ago

Hello @smnandre , I'm trying to require the package, but it's not working, it's like the package doesn't exists. I've tried with yours and mine, same error

Root composer.json requires laurentsanson/sass-bundle, it could not be found in any version, there may be a typo in the package name.

yivi commented 10 months ago

@LaurentSanson That's not how you request a fork.

Add this to your composer.json.

"repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/smnandre/sass-bundle"
    }
  ],

and change the version constraint for sass-bundle to dev-main to get the patched version.

bocharsky-bw commented 10 months ago

Instead of dev-main I believe you need to use dev-feat/download-alpine-binary to match the branch where changes are made

yivi commented 10 months ago

Instead of dev-main I believe you need to use dev-feat/download-alpine-binary to match the branch where changes are made

@bocharsky-bw You are right, I'm sleepy. Need more tea before writing on the interweb.

Thanks.

@smnandre Works for me 👍

bocharsky-bw commented 10 months ago

Awesome, thanks for double-checking!

Then #51 is almost ready, we just need to fix related failed tests there

LaurentSanson commented 10 months ago

Thanks guys, I've got the package locally now. And I really need to sleep too :smiley:

But it's still not working, same issue for me when trying to bin/console sass:build --watch, the /app/var/dart-sass/src/dart: not found error is here

EDIT :

After removing my var folder, I can confirm that it is working too :+1: