Rearrange the mysql-variables

This commit is contained in:
Manuel Thalmann 2021-05-10 20:34:21 +00:00
parent 1ad03d1d41
commit 56d8a6af3d
3 changed files with 14 additions and 25 deletions

View file

@ -1,11 +1,7 @@
MYSQL_DATABASE=SilverStripe
MYSQL_ROOT_PASSWORD=root
SS_DATABASE_NAME=SilverStripe
SS_ENVIRONMENT_TYPE=dev
SS_BASE_URL=http://localhost
SS_DATABASE_CLASS=MySQLPDODatabase
SS_DATABASE_SERVER=db
SS_DEFAULT_ADMIN_USERNAME=root
SS_DEFAULT_ADMIN_PASSWORD=password
MYSQL_USER=silverstripe
SS_DATABASE_USERNAME=silverstripe
MYSQL_PASSWORD=Sup3rS3cr3tP@ssw0rd
SS_DATABASE_PASSWORD=Sup3rS3cr3tP@ssw0rd

View file

@ -4,6 +4,13 @@ services:
silverstripe:
image: manuth/silverstripe-dev
env_file: devcontainer.env
environment:
- SS_ENVIRONMENT_TYPE=dev
- SS_BASE_URL=http://localhost:8080
- SS_DATABASE_CLASS=MySQLPDODatabase
- SS_DATABASE_SERVER=db
- SS_DEFAULT_ADMIN_USERNAME=root
- SS_DEFAULT_ADMIN_PASSWORD=password
ports:
- 8080:80
- 3000:3000
@ -15,5 +22,7 @@ services:
db:
image: mysql:5
env_file: devcontainer.env
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
volumes:
- ./mysql-data:/var/lib/mysql

View file

@ -3,7 +3,6 @@
use SilverStripe\Control\HTTPApplication;
use SilverStripe\Control\HTTPRequestBuilder;
use SilverStripe\Core\CoreKernel;
use SilverStripe\Core\Environment;
// Find autoload.php
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
@ -16,21 +15,6 @@ if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
exit(1);
}
if (Environment::getEnv("SS_DATABASE_USERNAME") === false)
{
Environment::setEnv("SS_DATABASE_USERNAME", Environment::getEnv("MYSQL_USERNAME") ?: "root");
}
if (Environment::getEnv("SS_DATABASE_PASSWORD") === false)
{
Environment::setEnv("SS_DATABASE_PASSWORD", Environment::getEnv("MYSQL_PASSWORD") ?: Environment::getEnv("MYSQL_ROOT_PASSWORD"));
}
if (Environment::getEnv("SS_DATABASE_NAME") === false)
{
Environment::setEnv("SS_DATABASE_NAME", Environment::getEnv("MYSQL_DATABASE"));
}
// Build request and detect flush
$request = HTTPRequestBuilder::createFromEnvironment();