Skip to content

refactor(tailwind,build,ci,docker): drop local Tailwind build & Node toolchain #373

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

Merged
merged 3 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ updates:
dependency-type: "development"
update-types: ["minor", "patch"]

# ─── Node (npm) ───────────────────────────────
- package-ecosystem: "npm"
directory: "/"
schedule: { interval: "weekly" }
labels: [ "dependencies", "npm" ]
cooldown: # wait before opening PRs
semver-major-days: 30
semver-minor-days: 7
semver-patch-days: 3

# ─── GitHub Actions ───────────────────────────
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,3 @@ jobs:
- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}

frontend:
needs: test # Builds Tailwind CSS only if tests pass
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install Node deps
run: npm ci

- name: Build CSS
run: npm run build:css # Creates src/static/css/site.css

- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: static-css
path: src/static/css/site.css
41 changes: 3 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,36 @@ on:
permissions:
contents: read

# ── Build the Tailwind CSS bundle ───────────────────────────────
jobs:
frontend-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: package-lock.json

- name: Install deps + build Tailwind
run: |
npm ci
npm run build:css

- name: Upload built CSS
uses: actions/upload-artifact@v4
with:
name: frontend-assets
path: src/static/css/site.css
if-no-files-found: error

# ── Build wheel/sdist (needs CSS) and upload “dist/” ────────────
release-build:
needs: frontend-build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Grab site.css produced above
- uses: actions/download-artifact@v4
with:
name: frontend-assets
path: src/static/css/

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
cache-dependency-path: pyproject.toml

- name: Install build backend
- name: Build package
run: |
python -m pip install --upgrade pip
python -m pip install build twine
python -m build
twine check dist/*
- name: Upload dist artefact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

# ── Publish to PyPI (only if “dist/” succeeded) ─────────────────
# Publish to PyPI (only if “dist/” succeeded)
pypi-publish:
needs: release-build
runs-on: ubuntu-latest
environment: pypi # Creates the “pypi” environment in repo-settings
environment: pypi

permissions:
id-token: write # OIDC token for trusted publishing
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
push:
branches: [ main ]

permissions: read-all # Default for the whole workflow
permissions: read-all

concurrency: # (optional) avoid overlapping runs
concurrency: # avoid overlapping runs
group: scorecard-${{ github.ref }}
cancel-in-progress: true

Expand Down
34 changes: 1 addition & 33 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,7 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
Expand Down Expand Up @@ -158,21 +134,13 @@ dmypy.json
# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# VSCode
.vscode/settings.json
.DS_Store

# JavaScript tooling
node_modules/

# CSS
src/static/css/site.css

# Project specific
history.txt
cleanup.py
Expand Down
36 changes: 6 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ If you ever get stuck, reach out on [Discord](https://discord.com/invite/zerRaGK
## How to submit a Pull Request

> **Prerequisites**: The project uses **Python 3.9+** and `pre-commit` for development.
> If you plan to touch the frontend, you'll also need **Node ≥18** (for Tailwind).

1. **Fork** the repository.

Expand Down Expand Up @@ -63,22 +62,7 @@ If you ever get stuck, reach out on [Discord](https://discord.com/invite/zerRaGK
pre-commit run --all-files
```

9. **If you edited templates or CSS** rebuild Tailwind:

```bash
# one-time install
npm ci

# build once
npm run build:css

# or watch & rebuild on every save
npm run dev:css
```

*Skip this step if your PR only touches Python code.*

10. **Run the local server** to sanity-check:
9. **Run the local server** to sanity-check:

```bash
cd src
Expand All @@ -87,30 +71,22 @@ If you ever get stuck, reach out on [Discord](https://discord.com/invite/zerRaGK

Open [http://localhost:8000](http://localhost:8000) to confirm everything works.

11. **Commit** (signed):
10. **Commit** (signed):

```bash
git commit -S -m "Your commit message"
```

If *pre-commit* complains, fix the problems and repeat **610**.
If *pre-commit* complains, fix the problems and repeat **59**.

12. **Push** your branch:
11. **Push** your branch:

```bash
git push origin your-branch
```

13. **Open a pull request** on GitHub with a clear description.
12. **Open a pull request** on GitHub with a clear description.

14. **Iterate** on any review feedback—update your branch and repeat **6 – 13** as needed.
13. **Iterate** on any review feedback—update your branch and repeat **6 – 11** as needed.

*(Optional) Invite a maintainer to your branch for easier collaboration.*

---

## CSS & build artefacts

- **Do not commit `src/static/css/site.css`.** The CI pipeline runs `npm run build:css` during the container/image build, so the artefact is produced automatically.

- When developing locally you may run the build yourself (see step 9) so you can preview the styles.
54 changes: 18 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,60 +1,42 @@
# ---------- Stage 1: Build CSS with Node -------------------------
FROM node:20-alpine AS css-builder
WORKDIR /frontend

# Copy only files that affect the CSS build to leverage Docker cache
COPY package*.json ./
RUN npm ci

# Tailwind source --> final CSS
# (adjust the paths if you store Tailwind input elsewhere)
COPY tailwind.config.js ./ # Tailwind config
COPY src/static/css/ ./src/static/css/ # Tailwind input file(s)
RUN npm run build:css # writes ./src/static/css/site.css


# ---------- Stage 2: Install Python dependencies -----------------
FROM python:3.12-slim AS python-builder
# Stage 1: Install Python dependencies
FROM python:3.13-slim AS python-builder
WORKDIR /build

# System build tools first (so later layers are cached if unchanged)
# System build tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc python3-dev \
&& rm -rf /var/lib/apt/lists/*

# Python dependencies
# Metadata and code that setuptools needs
COPY pyproject.toml .
COPY src/ ./src/


# Install runtime dependencies defined in pyproject.toml
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir --timeout 1000 "."
&& pip install --no-cache-dir --timeout 1000 .


# ---------- Stage 3: Final runtime image -------------------------
FROM python:3.12-slim
# Stage 2: Runtime image
FROM python:3.13-slim
LABEL org.opencontainers.image.source="https://github.com/cyclotruc/gitingest"

# Minimal runtime utilities
RUN apt-get update \
&& apt-get install -y --no-install-recommends git curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
WORKDIR /app

# Create non-root user (uid 1000 == common default on Linux host)
RUN useradd -m -u 1000 appuser

# ── Copy Python site-packages & app code ───────────────────────────
COPY --from=python-builder /usr/local/lib/python3.12/site-packages/ \
/usr/local/lib/python3.12/site-packages/
COPY src/ ./

# ── Copy the freshly-built CSS ────────────────────────────────────
COPY --from=css-builder /frontend/src/static/css/site.css \
src/static/css/site.css
# Copy Python site-packages and code
COPY --from=python-builder /usr/local/lib/python3.13/site-packages/ \
/usr/local/lib/python3.13/site-packages/
COPY src/ ./src/

# Fix permissions
# Set permissions
RUN chown -R appuser:appuser /app
USER appuser

Expand Down
Loading
Loading