Skip to content

Commit 9be11da

Browse files
committed
improve docker
1 parent 7ba3f83 commit 9be11da

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
Yii2-app is Fast and Ready-to-production advanced project template.
44

5-
Dockerized, for development- mysql, nginx, php-fpm containers
6-
7-
For you, I downgrade requirement to PHP v5.6. But **PHP 7.1** is better! because it is really fast.
5+
Dockerized, for development (mysql, nginx, php-fpm)
86

97
Please, [enable php intl extension](http://php.net/manual/en/intl.installation.php) for better work.
108

@@ -27,7 +25,6 @@ Default, the template includes three tiers: `frontend`, `backend`, and `console`
2725
* ContactForm in frontend app is improved: [himiklab/yii2-recaptcha-widget](https://github.com/himiklab/yii2-recaptcha-widget),
2826
all email are saved to DB (`common/models/EmailForm` Model), optionally send message to Viber messenger via bot
2927
(install requirements [Bogdaan/viber-bot-php](https://github.com/Bogdaan/viber-bot-php) and config, uncomment code in Model)
30-
* **postcss** config (`frontend/web/src/pcss//*.css`)
3128
* Gii generator:
3229
1. added **yii2-queue** Jobs generator
3330
2. yii2 migration generator (from existing table) [Insolita/yii2-migrik](https://github.com/Insolita/yii2-migrik)
@@ -62,11 +59,13 @@ docker run --rm --interactive --tty \
6259
--volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp \
6360
composer create-project --prefer-dist akiraz2/yii2-app my-site
6461
```
65-
2. copy `/mysql/docker-entrypoint-initdb.d/createdb.sql.example` to `createdb.sql`, then edit this file (database, user) from `docker-compose.yml` section db (MYSQL_USER: username, MYSQL_PASSWORD: password, MYSQL_DATABASE: dbname)
62+
2. copy `/mysql/docker-entrypoint-initdb.d/createdb.sql.example` to `createdb.sql` if you have ready DB
6663
3. `docker-compose build`
6764
4. `docker-compose up -d`
6865
5. `docker-compose exec php bash`, in terminal run `php init`, then run other migrations (see next)
69-
6. open localhost:8100 to test
66+
6. open localhost:8100 to test (backend on localhost:8200)
67+
68+
Access to Console App: `docker-compose exec php bash` and `php yii mycommand/action`
7069

7170
### Migrations
7271

@@ -102,16 +101,6 @@ In shell
102101
php yii message/extract common/messages/config.php
103102
```
104103

105-
**POSTCSS**
106-
107-
> **NOTE:** Dont forget install nodejs :) and run command `npm install` if you want use postcss locally
108-
109-
Add WebStorm file-watcher, postcss.config.js is ready for use
110-
1. scope file[my-site]:frontend/web/src/pcss//*.css
111-
2. program C:\Users\user4957\AppData\Roaming\npm\postcss.cmd
112-
3. arguments $ContentRoot$\frontend\web\css\style.css --config $ContentRoot$\post.config.js
113-
114-
115104
## Support
116105

117106
If you have any questions or problems with Yii2-App you can ask them directly

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"minimum-stability": "stable",
1212
"require": {
13-
"php": ">=5.6.0",
13+
"php": ">=7.0.0",
1414
"yiisoft/yii2": "~2.0.14",
1515
"yiisoft/yii2-bootstrap": "~2.0.0",
1616
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",

docker-compose.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
# Application testing
1212
- ./frontend/web:/app/frontend/web:delegated
1313
- ./backend/web:/app/backend/web:delegated
14+
links:
15+
- php
1416
php:
1517
build:
1618
dockerfile: Dockerfile-${DOCKERFILE_FLAVOUR}
@@ -28,24 +30,24 @@ services:
2830
- ~/.composer/cache:/root/.composer/cache:delegated
2931
links:
3032
- 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-
4233
db:
43-
image: postgres:13-alpine
34+
image: mysql:5.7
4435
environment:
4536
MYSQL_ROOT_PASSWORD: root
46-
POSTGRES_USER: username
47-
POSTGRES_PASSWORD: password
48-
POSTGRES_DB: yii2advanced
37+
MYSQL_USER: username
38+
MYSQL_PASSWORD: password
39+
MYSQL_DATABASE: yii2advanced
4940
volumes:
50-
- ./mysql/data:/var/lib/postgresql/data
41+
- ./mysql/data:/var/lib/mysql
5142
- ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
43+
44+
# db:
45+
# image: postgres:13-alpine
46+
# environment:
47+
# MYSQL_ROOT_PASSWORD: root
48+
# POSTGRES_USER: username
49+
# POSTGRES_PASSWORD: password
50+
# POSTGRES_DB: yii2advanced
51+
# volumes:
52+
# - ./mysql/data:/var/lib/postgresql/data
53+
# - ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
'components' => [
44
'db' => [
55
'class' => 'yii\db\Connection',
6-
'dsn' => 'pgsql:host=db;dbname=yii2advanced',
6+
// 'dsn' => 'pgsql:host=db;dbname=yii2advanced',
7+
'dsn' => 'mysql:host=db;dbname=yii2advanced',
78
'username' => 'username',
89
'password' => 'password',
910
'charset' => 'utf8',

0 commit comments

Comments
 (0)