This is an example setup for using a Docker based development environment with a SilverStripe 5 CMS project, with Nginx and PHP-FPM.
This setup uses php:8.1-fpm
, nginx:latest
, mysql:8.0.20
as base images, and a self-signed certificate for the ssl
port, only to be used locally.
Assuming you have an already existing project
-
Copy the
docker-compose.yml
file and copy thedocker
directory to your project -
Generate a self-signed certificate:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 \ -nodes -keyout ./docker/nginx/nginx-selfsigned.key -out ./docker/nginx/nginx-selfsigned.crt -subj "/CN=example.com" \ -addext "subjectAltName=DNS:example.com,DNS:*.example.com,IP:10.0.0.1"
-
Run
docker compose build --progress plain
-
Run
docker compose up -d
-
Try to access
http://localhost:8000
and/orhttps://localhost:8000
Notes:
- In the
fpm-template.conf
, usetry_files $uri /index.php?q=$query_string;
instead oftry_files $uri $uri/ /index.php?q=$uri&$args;
as it might break the SilverStripe routing - The mysql server will store the data in the
./storage/db-data
- you might want to gitignore it - If you encounter problems with the GD extension, have a look at this troubleshooting guide