- PHP 86.9%
- CSS 3.9%
- Twig 3.1%
- Python 2.6%
- Shell 2.3%
- Other 1.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #29 |
||
| .ddev | ||
| .setup | ||
| config | ||
| deploy | ||
| docker | ||
| docs/superpowers | ||
| tests | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| .woodpecker.yml | ||
| composer.json | ||
| composer.lock | ||
| Dockerfile | ||
| LICENSE | ||
| phpunit.xml | ||
| README.md | ||
| renovate.json | ||
filmclub.brussels
The website of the filmclub: planned and past screenings, attendance, leden and their Letterboxd profiles. Drupal 11 on PHP 8.4 and MariaDB, developed with DDEV.
| Branch | Deploys to |
|---|---|
staging |
https://staging.filmclub.brussels |
main |
https://filmclub.brussels |
Work on staging. A release is a merge of staging into main.
Getting started
git clone ssh://git@git.m44.be:2222/bdu/filmclub.git && cd filmclub
git switch staging
cp .setup/settings.local.php.example web/sites/default/settings.local.php
printf 'ANTHROPIC_API_KEY=\nTMDB_API_KEY=\n' > .ddev/.env # optional keys
ddev start
ddev composer install
Then get a database, either a restore of prod or an empty site.
Restore of prod (the usual way). Images load from prod through
stage_file_proxy (settings.local.php).
ssh <vps> docker exec filmclub-drupal-prod drush sql:dump > prod.sql
ddev import-db --file=prod.sql
ddev drush cim -y && ddev drush uli
The dump contains the real email addresses of leden. Keep it out of git and
delete it when you are done. A restore of staging works the same way
(filmclub-drupal-staging).
Empty site, with no films or leden:
ddev drush site:install --existing-config --account-name=bdu -y
for po in web/modules/custom/*/translations/*.po \
web/themes/custom/filmclub/translations/*.po; do
ddev drush locale:import nl "/var/www/html/$po" \
--type=not-customized --override=not-customized
done
ddev drush php:script .setup/seed-content.php
ddev drush uli
The keys in .ddev/.env are only needed for AI summaries and TMDB lookups.
Working on it
Test before you push. CI only checks that the PHP parses; the suites run
here. Add --filter ListRenderTest to run one class.
ddev exec vendor/bin/phpunit -c phpunit.xml web/modules/custom # slow
python3 -m pytest web/themes/custom/filmclub/tests tests -q
Config lives in config/sync. Change it in the UI, then run
ddev drush cex -y and commit. Check git diff config/sync first: importing
translations can change block labels in the database, and those should not
end up in a commit. Local-only modules (stage_file_proxy, potx) are in the
local config split, switched on by settings.local.php.
Text. Code strings are English. The Dutch translations sit next to the
code in translations/*.nl.po; add new strings there. The site's default
language is Dutch.
Secrets never go into git or config. API keys come from environment
variables: .ddev/.env here, Woodpecker secrets on the server.
Where things are
Custom modules are in web/modules/custom/:
| Module | What |
|---|---|
filmclub_core |
Films, screenings, attendance, leden, homepage |
filmclub_ai |
TMDB, AI summaries, /plannen |
| Path | What |
|---|---|
web/themes/custom/filmclub |
Theme: cards, screenings, light, dark |
config/sync |
Drupal configuration |
.setup/ |
Seed and setup scripts |
Dockerfile, docker/ |
The image and docker/deploy.sh |
deploy/ |
Compose files, the pull script, tests |
The film lists (/gepland with the proposals, /archief) and the next films
on the homepage are the view films. Its templates are in the theme
(views-view--films*.html.twig).
Dependency updates
Renovate (self-hosted on the VPS, see renovate.json) opens pull requests
against staging for Composer packages and the base image. Drupal core is one
grouped pull request, and major versions wait for approval in the dependency
dashboard. renovate.json is read from main, so it only works once a release
has put it there.
A green pull request only means the image builds. Before merging one, run it
here, because an update can change active configuration and cim on deploy
would import the old config/sync over that change:
git fetch && git switch renovate/<branch> && ddev composer install
ddev drush updatedb -y && ddev drush cex -y # then read git diff config/sync
ddev exec vendor/bin/phpunit -c phpunit.xml web/modules/custom
Commit any config change to the same branch, merge into staging, check
staging, then release to main as usual.
Deploying
Woodpecker (.woodpecker.yml) runs on the VPS for every push to staging or
main:
- Build: builds the image
filmclub/drupal:stagingorfilmclub/drupal:prodand lints the custom PHP inside it. - Deploy: starts the stack and runs
docker/deploy.sh staging|prodin the container.- Every deploy runs
updatedb,cimand the translations. It never touches content. - Both environments refuse an empty database: restore a prod dump into a new one first.
- Every deploy runs
deploy/test-deploy-guard.sh checks this behaviour against the real script in
the image with a stub drush (needs Docker). deploy/test-pull-script.sh tests
the guards of the pull script.
| Staging | Prod | |
|---|---|---|
| Stack | /opt/stacks/filmclub-staging |
/opt/stacks/filmclub-brussels |
| Container | filmclub-drupal-staging |
filmclub-drupal-prod |
| Files | /opt/sites/filmclub/{files,private}_staging |
/opt/sites/filmclub/{files,private} |
| Secrets | FILMCLUB_STAGING_* |
FILMCLUB_PROD_* |
Woodpecker secrets: both sets have …_DB_NAME, …_DB_USER,
…_DB_PASSWORD and …_HASH_SALT (openssl rand -base64 55). The shared
secrets are ANTHROPIC_API_KEY and TMDB_API_KEY.
Databases are on the shared MariaDB: host mariadb on
shared_internal_net. Each user needs all rights on its own database. The
files_* and private_* folders are created by hand.
Copying data: deploy/pull-prod-to-staging.sh refreshes staging from prod:
the database, files and private files. Staging can then send mail to the real
addresses of leden, so use it with care. Redeploy staging afterwards.
Useful commands on the VPS (S is the container):
S=filmclub-drupal-prod # or filmclub-drupal-staging
docker exec $S drush uli --uri=https://filmclub.brussels --name=bdu
Hosting
visitor ─▶ filmclub.brussels ─────────▶ Pangolin ─▶ drupal-prod
tester ─▶ staging.filmclub.brussels ─▶ Pangolin ─▶ drupal-staging
(VPS 49.12.98.181)
- Pangolin (pangolin.m44.be) routes the hostnames to the containers on port 80 and terminates TLS. The Traefik labels in the compose files are not used for routing.
- DNS is on Bunny:
@,wwwandstagingare A records to the VPS. - Caching: no CDN. Drupal's page cache serves anonymous pages; browsers
keep them for 5 minutes (
page.max_ageinsystem.performance). - Staging sends
X-Robots-Tag: noindex. - Mail: only prod sends, from the site address (
noreply@filmclub.brussels, the site email inconfig/sync), through the shared Postfix relay to Brevo. The address must be a sender in Brevo, andfilmclub.brusselsmust be in Postfix'sALLOWED_SENDER_DOMAINS. Staging and local containers only collect mail in Drupal's state, so a restored copy of prod can never email leden. - Analytics: Umami (umami.m44.be), proxied by the container's nginx under
/umami/, so it is first-party.