Skip to content
Open
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
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ module.exports = {
// This is actually because we don't have react in this project
react: { version: '18.2.0' },
},
rules: {
// tailwindcss@4 uses package.json exports which eslint-import-resolver-node doesn't support.
'import/no-unresolved': ['error', { ignore: ['^tailwindcss'] }],
},
};
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3.13
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.15.5' # keep in sync with pyproject.toml
rev: 'v0.15.15' # keep in sync with pyproject.toml
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
poetry.lock
)$
- repo: https://github.com/rtts/djhtml
rev: 3.0.10
rev: 3.0.11
hooks:
- id: djhtml
- repo: https://github.com/python-poetry/poetry
Expand Down
14 changes: 13 additions & 1 deletion .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ module.exports = {
'scss/at-rule-no-unknown': [
true,
{
ignoreAtRules: ['container'],
ignoreAtRules: [
'container',
'config',
'source',
'utility',
'theme',
],
},
],
'no-invalid-position-declaration': [
true,
{
ignoreAtRules: ['utility'],
},
],
'scss/dollar-variable-no-missing-interpolation': null,
Expand Down
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM node:24 AS frontend
FROM node:24-slim AS frontend-deps

# Make build & post-install scripts behave as if we were in a CI environment (e.g. for logging verbosity purposes).
ARG CI=true

WORKDIR /app

# Install front-end dependencies.
COPY package.json package-lock.json tsconfig.json webpack.config.js tailwind.config.js ./
RUN npm ci --no-optional --no-audit --progress=false
RUN npm ci --no-audit --progress=false

FROM frontend-deps AS frontend

# Compile static files
COPY ./tbx/ ./tbx/
Expand All @@ -17,7 +21,7 @@ RUN npm run build:prod
# all useful packages required for image manipulation out of the box. They
# however weight a lot, approx. up to 1.5GiB per built image.
# Pinned to a particlar version as requested by support team 6/10/25
FROM python:3.13-bookworm AS production
FROM python:3.13-trixie AS python-base

ARG POETRY_INSTALL_ARGS="--no-dev"

Expand Down Expand Up @@ -74,7 +78,10 @@ RUN python -m venv $VIRTUAL_ENV
COPY --chown=tbx pyproject.toml poetry.lock ./
RUN pip install --no-cache --upgrade pip && poetry install ${POETRY_INSTALL_ARGS} --no-root && rm -rf $HOME/.cache

COPY --chown=tbx --from=frontend ./tbx/static_compiled ./tbx/static_compiled

FROM python-base AS production

COPY --chown=tbx --from=frontend /app/tbx/static_compiled ./tbx/static_compiled

# Copy application code.
COPY --chown=tbx . .
Expand All @@ -94,8 +101,11 @@ COPY ./docker/bashrc.sh /home/tbx/.bashrc
# environment variable hence we don't specify a lot options below.
CMD ["gunicorn", "tbx.wsgi:application"]

# These steps won't be run on production
FROM production AS dev
# These steps won't be run on production.
# This stage branches from python-base (not production) so that local dev builds
# do not require the memory-intensive frontend webpack build — static files are
# served from the volume-mounted ./tbx directory at runtime anyway.
FROM python-base AS dev

# Swap user, so the following tasks can be run as root
USER root
Expand All @@ -108,14 +118,17 @@ RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-r
# Restore user
USER tbx

# Load shortcuts
COPY ./docker/bashrc.sh /home/tbx/.bashrc

# Install nvm and node/npm
ARG NVM_VERSION=0.40.3
COPY --chown=tbx .nvmrc ./
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash \
&& bash --login -c "nvm install --no-progress && nvm alias default $(nvm run --silent --version)"

# Pull in the node modules for the frontend
COPY --chown=tbx --from=frontend ./node_modules ./node_modules
# Pull in the node modules for the frontend (from deps-only stage, no build needed)
COPY --chown=tbx --from=frontend-deps /app/node_modules ./node_modules

# do nothing forever - exec commands elsewhere
CMD ["tail", "-f", "/dev/null"]
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ services:
- ./.stylelintrc.js:/app/.stylelintrc.js:rw
- ./package-lock.json:/app/package-lock.json:rw
- ./package.json:/app/package.json:rw
- ./tailwind.config.js:/app/tailwind.config.js:rw
- ./tsconfig.json:/app/tsconfig.json:rw
- ./webpack.config.js:/app/webpack.config.js:rw

depends_on:
Expand Down
34 changes: 34 additions & 0 deletions docs/custom-features/wagtail-ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Wagtail AI

AI-assisted content editing in the Wagtail admin, powered by [wagtail-ai](https://wagtail-ai.readthedocs.io/latest/).

## Configuration

The integration is always active but requires environment variables to function. The provider and model are both configurable at runtime.

| Variable | Required | Default | Description |
| --------------------- | -------------------- | -------------- | --------------------------------------------------------- |
| `WAGTAIL_AI_PROVIDER` | No | `openai` | [any-llm](https://docs.mozilla.ai/any-llm/) provider name |
| `WAGTAIL_AI_MODEL` | No | `gpt-4.1-mini` | Model identifier for the chosen provider |
| `OPENAI_API_KEY` | When using OpenAI | — | API key read directly by the OpenAI SDK |
| `ANTHROPIC_API_KEY` | When using Anthropic | — | API key read directly by the Anthropic SDK |

## Examples

**OpenAI (default):**

```
WAGTAIL_AI_PROVIDER=openai
WAGTAIL_AI_MODEL=gpt-4.1-mini
OPENAI_API_KEY=sk-...
```

**Anthropic:**

```
WAGTAIL_AI_PROVIDER=anthropic
WAGTAIL_AI_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_API_KEY=sk-ant-...
```

For a full list of supported providers and their model identifiers, see the [any-llm documentation](https://docs.mozilla.ai/any-llm/).
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ nav:
- 'Migration-friendly StreamFields': 'custom-features/migration-friendly-streamfields.md'
- 'Modes': 'custom-features/modes.md'
- 'Theme': 'custom-features/theme.md'
- 'Wagtail AI': 'custom-features/wagtail-ai.md'
- 'Continuous integration': 'continuous-integration.md'
- 'Anonymised data': 'anonymised-data.md'
- 'Data import': 'data-import.md'
Expand Down
Loading
Loading