esoul-cz / template-astro-cms
eSoul monorepo root of a static Astro site with a headless CMS: README, the contract, one NGINX site, and git submodules for the frontend and the backend.
Package info
github.com/eSoul-cz/template-astro-cms
Language:Shell
Type:project
pkg:composer/esoul-cz/template-astro-cms
Requires
None
Requires (Dev)
- esoul-cz/guidelines: ^0.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-23 18:18:31 UTC
README
Static website (Astro) with a headless CMS (Laravel + Filament). Editors work in the admin of the backend; the public site is a static build that is regenerated and deployed by the Publish button.
This repository is the thin monorepo of the project: shared documentation and tools, and two git submodules, each its own repository with its own pipeline. Nothing is built or deployed from here.
| Path | What |
|---|---|
frontend/ |
Submodule: the Astro 7 static site (created from the astro-cms-frontend template). Content comes from the CMS export at build time. |
backend/ |
Submodule: Laravel 13 + Filament 5, pages and site settings, the export API, the Publish button, the form endpoint (created from the laravel-cms template). |
docs/contract.md |
The contract between the halves (versioned, guarded by the golden export). |
docker/nginx.example |
One NGINX site definition for the site and the backend (backend on a subdomain; the path variant is commented). |
bin/add-submodules |
Adds the two repositories as submodules (composer submodules -- <frontend-url> <backend-url> does the same). |
Setup
- Create the two repositories from the templates (
composer create-project esoul-cz/template-astro-cms-frontendandcomposer create-project esoul-cz/template-laravel-cms, or the Packagist-less equivalent), push each to its own GitHub repository. - In this repository (
git initfirst):sh bin/add-submodules <frontend-repository-url> <backend-repository-url>, then commit.gitmodulesand the two pointers. Every other checkout runsgit submodule update --init --recursive. - Fill
CONTEXT.md(archetypeC-headless, where the backend lives, business time zone, tasking) and set up the two repositories as their own READMEs say.
The submodule pointers move when a half is released (git add frontend backend). A change to the contract is a pull request in each repository.
Where the backend lives
NGINX serves the frontend and the backend from one site definition (docker/nginx.example). The default, and the recommendation, is a
subdomain; a path of the site's domain is a documented exception for a project that is forced onto one hostname. Record the choice in
CONTEXT.md.
| Subdomain (default) | Path /admin (exception) |
|
|---|---|---|
| Admin URL | https://admin.example.com/admin |
https://example.com/admin |
| nginx | a site block (static + /_cms/) and an admin. block that routes /admin, /cms-api, /forms, /livewire-*, /up to php-fpm and serves /cms-media/, /_cms/ and the panel assets |
one block: the static site, the backend's own paths routed to php-fpm |
APP_URL (backend) |
https://admin.example.com |
https://example.com |
SESSION_DOMAIN / SESSION_PATH |
null / / (host-only cookie; never .example.com) |
null / /admin |
CMS_ADMIN_PATH_MODE (backend) |
false |
true: the Livewire update and upload routes move under /admin/livewire/ |
CMS_API_URL (frontend build) |
https://admin.example.com/cms-api/v1 |
https://example.com/cms-api/v1 |
CMS_FORMS_ALLOWED_ORIGINS |
https://example.com |
https://example.com |
- Why a subdomain: the admin session cookie is host-only and never reaches the public site, the admin has its own CSP and access rules (VPN or IP
allowlist on
admin.without touching the site), and the public site exposes no PHP routes. - Why the path variant needs more: a host-only cookie is sent with every request to the host, so on a path the cookie has to be scoped to the backend
(
SESSION_PATH=/admin). Livewire posts its updates and uploads outside/adminby default, and those would no longer carry the cookie;CMS_ADMIN_PATH_MODE=truemoves them under/admin. Test the admin login, a page save and an image upload after switching. - CORS is never needed: the static build fetches the export server-side and visitors' browsers only navigate (the form post is a navigation).
CMS_API_ALLOWED_IPShas to contain the build agent in both modes (see the setup checklist).- Switching later means changing nginx, the backend
.env,CMS_API_URLin the frontendJenkinsfileand the DNS record; the exported media URLs are relative (/_cms/<hash>).
Local development
# backend (see backend/README.md for the full setup) cd backend && composer install && cp .env.example .env && php artisan key:generate && php artisan migrate php artisan make:filament-user # admin at http://localhost:8080/admin # set CMS_EXPORT_TOKEN=<random string> in backend/.env # frontend cd frontend && pnpm install CMS_SOURCE=fixture pnpm dev # no backend needed # or against the running backend: CMS_API_URL=http://localhost:8080/cms-api/v1, CMS_API_TOKEN=<CMS_EXPORT_TOKEN>
After a backend change to the exporter: cd backend && GOLDEN_UPDATE=1 php artisan test --filter=GoldenExportTest, then cd ../frontend && pnpm contract:sync
(see docs/contract.md, "Golden export, golden copy and fixture").
Publish flow
editor ── Publish ─▶ StartPublishCommand ─▶ Jenkins job of the frontend (CMS_PUBLISH_ID=<id>) ─▶ Checks ─▶ image (FROM scratch, dist/) ─▶ Komodo stack
▲ (Filament) │ checks the export, │ │ GET /cms-api/v1/export │ deploy hook: releases/<id>, `current` switch
│ │ writes a `publishes` │ │ (bearer token, Zod-validated, ▼
│ │ row (queued) │ │ /_cms media HEAD-checked) web/current -> releases/<id>
└──── status ◀──── POST /cms-api/v1/publishes/<id>/status (callback, bearer token) ◀── `cms` callback of the frontend Jenkinsfile
- An editor saves pages and settings in Filament. Nothing is public yet: the Publish page shows "unpublished changes".
- Publish (
StartPublishCommand): refuses when a publish is already queued or running, when Jenkins is not configured, or when the export has problems (the same rules as the Zod schema). Otherwise it stores apublishesrow (queued) and calls{CMS_JENKINS_JOB_URL}/buildWithParameterswithCMS_PUBLISH_ID. - The frontend job fetches
GET /cms-api/v1/export(bearerCMS_EXPORT_TOKEN). While serving it, the backend copies every referenced image tostorage/app/cms-public/<sha256[0:20]>.<ext>; nginx serves it at/_cms/. The image build validates the export with Zod, HEAD-checks the media, builds, runspnpm verifyand the Komodo hook deploysdist/as a new release. In CI the build fails when the export is unreachable or invalid: it never falls back to the fixture or to old data. - The
finallyblock reports{result, buildUrl}toPOST /cms-api/v1/publishes/<id>/status(bearerCMS_JENKINS_CALLBACK_TOKEN).SUCCESSandUNSTABLEmean deployed. - The callback is best effort. Refresh status polls Jenkins (queue item, then build), and a publish without a result
after
CMS_PUBLISH_TIMEOUTminutes (default 30) is marked failed so the button cannot stay blocked. A late callback is still recorded, with a note.
Media: names are content addressed, so files are immutable and cacheable for a year. cms:prune-public-media (daily 03:30)
deletes files that no build of the last 7 days referenced. Rollback is redeploying the previous image of the frontend.
Setup checklist
- Backend
.env:CMS_EXPORT_TOKEN,CMS_JENKINS_JOB_URL(https://<jenkins>/job/<job>/job/main, the job of the frontend),CMS_JENKINS_USER,CMS_JENKINS_API_TOKEN,CMS_JENKINS_CALLBACK_TOKEN,CMS_API_ALLOWED_IPS, and for the formsCMS_FORMS_ALLOWED_ORIGINS,CMS_FORMS_RECIPIENTS,CMS_FORMS_RECAPTCHA_SECRET,TRUSTED_PROXIES. - Jenkins credentials (Secret Text) of the frontend job: the export token (=
CMS_EXPORT_TOKEN) and the callback token (=CMS_JENKINS_CALLBACK_TOKEN), named in itsJenkinsfile. CMS_API_ALLOWED_IPShas to contain the address of the build agent. The build fetches/cms-apiover the public URL, so a changed agent address makes the export (and so every publish) answer 403 until the list is updated. Record the address in the frontendREADME.md.- nginx:
docker/nginx.example. The static release root (web/current) and the backend directories (storage/app/cms-public,storage/app/cms-media,public/) must be readable by nginx. - Staging: build the frontend with
PUBLIC_NOINDEX=true(noindex meta,Disallow: /, no sitemap, nollms.txtentries) behind HTTP basic auth. Production leaves it unset.
Notes
- The content model is deliberately minimal (pages with heading / text / image blocks, one settings record). Extend the
exporter, the Zod schema,
Blocks.astro, the Markdown renderer anddocs/contract.mdtogether, in a pull request in each repository. - A site without a CMS needs only the
astro-statictemplate; if it needs a form it starts its small backend fromlaravel-cms. esoul-guidelines.jsonof this repository holds the layers for the shared documentation; each submodule has its own.- This repository has a
composer.jsonwithesoul-cz/guidelinesas a dev dependency:composer install, thenvendor/bin/esoul-guidelines sync(composer updateruns it) andvendor/bin/esoul-guidelines check. Nothing is built from here and it has no pipeline, so nothing checks it in CI; if you add one, runesoul-guidelines checkin it, e.g. in the Docker imagedocker run --rm -v "$PWD:/app" -w /app --user "$(id -u):$(id -g)" rg.fr-par.scw.cloud/testing-images/esoul-guidelines:0.3 check. The submodules have novendor/: their READMEs ("Guidelines") give three ways to run the command without PHP in the project (Composer global, the PHAR, Docker), and theirJenkinsfilerunscheckin the Docker image.