Silverstripe 5 on Docker with Nginx and PHP-FPM
If you need a quick jump start to setup a Docker based development environment for you Silverstripe project, there are a few options available
1) Have a look at the example setup I've uploaded to recon/silverstripe-5-docker-example
2) Have a look at brettt89's Dockerfiles
recon/silverstripe-5-docker-example
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
1) Copy the docker-compose.yml
file and copy the docker
directory to your project
2) 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"
```
3) Run docker compose build --progress plain
4) Run docker compose up -d
5) Try to access http://localhost:8000
and/or https://localhost:8443
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