Basic template of docker-compose.yml for Yii2 advanced
-
Make the necessary changes to
env.example, it is usually enough to changeAPP_NAME. -
Rename
env.exampleto.env. -
Change the database connection configuration in the file
common/config/main-local.phporenvironments/dev/common/config/main-local.php:
... 'components' => [ 'db' => [ 'class' => \yii\db\Connection::class, 'dsn' => 'mysql:host=mysql;dbname=app-db', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8mb4', ], 'mailer' => [ 'class' => \yii\symfonymailer\Mailer::class, 'viewPath' => '@common/mail', 'useFileTransport' => false, 'transport' => [ 'dsn' => 'smtp://mailcatcher:1025', ], ], ...- Run docker compose:
docker compose -f docker-compose.yml -p {APP_NAME} -d- Available domains
- http://{APP_NAME}.localhost - frontend
- http://admin.{APP_NAME}.localhost - backend
- http://pma.{APP_NAME}.localhost - phpMyAdmin
- http://mail.{APP_NAME}.localhost - MailCatcher