From 2502f005e300d2284107e4cdd6fa9dd631769d1e Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Wed, 8 Jul 2026 14:14:01 +0200 Subject: [PATCH] fix(docker): Build Tailwind CSS in Docker image The /style.css route 500'd in production because style.css is gitignored and the Dockerfile never produced it: only main.py and templates/ were copied into the image. Mirror the myice Dockerfile by building the CSS in the builder stage: copy the tailwind input files, download the standalone Tailwind CLI (arch-aware for x64/arm64), and compile style.css. The artifact is then copied into the runtime stage. build-css.sh is kept for local dev but not used in Docker because its #!/bin/bash shebang and pipefail are incompatible with alpine's sh. --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4c3f984..923cc80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,18 @@ RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +# Build Tailwind CSS +COPY templates/index.html templates/index.html +COPY style-input.css tailwind.config.js ./ +RUN case "$(uname -m)" in \ + x86_64) arch="x64" ;; \ + aarch64|arm64) arch="arm64" ;; \ + *) echo "Unsupported architecture: $(uname -m)"; exit 1 ;; \ + esac \ + && curl -sL "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/tailwindcss-linux-${arch}" -o tailwindcss \ + && chmod +x tailwindcss \ + && ./tailwindcss -i ./style-input.css -o ./style.css --minify + ############################################# # Final stage ############################################# @@ -35,6 +47,7 @@ COPY --from=builder /usr/local/bin /usr/local/bin # Copy application files COPY main.py . COPY templates/ templates/ +COPY --from=builder /app/style.css ./style.css # Change ownership to non-root user RUN chown -R app:app /app