Skip to content

Commit a8e7f74

Browse files
committed
Update Dockerfile, add auto-build workflow, update README
- Rename TAILWIND_VERSION to TAILWINDCSS_VERSION for consistency- Add Watchman to get rid of bugging error - Improve container cleanup and signal handling- Update build arguments in Justfile - Add GitHub Actions workflow for auto-building Docker images - Add Justfile for build automation - Add docker-compose.yml for local development - Add initial input.css for examples
1 parent 7e64d40 commit a8e7f74

5 files changed

Lines changed: 107 additions & 45 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Auto Build TailwindCSS Image
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # daily at 00:00 UTC
6+
workflow_dispatch: # manual trigger via `Actions` tab
7+
8+
jobs:
9+
build-and-push-image:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
attestations: write
16+
id-token: write
17+
18+
steps:
19+
- name: Checkout repository (containing the Dockerfile)
20+
uses: actions/checkout@v4
21+
22+
- name: Authenticate with GHCR
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- id: get-latest-release
30+
name: Fetch latest TailwindCSS release
31+
uses: pozetroninc/github-action-get-latest-release@v0.8.0
32+
with:
33+
repository: tailwindlabs/tailwindcss
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v4
37+
with:
38+
context: .
39+
file: Dockerfile
40+
push: true
41+
tags: |
42+
ghcr.io/scriptogre/tailwindcss:latest
43+
ghcr.io/scriptogre/tailwindcss:${{ steps.get-latest-release.outputs.release }}
44+
build-args: |
45+
TAILWINDCSS_VERSION=${{ steps.get-latest-release.outputs.release }}

Dockerfile

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,50 @@
1-
# ─── Stage 1: Download Tailwind CLI ─────────────────────────
1+
# ─── Stage 1: Download TailwindCSS CLI ─────────────────────────
22
FROM curlimages/curl:latest AS downloader
33

4-
ARG TAILWIND_VERSION=4.1.5
4+
ARG TAILWINDCSS_VERSION
55
ARG TARGETPLATFORM
66
ARG TARGETVARIANT
77

8-
# Download TailwindCSS standalone CLI
8+
# Download TailwindCSS CLI
99
RUN set -eux; \
1010
platform="$TARGETPLATFORM"; \
1111
OS="${platform%/*}"; \
1212
ARCH="${platform#*/}"; \
1313
[ "$ARCH" = "amd64" ] && ARCH=x64; \
1414
[ "$ARCH" = "aarch64" ] && ARCH=arm64; \
15-
url="https://github.com/tailwindlabs/tailwindcss/releases/download/v${TAILWIND_VERSION}/tailwindcss-${OS}-${ARCH}${TARGETVARIANT}"; \
15+
url="https://github.com/tailwindlabs/tailwindcss/releases/download/v${TAILWINDCSS_VERSION}/tailwindcss-${OS}-${ARCH}${TARGETVARIANT}"; \
1616
curl -fSL -o /tmp/tailwindcss "$url"; \
1717
chmod +x /tmp/tailwindcss
1818

1919

2020
# ─── Stage 2: Final Image ───────────────────────────────────────────────
2121
FROM debian:bullseye-slim
2222

23-
ARG TAILWIND_VERSION=4.1.5
23+
ARG TAILWINDCSS_VERSION
2424

2525
# Image metadata
2626
LABEL org.opencontainers.image.title="Tailwind CSS CLI Docker Image"
2727
LABEL org.opencontainers.image.description="Minimal Docker image packaging the Tailwind CSS standalone CLI"
2828
LABEL org.opencontainers.image.documentation="https://github.com/scriptogre/tailwindcss-docker#readme"
2929
LABEL org.opencontainers.image.source="https://github.com/scriptogre/tailwindcss-docker"
3030
LABEL org.opencontainers.image.url="https://github.com/scriptogre/tailwindcss"
31-
LABEL org.opencontainers.image.version="${TAILWIND_VERSION}"
31+
LABEL org.opencontainers.image.version="${TAILWINDCSS_VERSION}"
3232
LABEL org.opencontainers.image.authors="scriptogre"
3333

34-
# Copy Tailwind CLI from `downloader` stage
34+
# Install Watchman
35+
RUN apt-get update && \
36+
apt-get install -y --no-install-recommends watchman && \
37+
rm -rf /var/lib/apt/lists/*
38+
39+
# Copy Tailwind CLI from `downloader`
3540
COPY --from=downloader /tmp/tailwindcss /usr/local/bin/tailwindcss
3641

37-
# Set /code as work dir (this is where user's files should be mounted)
38-
WORKDIR /code
42+
WORKDIR /app
3943

4044
ENTRYPOINT ["/usr/local/bin/tailwindcss"]
4145

46+
# Ensures container doesn't hang on CTRL+C (alternative is setting `stop_grace_period: 0` in `docker-compose.yml`)
47+
STOPSIGNAL SIGKILL
48+
4249
# Default to TailwindCSS CLI's help message
4350
CMD ["--help"]

Justfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rebuild release_version:
2+
docker build \
3+
--build-arg TAILWINDCSS_VERSION={{release_version}} \
4+
-t ghcr.io/scriptogre/tailwindcss:{{release_version}} \
5+
-t ghcr.io/scriptogre/tailwindcss:latest \
6+
.
7+
8+
push release_version:
9+
docker push ghcr.io/scriptogre/tailwindcss:{{release_version}}
10+
docker push ghcr.io/scriptogre/tailwindcss:latest

README.md

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1-
# TailwindCSS Docker Image
2-
3-
A minimal Docker image for the Tailwind CSS standalone CLI that bundles `tini` for proper signal forwarding.
4-
5-
## Usage Example
6-
7-
Pull and run the image:
8-
1+
# TailwindCSS Docker
2+
3+
A dead simple way to run [Tailwind CSS](https://tailwindcss.com/) from a Docker container.
4+
5+
No more **Node.JS**. No more **manual downloads of the CLI**.
6+
7+
1. Create `input.css` in your project:
8+
```css
9+
@import 'tailwindcss';
10+
```
11+
2. Create `docker-compose.yml` in your project:
12+
```yaml
13+
services:
14+
tailwindcss:
15+
# You can also use pinned versions, e.g. `:4.1.7`
16+
image: ghcr.io/scriptogre/tailwindcss:latest
17+
volumes:
18+
- .:/app
19+
command: -i ./input.css -o ./output.css --watch
20+
```
21+
22+
3. Or run `docker run` command:
923
```bash
10-
docker run \
11-
--init \
12-
--rm \
13-
--volume "$(pwd)":/code \
14-
ghcr.io/scriptogre/tailwindcss:latest \
15-
-i ./static/css/input.css \
16-
-o ./static/css/output.css \
17-
--watch=always
18-
```
19-
20-
Or with Docker Compose:
21-
22-
```yaml
23-
services:
24-
tailwindcss:
25-
image: ghcr.io/scriptogre/tailwindcss:latest
26-
volumes:
27-
- .:/code
28-
command: [
29-
"-i", "./static/css/input.css",
30-
"-o", "./static/css/output.css",
31-
"--watch=always"
32-
]
33-
init: true
24+
docker run \
25+
-v "$(pwd)":/app \
26+
ghcr.io/scriptogre/tailwindcss:latest \
27+
-i ./input.css -o ./output.css --watch
3428
```
3529

36-
## Notes
3730

38-
- The final image is based on `debian:bullseye-slim` and includes the `tailwindcss` CLI.
39-
- The container expects a bind mount from the host to `/code`, where your Tailwind CSS files are located.
40-
- Use `init: true` in docker-compose for proper signal handling.
31+
### **Notes:**
32+
- Make sure you mount all source files (`*.html`, `*.css`, `*.js`, …) to `/app`, so Tailwinds watcher can see them within the container.
33+
- The `ghcr.io/scriptogre/tailwindcss:latest` image is rebuilt daily to track the newest Tailwind CSS release.

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
tailwindcss:
3+
image: ghcr.io/scriptogre/tailwindcss:latest
4+
tty: true
5+
volumes:
6+
- .:/app
7+
command: ["-i", "./input.css", "-o", "./output.css", "--watch"]

0 commit comments

Comments
 (0)