diff --git a/.env-dist b/.env-dist index 683a034..33bd18c 100644 --- a/.env-dist +++ b/.env-dist @@ -1,20 +1,56 @@ -# Основные параметры +# Параметры приложения +## Env приложения YII_DEBUG=true YII_ENV=dev + +## Параметры, отвечающие за безопасность JWT_USER_SECRET= + +## Внешние сервисы RECAPTCHA_PUBLIC= RECAPTCHA_SECRET= +## SMTP параметры +SMTP_USER= +SMTP_PASS= +SMTP_PORT= + +## Параметры подключения к базе данных +DB_HOST=db +DB_DATABASE=ely_accounts +DB_USER=ely_accounts_user +DB_PASSWORD=ely_accounts_password + +## Параметры подключения к redis +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_DATABASE=0 +REDIS_PASSWORD= + +## Параметры подключения к redis +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_DATABASE=0 +REDIS_PASS= + +## Параметры подключения к rabbitmq +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_USER=ely-accounts-app +RABBITMQ_PASS=ely-accounts-app-password +RABBITMQ_VHOST=/ely.by + +## Конфигурация для Dev. +XDEBUG_CONFIG=remote_host=10.254.254.254 +PHP_IDE_CONFIG=serverName=docker + + # Web VIRTUAL_HOST=account.ely.by,authserver.ely.by AUTHSERVER_HOST=authserver.ely.by # LETSENCRYPT_HOST=account.ely.by # LETSENCRYPT_EMAIL=erickskrauch@ely.by -# SMTP (только для production) -SMTP_USER= -SMTP_PASS= - # MySQL MYSQL_ALLOW_EMPTY_PASSWORD=yes MYSQL_ROOT_PASSWORD= @@ -26,7 +62,3 @@ MYSQL_PASSWORD=ely_accounts_password RABBITMQ_DEFAULT_USER=ely-accounts-app RABBITMQ_DEFAULT_PASS=ely-accounts-app-password RABBITMQ_DEFAULT_VHOST=/ely.by - -# Конфигурация для Dev. -XDEBUG_CONFIG=remote_host=10.254.254.254 -PHP_IDE_CONFIG=serverName=docker diff --git a/common/config/config-prod.php b/common/config/config-prod.php index 373f6ca..0160435 100644 --- a/common/config/config-prod.php +++ b/common/config/config-prod.php @@ -6,22 +6,5 @@ return [ 'schemaCacheDuration' => 3600, 'schemaCache' => 'cache', ], - 'mailer' => [ - 'useFileTransport' => false, - 'transport' => [ - 'class' => Swift_SmtpTransport::class, - 'host' => 'ely.by', - 'username' => getenv('SMTP_USER'), - 'password' => getenv('SMTP_PASS'), - 'port' => 587, - 'encryption' => 'tls', - 'streamOptions' => [ - 'ssl' => [ - 'allow_self_signed' => true, - 'verify_peer' => false, - ], - ], - ], - ], ], ]; diff --git a/common/config/config.php b/common/config/config.php index 262b2ec..ed68090 100644 --- a/common/config/config.php +++ b/common/config/config.php @@ -8,9 +8,9 @@ return [ ], 'db' => [ 'class' => yii\db\Connection::class, - 'dsn' => 'mysql:host=db;dbname=' . getenv('MYSQL_DATABASE'), - 'username' => getenv('MYSQL_USER'), - 'password' => getenv('MYSQL_PASSWORD'), + 'dsn' => 'mysql:host=' . (getenv('DB_HOST') ?: 'db') . ';dbname=' . getenv('DB_DATABASE'), + 'username' => getenv('DB_USER'), + 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8', 'schemaMap' => [ 'mysql' => common\db\mysql\Schema::class, @@ -19,24 +19,38 @@ return [ 'mailer' => [ 'class' => yii\swiftmailer\Mailer::class, 'viewPath' => '@common/mail', + 'transport' => [ + 'class' => Swift_SmtpTransport::class, + 'host' => 'ely.by', + 'username' => getenv('SMTP_USER'), + 'password' => getenv('SMTP_PASS'), + 'port' => getenv('SMTP_PORT') ?: 587, + 'encryption' => 'tls', + 'streamOptions' => [ + 'ssl' => [ + 'allow_self_signed' => true, + 'verify_peer' => false, + ], + ], + ], ], 'security' => [ 'passwordHashStrategy' => 'password_hash', ], 'redis' => [ 'class' => common\components\Redis\Connection::class, - 'hostname' => 'redis', - 'password' => null, - 'port' => 6379, - 'database' => 0, + 'hostname' => getenv('REDIS_HOST') ?: 'redis', + 'password' => getenv('REDIS_PASS') ?: null, + 'port' => getenv('REDIS_PORT') ?: 6379, + 'database' => getenv('REDIS_DATABASE') ?: 0, ], 'amqp' => [ 'class' => common\components\RabbitMQ\Component::class, - 'host' => 'rabbitmq', - 'port' => 5672, - 'user' => getenv('RABBITMQ_DEFAULT_USER'), - 'password' => getenv('RABBITMQ_DEFAULT_PASS'), - 'vhost' => getenv('RABBITMQ_DEFAULT_VHOST'), + 'host' => getenv('RABBITMQ_HOST') ?: 'rabbitmq', + 'port' => getenv('RABBITMQ_PORT') ?: 5672, + 'user' => getenv('RABBITMQ_USER'), + 'password' => getenv('RABBITMQ_PASS'), + 'vhost' => getenv('RABBITMQ_VHOST'), ], 'guzzle' => [ 'class' => GuzzleHttp\Client::class, diff --git a/tests/codeception/api/functional.suite.yml b/tests/codeception/api/functional.suite.yml index 232c933..5d52ea1 100644 --- a/tests/codeception/api/functional.suite.yml +++ b/tests/codeception/api/functional.suite.yml @@ -23,4 +23,4 @@ modules: username: 'ely-accounts-tester' password: 'tester-password' vhost: '/account.ely.by/tests' - queues: ['account-operations'] + queues: [] diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php index 3fbe89e..2904804 100644 --- a/tests/codeception/config/config.php +++ b/tests/codeception/config/config.php @@ -10,26 +10,9 @@ return [ ], ], 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=testdb;dbname=ely_accounts_test', - 'username' => 'ely_accounts_tester', - 'password' => 'ely_accounts_tester_password', - ], - 'mailer' => [ - 'useFileTransport' => true, - ], 'urlManager' => [ 'showScriptName' => true, ], - 'redis' => [ - 'hostname' => 'testredis', - ], - 'amqp' => [ - 'host' => 'testrabbit', - 'user' => 'ely-accounts-tester', - 'password' => 'tester-password', - 'vhost' => '/account.ely.by/tests', - ], 'security' => [ // Для тестов нам не сильно важна безопасность, а вот время прохождения тестов значительно сокращается 'passwordHashCost' => 4, diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 4c2d96d..a9e8054 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -11,16 +11,25 @@ services: - testredis - testrabbit volumes: - - ./codeception/_output:/var/www/html/tests/codeception/_output - - ./codeception/api/_output:/var/www/html/tests/codeception/api/_output - - ./codeception/common/_output:/var/www/html/tests/codeception/common/_output - - ./codeception/console/_output:/var/www/html/tests/codeception/console/_output + - ./..:/var/www/html environment: - - YII_DEBUG=true - - YII_ENV=test + YII_DEBUG: "true" + YII_ENV: "test" + # DB config + DB_HOST: "testdb" + DB_DATABASE: "ely_accounts_test" + DB_USER: "ely_accounts_tester" + DB_PASSWORD: "ely_accounts_tester_password" + # Redis config + REDIS_HOST: "testredis" + # RabbitMQ config + RABBITMQ_HOST: "testrabbit" + RABBITMQ_USER: "ely-accounts-tester" + RABBITMQ_PASS: "tester-password" + RABBITMQ_VHOST: "/account.ely.by/tests" # Это я потом, когда-нибудь, уберу - - XDEBUG_CONFIG=remote_host=10.254.254.254 - - PHP_IDE_CONFIG=serverName=docker + XDEBUG_CONFIG: "remote_host=10.254.254.254" + PHP_IDE_CONFIG: "serverName=docker" testdb: container_name: accountelyby_testdb