Skip to content

Commit 7ba3f83

Browse files
committed
improve docker, config
FIX migrations (tested on pqsql)
1 parent fbfd28a commit 7ba3f83

File tree

12 files changed

+91
-44
lines changed

12 files changed

+91
-44
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ phpunit.phar
3535
/.vagrant
3636
/node_modules
3737
/mysql/data
38+
39+
.env

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ Please, [enable php intl extension](http://php.net/manual/en/intl.installation.p
1010

1111
Default, the template includes three tiers: `frontend`, `backend`, and `console`, each of which is a separate Yii application.
1212

13-
> **NOTE:** Template is in initial development. Anything may change at any time.
13+
> **NOTE:** Template is in initial development. Anything may change at any time.
1414
1515

1616
## Features
1717
* Gentelella Admin template is beautiful and simple bootstrap, compatible with yii2 assets: [yiister/yii2-gentelella](https://github.com/yiister/yii2-gentelella), [Demo](https://colorlib.com/polygon/gentelella/)
1818
* Yii2 User is strong and proved user-module with many features: [dektrium/yii2-user](https://github.com/dektrium/yii2-user) (login `adminus`, password `adminus`)
1919
* Frontend and Backend User Controllers are filtered (by `dektrium/yii2-user`)
20-
* DB cache, but I recommend Redis Cache - it is really fast
20+
* File or DB cache, but I recommend Redis Cache - it is really fast
2121
* Yii2 queue (DB table `queue`), but you can use *Redis-queue* or other [yii2-queue docs](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/README.md)
2222
* Queue Manager with backend (`/queuemanager/default/index`) using [ignatenkovnikita/yii2-queuemanager](https://github.com/ignatenkovnikita/yii2-queuemanager)
23-
* Log DB Target with backend (`/log/index`) - simply view log messages
23+
* Log DB Target with backend (`/log/index`) - simply view log messages
2424
* .htaccess - config for **pretty urls** (rewrite index.php), *may be later add nginx config*
2525
* **UrlManagerFrontend** for backend app (all url rules in file `frontend/config/urls.php`, hostInfo in `common/config/params.php`)
2626
* i18n translations in `common/messages` with config (current only English and Russian, language translation are welcome!)
2727
* ContactForm in frontend app is improved: [himiklab/yii2-recaptcha-widget](https://github.com/himiklab/yii2-recaptcha-widget),
2828
all email are saved to DB (`common/models/EmailForm` Model), optionally send message to Viber messenger via bot
2929
(install requirements [Bogdaan/viber-bot-php](https://github.com/Bogdaan/viber-bot-php) and config, uncomment code in Model)
3030
* **postcss** config (`frontend/web/src/pcss//*.css`)
31-
* Gii generator:
32-
1. added **yii2-queue** Jobs generator
31+
* Gii generator:
32+
1. added **yii2-queue** Jobs generator
3333
2. yii2 migration generator (from existing table) [Insolita/yii2-migrik](https://github.com/Insolita/yii2-migrik)
3434
3. [schmunk42/yii2-giiant](https://github.com/schmunk42/yii2-giiant) - really steroid, but in development with bugs
3535

@@ -97,14 +97,14 @@ Add your language in `common/messages/config.php`
9797
'ru-RU',
9898
],
9999
```
100-
In shell
100+
In shell
101101
```
102102
php yii message/extract common/messages/config.php
103103
```
104104

105105
**POSTCSS**
106106

107-
> **NOTE:** Dont forget install nodejs :) and run command `npm install` if you want use post locally
107+
> **NOTE:** Dont forget install nodejs :) and run command `npm install` if you want use postcss locally
108108
109109
Add WebStorm file-watcher, postcss.config.js is ready for use
110110
1. scope file[my-site]:frontend/web/src/pcss//*.css
@@ -128,4 +128,4 @@ I can apply patch, PR in 2-3 days! If not, please write me `akiraz@bk.ru`
128128
## Licensing
129129

130130
Yii2-App is released under the BSD License. See the bundled [LICENSE.md](LICENSE.md)
131-
for details.
131+
for details.

common/config/main.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
]*/
2424
],
2525
'cache' => [
26-
'class' => yii\caching\DbCache::class,
27-
'cacheTable' => '{{%cache}}',
26+
'class' => yii\caching\FileCache::class,
27+
// 'class' => yii\caching\DbCache::class,
28+
// 'cacheTable' => '{{%cache}}',
2829
/*'class' => \yii\redis\Cache::class,
2930
'redis' => [
3031
'hostname' => 'localhost',
@@ -64,15 +65,19 @@
6465
],
6566
],
6667
'queue' => [
67-
'class' => \yii\queue\db\Queue::class,
68-
'db' => 'db', // DB connection component or its config
69-
'tableName' => '{{%queue}}', // Table name
70-
'channel' => 'default', // Queue channel key
71-
'mutex' => \yii\mutex\MysqlMutex::class, // Mutex used to sync queries
72-
'as log' => \yii\queue\LogBehavior::class,
73-
'as quuemanager' => \ignatenkovnikita\queuemanager\behaviors\QueueManagerBehavior::class
74-
// Other driver options
68+
'class' => \yii\queue\sync\Queue::class,
69+
'handle' => false, // whether tasks should be executed immediately
7570
],
71+
// 'queue' => [
72+
// 'class' => \yii\queue\db\Queue::class,
73+
// 'db' => 'db', // DB connection component or its config
74+
// 'tableName' => '{{%queue}}', // Table name
75+
// 'channel' => 'default', // Queue channel key
76+
// 'mutex' => \yii\mutex\MysqlMutex::class, // Mutex used to sync queries
77+
// 'as log' => \yii\queue\LogBehavior::class,
78+
// 'as quuemanager' => \ignatenkovnikita\queuemanager\behaviors\QueueManagerBehavior::class
79+
// // Other driver options
80+
// ],
7681
],
7782
'modules' => [
7883
'user' => [

console/migrations/m180422_170849_create_email_form_table.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,13 @@
55
/**
66
* Handles the creation of table `email_form`.
77
*/
8-
class m180422_170849_create_email_form_table extends Migration
8+
class m180422_170849_create_email_form_table extends \dektrium\user\migrations\Migration
99
{
1010
/**
1111
* {@inheritdoc}
1212
*/
1313
public function safeUp()
1414
{
15-
$tableOptions = null;
16-
17-
if ($this->db->driverName === 'mysql') {
18-
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
19-
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
20-
}
21-
2215
$this->createTable('{{%email_form}}', [
2316
'id' => $this->primaryKey(),
2417
'user_id' => $this->integer(11),
@@ -32,7 +25,7 @@ public function safeUp()
3225
'created_at' => $this->timestamp(),
3326
'status_text' => $this->text(),
3427
'send_at' => $this->dateTime()
35-
], $tableOptions);
28+
], $this->tableOptions);
3629
}
3730

3831
/**

console/migrations/m180430_141650_cache.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use yii\db\Schema;
44
use yii\db\Migration;
55

6-
class m180430_141650_cache extends Migration
6+
class m180430_141650_cache extends \dektrium\user\migrations\Migration
77
{
88

99
public function init()
@@ -14,13 +14,11 @@ public function init()
1414

1515
public function safeUp()
1616
{
17-
$tableOptions = 'ENGINE=InnoDB';
18-
1917
$this->createTable('{{%cache}}',[
2018
'id'=> $this->char(128)->notNull(),
2119
'expire'=> $this->integer(11)->null()->defaultValue(null),
2220
'data'=> $this->binary()->null()->defaultValue(null),
23-
], $tableOptions);
21+
], $this->tableOptions);
2422

2523
$this->addPrimaryKey('pk_on_cache','{{%cache}}',['id']);
2624
}

docker-compose.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ services:
66
context: 'nginx'
77
ports:
88
- '8100:80'
9+
- '8200:81'
910
volumes:
1011
# Application testing
1112
- ./frontend/web:/app/frontend/web:delegated
13+
- ./backend/web:/app/backend/web:delegated
1214
php:
1315
build:
1416
dockerfile: Dockerfile-${DOCKERFILE_FLAVOUR}
@@ -26,13 +28,24 @@ services:
2628
- ~/.composer/cache:/root/.composer/cache:delegated
2729
links:
2830
- db
31+
# db:
32+
# image: mysql:5.7
33+
# environment:
34+
# MYSQL_ROOT_PASSWORD: root
35+
# MYSQL_USER: username
36+
# MYSQL_PASSWORD: password
37+
# MYSQL_DATABASE: yii2advanced
38+
# volumes:
39+
# - ./mysql/data:/var/lib/mysql
40+
# - ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
41+
2942
db:
30-
image: mysql:5.7
43+
image: postgres:13-alpine
3144
environment:
3245
MYSQL_ROOT_PASSWORD: root
33-
MYSQL_USER: username
34-
MYSQL_PASSWORD: password
35-
MYSQL_DATABASE: dbname
46+
POSTGRES_USER: username
47+
POSTGRES_PASSWORD: password
48+
POSTGRES_DB: yii2advanced
3649
volumes:
37-
- ./mysql/data:/var/lib/mysql
50+
- ./mysql/data:/var/lib/postgresql/data
3851
- ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

environments/dev/backend/config/main-local.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
$config['bootstrap'][] = 'debug';
1515
$config['modules']['debug'] = [
1616
'class' => 'yii\debug\Module',
17+
'allowedIPs' => ['*']
1718
];
1819

1920
$config['bootstrap'][] = 'gii';
2021
$config['modules']['gii'] = [
2122
'class' => 'yii\gii\Module',
23+
'allowedIPs' => ['*'],
2224
'generators' => [
2325
'job' => [
2426
'class' => \yii\queue\gii\Generator::class,

environments/dev/common/config/main-local.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
'components' => [
44
'db' => [
55
'class' => 'yii\db\Connection',
6-
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
7-
'username' => 'root',
8-
'password' => '',
6+
'dsn' => 'pgsql:host=db;dbname=yii2advanced',
7+
'username' => 'username',
8+
'password' => 'password',
99
'charset' => 'utf8',
1010
],
1111
'mailer' => [

environments/dev/frontend/config/main-local.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
$config['bootstrap'][] = 'debug';
1515
$config['modules']['debug'] = [
1616
'class' => 'yii\debug\Module',
17+
'allowedIPs' => ['*']
1718
];
1819

1920
$config['bootstrap'][] = 'gii';
2021
$config['modules']['gii'] = [
2122
'class' => 'yii\gii\Module',
23+
'allowedIPs' => ['*']
2224
];
2325
}
2426

nginx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM nginx
1+
FROM nginx:1.19-alpine
22
COPY nginx.conf /etc/nginx/nginx.conf

0 commit comments

Comments
 (0)