A pre-configured environment that allows serving any SilverStripe 3 website inside a Docker container by following a few simple steps.
- Docker >= 17.12.0-ce
- Docker Compose >= 1.14.0
Refer to their official documentation on how to install Docker Engine and Docker Compose.
- Copy the content of the root directory of the SilverStripe 3 project to the
./app
folder or create a symbolic link to it. - Adjust the project's file and folders permissions:
$ cd ./app $ sudo chmod 666 .htaccess mysite/_config.php mysite/_config/config.yml $ sudo chmod 777 assets mysite
- In
./app/mysite/_config/
edit all the the config files according to your preferences - In
./app/mysite/_config.php
adjust database configurations to match the configurations in./config/_ss_environment.php
- Start the Docker Compose service
- Visit localhost/dev/build/?flush
- Visit localhost/admin
- Go to security tab and create a new admin user
$ docker-compose up
The website will then be available at http://localhost.
Mailcatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface.
If you want the local mailcatcher service to catch emails sent by the containerized SilverStripe 3 website, you must change its STMP configuration to
server: mailcatcher
port: 1025
Example app/mysite/_config/smtp.yml
:
---
Name: mysmtp
After: mysite
---
SmtpMailer:
conf:
default_from:
name: Sender Name
email: sender@example.com
charset_encoding: utf-8
server: mailcatcher
port: 1025
debug: 1
lang: pt_BR
By running the command in Serve a local mailcatcher server will automatically be started together with the website server.
Check out http://localhost:1080 to see the email captured by mailcatcher.
To run either the following commands, the app's docker container must be up.
$ docker-compose exec app tail -f /var/log/apache2/access.log
$ docker-compose exec app tail -f /var/log/apache2/error.log
Replace the [database name]
in the following commands by the name of the
database you configured in the ./app/mysite/_config.php
file.
$ docker-compose run --rm app /bin/bash -c 'mysqldump -u root -h localhost [database name] > /var/www/app/dump.sql'
$ docker run --rm [container name] /bin/bash -c 'cat /var/www/app/dump.sql | mysql -u root -D [database name]'