From 45eaeede5eb47c1c8e7e463b41561dacb88268aa Mon Sep 17 00:00:00 2001 From: Nadar Date: Mon, 29 Apr 2024 06:38:14 +0000 Subject: [PATCH] 5.0 constraint --- composer.json | 10 +++--- configs/config.php | 90 +++++++++++++++++++++++----------------------- deploy.php | 28 +++++---------- docker-compose.yml | 16 ++++++--- localphp.ini | 7 ++++ 5 files changed, 78 insertions(+), 73 deletions(-) create mode 100644 localphp.ini diff --git a/composer.json b/composer.json index ce79e2d..f78ad87 100644 --- a/composer.json +++ b/composer.json @@ -4,20 +4,20 @@ "type": "luya-kickstarter", "license":"MIT", "require": { - "luyadev/luya-module-admin" : "^4.0", - "luyadev/luya-module-cms" : "^4.0", + "luyadev/luya-module-admin" : "^5.0", + "luyadev/luya-module-cms" : "^5.0", "luyadev/luya-bootstrap4": "^1.0", "luyadev/luya-generic" : "^1.0" }, "require-dev": { "yiisoft/yii2-debug" : "^2.0", "yiisoft/yii2-gii" : "^2.0", - "luyadev/luya-deployer": "^1.0", + "luyadev/luya-deployer": "^3.0", "twbs/bootstrap": "^4.0" }, "config": { - "fxp-asset": { - "enabled": false + "platform": { + "php": "8.2" }, "allow-plugins": { "yiisoft/yii2-composer": true, diff --git a/configs/config.php b/configs/config.php index 4e2d5e9..f2ce525 100644 --- a/configs/config.php +++ b/configs/config.php @@ -69,55 +69,57 @@ ] ]); -$config->callback(function() { - define('YII_DEBUG', true); - define('YII_ENV', 'local'); -})->env(Config::ENV_LOCAL); +/************ LOCAL ************/ -// database config for -$config->component('db', [ - 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', - // 'dsn' => 'mysql:host=localhost;dbname=DB_NAME;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock', // OSX MAMP - // 'dsn' => 'mysql:host=localhost;dbname=DB_NAME;unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock', // OSX XAMPP - 'username' => '', - 'password' => '', -])->env(Config::ENV_LOCAL); +$config->env(Config::ENV_LOCAL, function (Config $config) { + $config->callback(function () { + define('YII_DEBUG', true); + define('YII_ENV', 'local'); + }); -/* -// docker mysql config -$config->component('db', [ - 'dsn' => 'mysql:host=luya_db;dbname=luya_kickstarter_101', - 'username' => 'luya', - 'password' => 'CHANGE_ME', -])->env(Config::ENV_LOCAL); -*/ + // docker mysql config + $config->component('db', [ + 'dsn' => 'mysql:host=luya_db;dbname=luya', + 'username' => 'luya', + 'password' => 'luya', + ]); + + $config->component('assetManager', [ + 'class' => 'luya\web\AssetManager', + 'linkAssets' => true + ]); + + // debug and gii on local env + $config->module('debug', [ + 'class' => 'yii\debug\Module', + 'allowedIPs' => ['*'], + ]); + $config->module('gii', [ + 'class' => 'yii\gii\Module', + 'allowedIPs' => ['*'], + ]); -$config->component('db', [ - 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', - 'username' => '', - 'password' => '', - 'enableSchemaCache' => true, - 'schemaCacheDuration' => 0, -])->env(Config::ENV_PROD); + $config->bootstrap(['debug', 'gii']); +}); -$config->component('cache', [ - 'class' => 'yii\caching\FileCache' -])->env(Config::ENV_PROD); +/************ PROD ************/ -$config->application([ - 'ensureSecureConnection' => true, // https://luya.io/guide/app-security -])->env(Config::ENV_PROD); +$config->env(Config::ENV_PROD, function (Config $config) { + $config->component('db', [ + 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', + 'username' => '', + 'password' => '', + 'enableSchemaCache' => true, + 'schemaCacheDuration' => 0, + ]); -// debug and gii on local env -$config->module('debug', [ - 'class' => 'yii\debug\Module', - 'allowedIPs' => ['*'], -])->env(Config::ENV_LOCAL); -$config->module('gii', [ - 'class' => 'yii\gii\Module', - 'allowedIPs' => ['*'], -])->env(Config::ENV_LOCAL); - -$config->bootstrap(['debug', 'gii'])->env(Config::ENV_LOCAL); + $config->component('cache', [ + 'class' => 'yii\caching\FileCache' + ]); + + $config->application([ + 'ensureSecureConnection' => true, // https://luya.io/guide/app-security + ]); +}); return $config; diff --git a/deploy.php b/deploy.php index 28db1ab..68a0814 100644 --- a/deploy.php +++ b/deploy.php @@ -1,26 +1,14 @@ user('username') - ->password('password') - ->stage('dev') - ->env('deploy_path', '/path/to/dev/project/public_html'); +require 'vendor/luyadev/luya-deployer/luya.php'; -// Preproduction environment -server('prep', 'server.tld', 22) - ->user('username') - ->password('password') - ->stage('prep') - ->env('deploy_path', '/path/to/prep/project/public_html'); +host('SSH_HOST') + ->setLabels(['stage' => 'prod']) + ->set('remote_user', 'SSH_USER_NAME') + ->set('deploy_path', '~/httpdocs'); -// Production environment -server('prod', 'server.tld', 22) - ->user('username') - ->password('password') - ->stage('prod') - ->env('deploy_path', '/path/to/prod/project/public_html'); +after('luya:commands', 'unglue'); -set('repository', 'https://user:password@github.com/organisation/repository.git'); +set('repository', 'https://USER:PASSWORD@github.com/VENDOR/REPO.git'); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 79d7962..21dd8c1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,12 @@ version: '3' services: + luya_composer: - image: composer:latest + image: composer volumes: - ./:/app command: composer install + luya_db: image: mysql:5.7 command: @@ -12,10 +14,16 @@ services: - --collation-server=utf8_general_ci environment: MYSQL_ROOT_PASSWORD: luya - MYSQL_DATABASE: luya_core + MYSQL_DATABASE: luya MYSQL_USER: luya MYSQL_PASSWORD: luya + ports: + - "3306:3306" + luya_web: - image: luyadev/luya-docker:nginx-fpm-php74 + image: registry.gitlab.com/zephir.ch/foss/luya-docker:php82 volumes: - - ./:/app + - ./localphp.ini:/etc/php82/conf.d/zzz_custom.ini + - ./:/var/www/html + healthcheck: + disable: true diff --git a/localphp.ini b/localphp.ini new file mode 100644 index 0000000..6af225f --- /dev/null +++ b/localphp.ini @@ -0,0 +1,7 @@ +[opcache] +opcache.validate_timestamps=1 +opcache.revalidate_freq=1 +[PHP] +display_errors = On +log_errors = On +error_reporting = E_ALL