diff --git a/.gitignore b/.gitignore index ad79fa3..51693a2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,11 @@ myice.ini schedule.json .envrc cookies.txt -# Byte-compiled / optimized / DLL files +# Tailwind CSS generated artifacts +style.css +tailwindcss + +# Python bytecode __pycache__/ *.py[cod] *$py.class diff --git a/AGENTS.md b/AGENTS.md index 285d3f6..abea3d3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,6 +48,21 @@ pre-commit run ruff-format --files myice/webapi.py pre-commit run mypy --files myice/myice.py ``` +### CSS/Frontend Build + +When modifying `index.html` or the Tailwind CSS setup: + +```bash +# One-off build of style.css +./build-css.sh + +# Watch mode for development +./build-css.sh --watch + +# Or manually with the standalone CLI (if already downloaded) +./tailwindcss -i ./style-input.css -o ./style.css --minify +``` + ### Running the Web API ```bash diff --git a/Dockerfile b/Dockerfile index a307c1d..6018273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,12 @@ FROM python:3.13-slim AS builder # Create working directory WORKDIR /app -# poetry export -f requirements.txt --output requirements.txt --without-hashes +# Install tools needed for Tailwind CSS build +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + && rm -rf /var/lib/apt/lists/* + # Copy dependency files COPY requirements.txt ./ @@ -12,6 +17,12 @@ COPY requirements.txt ./ RUN --mount=type=cache,target=/root/.cache/pip \ pip install --no-deps --disable-pip-version-check -r requirements.txt +# Build Tailwind CSS +COPY index.html style-input.css tailwind.config.js ./ +RUN curl -sL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/tailwindcss-linux-x64 -o tailwindcss \ + && chmod +x tailwindcss \ + && ./tailwindcss -i ./style-input.css -o ./style.css --minify + # Runtime stage FROM python:3.13-slim AS runtime @@ -29,8 +40,9 @@ RUN useradd --home-dir /app --no-create-home --uid 1000 myice # Copy installed packages from builder stage COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages -# Copy application code +# Copy application code and compiled assets COPY index.html favicon.ico ./ +COPY --from=builder /app/style.css ./style.css COPY myice ./myice # Change ownership of copied files diff --git a/build-css.sh b/build-css.sh new file mode 100755 index 0000000..b2260ab --- /dev/null +++ b/build-css.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -euo pipefail + +# Build CSS using Tailwind CSS standalone CLI +# For local development, run: +# ./build-css.sh # one-off build +# ./build-css.sh --watch # watch mode + +version="v3.4.17" +os="$(uname -s)" +arch="$(uname -m)" + +case "$os" in + Linux*) platform="linux";; + Darwin*) platform="macos";; + *) echo "Unsupported OS: $os"; exit 1;; +esac + +case "$arch" in + x86_64) arch="x64";; + arm64) arch="arm64";; + aarch64) arch="arm64";; + *) echo "Unsupported architecture: $arch"; exit 1;; +esac + +binary="tailwindcss-${platform}-${arch}" +url="https://github.com/tailwindlabs/tailwindcss/releases/download/${version}/${binary}" + +if [ ! -f "tailwindcss" ]; then + echo "Downloading Tailwind CSS standalone CLI (${version} ${platform}/${arch})..." + curl -sL "$url" -o tailwindcss + chmod +x tailwindcss +fi + +if [ "${1:-}" == "--watch" ]; then + echo "Building CSS in watch mode..." + ./tailwindcss -i ./style-input.css -o ./style.css --watch +else + echo "Building CSS..." + ./tailwindcss -i ./style-input.css -o ./style.css --minify +fi diff --git a/index.html b/index.html index e973b47..5c81b76 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@