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

TailwindCSS Standalone CLI not working in Alpine Linux (docker) #6690

Closed
altdsoy opened this issue Dec 22, 2021 · 7 comments
Closed

TailwindCSS Standalone CLI not working in Alpine Linux (docker) #6690

altdsoy opened this issue Dec 22, 2021 · 7 comments

Comments

@altdsoy
Copy link

altdsoy commented Dec 22, 2021

The tailwindcss binary release is not working on Alpine Linux.
Tested with the release tailwindcss-linux-x64 v3.0.7 on the latest docker alpine image.

If I run an alpine container (installing curl, and downloading the standalone release as described here https://tailwindcss.com/blog/standalone-cli#get-started ) I got nothing (binary not found).
Running the exact same steps in debian works.

Tell me if I need to provide more information.

Example steps to reproduce it:

#On the host
docker run -it --rm alpine ash

#Within the container
apk add curl
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
chmod +x tailwindcss-linux-x64
mv tailwindcss-linux-x64 tailwindcss
./tailwindcss init
# Got => ./tailwindcss: not found

The exact same steps works fine using debian for example:

#On the host
docker run -it --rm debian bash

#Within the container
apt update
apt install curl # Type Y to install
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
chmod +x tailwindcss-linux-x64
mv tailwindcss-linux-x64 tailwindcss
./tailwindcss init
# Generate tailwind.config.js

Edit:
Here is the output of file:

tailwindcss: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2e882d60273a4031f72a88815a36cb574dc1090b, for GNU/Linux 2.6.32, stripped

Seems I need to install some libraries...

Edit 2:
This answer from SO seems relevant to the issue: https://stackoverflow.com/a/66974607

Executables built on glibc distributions depend on /lib/x86_64-linux-gnu/libc.so.6, for example, which is not available on Alpine (unless, they are statically linked).

So is it possible to statically link dependencies when compiling the binaries?

Edit 3:
Some workarounds are based on installing gcompat and/or libc6-compat, but those do not fix the tailwindcss issue.

Edit 4:
I just noticed that the standalone CLI is using a tool called pkg under the hood.

So maybe this issue does not belong here..
If so, feel free to close.

Edit 5: As stated below, installing both gcompat and build-base solves the problem.

@altdsoy altdsoy changed the title Tailwindcss Standalone CLI not working in Alpine Linux (docker) TailwindCSS Standalone CLI not working in Alpine Linux (docker) Dec 22, 2021
@DistantMe
Copy link

@altdsoy I use Alpine (3.15) in a VM and the standalone binary works if I install gcompat, but I've tested in Docker and I can confirm your findings. Installing gcompat and libstdc++ gets me closer with less errors, but it still doesn't run.

@altdsoy
Copy link
Author

altdsoy commented Dec 28, 2021

Installing gcompat and libstdc++ gets me closer with less errors, but it still doesn't run.

@DistantMe I also noticed the same thing but still didn't find a solution. I wonder if it is possible to solve this in the Tailwind side, or does it need to be solved on the pkg side or even on the Alpine side?

@mveytsman
Copy link
Contributor

mveytsman commented Dec 28, 2021

@DistantMe does adding gcompat and build-base work for you?

I agree it would be great if tailwind could build this binary statically linked - I see the pkg docs say:

Note that fully static Node binaries are not capable of loading native bindings, so you may not use Node bindings with linuxstatic.

Not sure if this would affect this project?

@DistantMe
Copy link

DistantMe commented Dec 28, 2021

@DistantMe does adding gcompat and build-base work for you?

@mveytsman adding build-base did the trick, works perfectly after adding that (and gcompat) 😁 I didn't need libstdc++ by the looks of it.

@altdsoy, after taking the above into account, I ran the following as a test:

On Docker host: docker run -it --rm alpine ash

Inside Docker container:
apk add gcompat build-base
wget https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
chmod +x tailwindcss-linux-x64
./tailwindcss-linux-x64

... and the general help screen is displayed correctly.

@altdsoy
Copy link
Author

altdsoy commented Dec 28, 2021

@DistantMe, Indeed, as also stated by @mveytsman, for me gcompat and build-base solves the problem too!

I tried many different libraries (but rather in a random way).. I should have tried in a better way those two one together..
Anyway, thank you very much for your inputs..
Closing the issue..

@altdsoy altdsoy closed this as completed Dec 28, 2021
@mveytsman
Copy link
Contributor

I added a suggestion to switch to static builds here: #6785

@joshdoesthis
Copy link

Ran into the same issue with Alpine 3.20. Adding gcompat and build-base (as per above recommendations) has made tailwindcss-linux-arm64 work as expected.

FROM alpine:3.20
RUN apk add --no-cache curl gcompat build-base
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.4/tailwindcss-linux-arm64
RUN chmod +x tailwindcss-linux-arm64
RUN mv tailwindcss-linux-arm64 tailwindcss
ENTRYPOINT ["./tailwindcss"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants