Kaffedrengen.dk — Project Documentation¶
WordPress/WooCommerce coffee subscription site built on Roots Bedrock.
Docker is used for local development only and is not part of the production setup.
Stack¶
- WordPress (Bedrock) — PHP, Composer-managed plugins
- WooCommerce + WooCommerce Subscriptions
- Frontend — Vue 2, Tailwind CSS, Bulma, Webpack (Laravel Mix)
- Docker — PHP-FPM, nginx, MariaDB, Redis
Repository structure¶
.
├── devops/ # Docker configs per environment (local, dev, prod)
│ └── local.example/ # Copy this to devops/local/ for local overrides
├── docs/ # Project documentation
├── site/ # Roots Bedrock WordPress installation
│ ├── config/ # WordPress and environment configuration
│ │ └── environments/# Per-environment PHP config (development, staging, production)
│ ├── customizations/ # Custom MU-plugin
│ ├── src/ # Frontend source (JS, SCSS, images)
│ ├── web/ # Document root served by nginx
│ │ ├── app/ # wp-content equivalent (plugins, themes, uploads)
│ │ └── wp/ # WordPress core (managed by Composer)
│ ├── composer.json
│ └── package.json
├── system/ # Runtime volumes (logs, releases, uploads) — git-ignored
├── docker-compose.yml
└── .env.example # Docker environment template
Local setup¶
Prerequisites¶
- Docker and Docker Compose
- SSH key with access to the Bitbucket repository
- SSH key with access to
packagist.barberklingen.dk(private Composer registry)
Verify your Docker installation:
1. Clone the repository¶
git clone git@bitbucket.org:barberklingen-wordpress/kaffedrengen-dk-bedrock.git
cd kaffedrengen-dk-bedrock
2. Configure the Docker environment¶
Edit .env and set values appropriate for your machine (container names, ports, etc.).
3. Copy the devops local config¶
Adjust the nginx, PHP, and MySQL configs inside devops/local/ if needed.
4. Configure the WordPress environment¶
Edit site/.env and fill in at minimum:
| Variable | Description |
|---|---|
DB_NAME | Database name |
DB_USER / DB_PASSWORD | Database credentials |
DB_HOST | MariaDB container name (matches the container name set in .env) |
WP_HOME | Site URL (e.g. http://localhost:8080) |
WP_SITEURL | ${WP_HOME}/wp |
AUTH_KEY … NONCE_SALT | Generate at roots.io/salts |
5. Start the containers¶
6. Install PHP dependencies¶
Run Composer inside the PHP container:
docker exec -it <php-container-name> bash -c "cd /var/www/<project>/releases/current && composer install"
Or locally if you have PHP and Composer installed and SSH access to the private registry:
setasign/fpdi_pdf-parser (used by the shipping package for labels) is a licensed download from Setasign. Give Composer the token once, wherever you run it:
7. Access the site¶
Open the URL you set for WP_HOME in your browser. The WordPress admin is at WP_HOME/wp/wp-admin.
Deployment¶
Deploys run through the "Deploy Bedrock" GitHub Actions workflow (or subscribed deploy kddk). On the server the deployment script copies devops/<env>/php/php-entrypoint.sh into the new release and runs it inside the PHP container before the release is symlinked live. The entrypoint:
- Runs
composer installand builds the theme.SETASIGN_TOKENmust be set in the server's.envfor the Setasign package - Runs
wp core update-db - Runs
wp barberklingen database migrate, which applies the site's own migrations and then firesbarberklingen/migrations/completedso every package (Payments Hub, cancellation-reasons, base-plugin roles) applies its pending migrations too
A failed migration aborts the deploy and leaves current on the previous release.
The command is registered under both barberklingen and kaffedrengen, so wp kaffedrengen database migrate still works. New scripts should use the barberklingen name, which is the same on every brand.
Deploy keys¶
php-entrypoint.sh reads SETASIGN_TOKEN, ELEMENTOR_EMAIL and ELEMENTOR_LICENSE from the project root .env on every deploy. The project root is mounted read-only in the php container at /run/project. To add or change one of these keys, edit the root .env and run the deploy. You don't need to recreate the container. To revoke a key, set it to an empty value (SETASIGN_TOKEN=). The deploy then removes the stored Composer login. Clearing ELEMENTOR_EMAIL or ELEMENTOR_LICENSE stops the deploy, because nothing is installed without them, so the live release stays untouched.
The keys are only used for the Composer config during the deploy. WordPress loads its settings the same way as before.
Recreating the php container¶
The releases live in system/releases and survive a recreate. The current symlink lives inside the container and does not. When php or nginx starts without one, devops/restore-current.sh points current at the newest release where php-entrypoint.sh ran to the end. The entrypoint marks such a release with .release-complete. While a deploy is running, the release has .release-incomplete, so a release whose deploy failed is skipped, also by the fallback. Releases from before the marker existed fall back to the newest one that has vendor/ and WordPress core. The site keeps running on the last good release until the next deploy.
docker compose up -d --force-recreate php
docker compose exec nginx nginx -s reload # nginx looks up the new php container's IP
docker compose exec php readlink /var/www/kaffedrengen/current # shows which release is live
Only php has to be recreated. nginx resolves the php hostname once at startup, so it needs a reload (no downtime), not a recreate. php-entrypoint.sh is built into the image, so changes to it need --build on the recreate.
The first time you recreate php after this change, mark the live release first. Run this while php still has its current symlink. Then a newer release that failed after Composer can't be picked by the fallback:
docker compose exec php sh -c 'touch "$(readlink -f /var/www/kaffedrengen/current)/.release-complete"'
Frontend development¶
All frontend source lives in site/src/. Assets are compiled with Webpack via Laravel Mix.
cd site
npm install
# Watch for changes during development
npm run watch
# Production build
npm run build
The admin apps in the plugin (the label overlay) have their own build. Their bundles are committed, so rebuild and commit them after changing site/src/js/admin: