Getting started
Docker deployment
The production image runs FrankenPHP (Caddy with PHP 8.4): it serves the site, gets the HTTPS certificate, compresses responses and caches the built assets and photos. The same image runs the worker.
Files
| File | What it is |
|---|---|
docker/production/Dockerfile | Three stages: Composer packages without dev tools, the asset build (with THEME when set), the runtime image. |
docker/production/Caddyfile | The site on SERVER_NAME, compression, a year of caching for /build and /uploads. |
docker/production/entrypoint.sh | Warms the cache, then starts the server or the worker. |
compose.prod.yaml | app (ports 80 and 443), worker, and database (MySQL 8, only with --profile database). |
.env.prod.dist | The variables to copy into .env.prod (never committed). |
Start
cp .env.prod.dist .env.prod # then fill it in
export SERVER_NAME=market.example.com
docker compose -f compose.prod.yaml --profile database up -d --build
docker compose -f compose.prod.yaml exec app php bin/console app:install
With a managed database, leave out --profile database and point DATABASE_URL at it.
Volumes
| Volume | Holds | Back up? |
|---|---|---|
uploads | Photos when storage is local | Yes, unless photos are on S3 |
database | MySQL data (bundled database) | Yes: docker compose -f compose.prod.yaml exec database mysqldump ... every night, or volume snapshots |
caddy_data | HTTPS certificates | Optional, they are renewed on their own |
A theme
THEME=acme docker compose -f compose.prod.yaml build
docker compose -f compose.prod.yaml up -d
Updating
git pull
docker compose -f compose.prod.yaml build
docker compose -f compose.prod.yaml up -d
docker compose -f compose.prod.yaml exec -e SKIP_BACKUP=1 app bin/update
Back up the database before the last command. up -d restarts the worker on the new image.
Logs
docker compose -f compose.prod.yaml logs -f app
docker compose -f compose.prod.yaml logs -f worker
The application writes JSON logs to var/log/prod.log inside the containers; set SENTRY_DSN to get errors reported.
Found a mistake? Tell us.