Unable to install Tailwind during Docker build

Hello, folks!

I’m trying to build tailwind styles into an output.css file during docker build, and the installation of the standalone tailwind seems not working. Here are the logs:

Step 7/17 : RUN make tailwind-build
 ---> Running in 6a3cea6aa7f7
tailwindcss -i ./static/css/styles.css -o ./static/css/output.css --minify
make: tailwindcss: No such file or directory
make: *** [Makefile:5: tailwind-build] Error 127
The command '/bin/sh -c make tailwind-build' returned a non-zero code: 2

Also find here some debug commands I added then to Dockerfile:

#16 [builder  7/16] RUN which tailwindcss
#16 0.049 /usr/local/bin/tailwindcss
#16 DONE 0.1s
#17 [builder  8/16] RUN ls -l /usr/local/bin/tailwindcss
#17 0.046 -rwxr-xr-x    1 root     root     135401489 Feb  8 14:09 /usr/local/bin/tailwindcss
#17 DONE 0.1s
#18 [builder  9/16] RUN echo /go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#18 0.043 /go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#18 DONE 0.1s
#19 [builder 10/16] RUN /usr/local/bin/tailwindcss --version
#19 0.045 /bin/sh: /usr/local/bin/tailwindcss: not found

The Dokckerfile itself can be found here: discogs-spotify/Dockerfile at main · martiriera/discogs-spotify · GitHub

I tried to build it locally, and it’s working, but somehow it breaks on Koyeb.

Thanks in advance.

Hi, I’m not exactly sure what’s going on here, but I have two suggestions.

  1. Try using golang:1.23-bullseye as base image instead of alpine.

  2. Use a multi-stage build to install tailwind with a node package manager.

FROM node:20-slim AS tailwind-builder

WORKDIR /app

COPY ./package.json ./package-lock.json ./styles.css /app
RUN npm install
RUN npx @tailwindcss/cli -i ./styles.css -o ./styles-compiled.css

FROM golang:1.23-alpine AS builder

COPY --from=tailwind-builder /app/styles-compiled.css /app/styles.css

# ...

Hey @nils, thanks for answering, mate!

Bullseye made the job. I will try the other solution if I need a lighter image. Thanks again.