Skip to content

Commit aeef672

Browse files
committed
initial commit
0 parents  commit aeef672

File tree

8 files changed

+195
-0
lines changed

8 files changed

+195
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Docker-compose config for Yii 2 Advanced Project Template
2+
===================================
3+
Yii 2 docker is a configuration for easy deployment and development of Yii 2 Advanced Project Template.
4+
5+
REQUIREMENTS
6+
------------
7+
8+
Docker and Docker compose
9+
10+
INSTALLATION VIA COMPOSER
11+
-------------------------
12+
```
13+
composer create-project --prefer-dist --no-install consultnn/yii2-docker-app-advanced app
14+
```
15+
16+
MANUALLY INSTALLATION
17+
---------------------
18+
Clone this repository
19+
```
20+
git clone https://github.com/consultnn/yii2-docker-app-advanced.git app
21+
```
22+
Change directory
23+
```
24+
cd app
25+
```
26+
Remove git directory
27+
```
28+
rm -rf .git
29+
```
30+
Install Yii 2 Advanced Project Template via composer inside docker container
31+
```
32+
docker-compose run --rm php composer create-project --prefer-dist yiisoft/yii2-app-advanced project
33+
```
34+
Change project directory owner (default root, because process inside container run as root)
35+
```
36+
chown -R $USER:$USER project
37+
```
38+
39+
DIRECTORY STRUCTURE
40+
-------------------
41+
```
42+
docker contains docker configuration, build files and logs
43+
nginx nginx docker configuration
44+
php php docker configuration
45+
project Yii 2 Advanced Project Template
46+
docker-compose.yml docker-compose configuration
47+
```
48+
49+
50+
USING
51+
------
52+
For executing commands inside docker container run
53+
~~~
54+
docker-compose run --rm {service} {command}
55+
or, if application already running
56+
docker exec {service} {command}
57+
~~~
58+
For example:
59+
~~~
60+
docker-compose run php composer install
61+
docker exec run php /init
62+
~~~
63+
64+
Start docker containers
65+
~~~
66+
docker-compose up -d
67+
~~~
68+
NOTE: for composer use `--prefer-dist` options, git not installed in php container.
69+
NOTE: inside php container default directory - project
70+
71+
After start check http://127.0.0.1:8090

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "consultnn/yii2-docker-app-advanced",
3+
"description": "Yii 2 Advanced Project Template under docker and docker-compose",
4+
"keywords": ["yii2", "docker", "docker-compose", "advanced", "project template"],
5+
"license": "BSD-3-Clause",
6+
"authors": [
7+
{
8+
"name": "sokrat",
9+
"email": "sergey.sipatov@gmail.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"config": {
14+
"process-timeout": 1800
15+
},
16+
"scripts": {
17+
"post-create-project-cmd" : [
18+
"composer global require 'fxp/composer-asset-plugin:~1.0' && composer create-project --prefer-dist yiisoft/yii2-app-advanced project"
19+
]
20+
}
21+
}

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
nginx:
2+
image: nginx
3+
links:
4+
- php
5+
volumes:
6+
- project:/www
7+
- docker/nginx/log:/var/log/nginx:rw
8+
- docker/nginx/conf.d:/etc/nginx/conf.d
9+
ports:
10+
- "8090:80"
11+
php:
12+
build: docker/php/build
13+
volumes:
14+
- project:/www:rw
15+
- docker/php/php-fpm.conf:/usr/local/etc/php-fpm.conf
16+
- docker/php/log:/var/log/php-fpm:rw
17+
working_dir: /www/

docker/nginx/conf.d/advanced.conf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
server {
2+
charset utf-8;
3+
client_max_body_size 128M;
4+
5+
listen 80; ## listen for ipv4
6+
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
7+
8+
server_name mysite.local;
9+
index index.php;
10+
11+
access_log /var/log/nginx/access.log;
12+
error_log /var/log/nginx/error.log;
13+
14+
location /backend {
15+
root /www/backend/web;
16+
try_files $uri $uri/ /index.php?$args;
17+
18+
location ~ \.php$ {
19+
include fastcgi_params;
20+
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
21+
fastcgi_pass php:9000;
22+
#fastcgi_pass unix:/var/run/php5-fpm.sock;
23+
#try_files $uri =404;
24+
}
25+
}
26+
27+
location / {
28+
root /www/frontend/web;
29+
# Redirect everything that isn't a real file to index.php
30+
try_files $uri $uri/ /index.php?$args;
31+
32+
location ~ \.php$ {
33+
include fastcgi_params;
34+
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
35+
fastcgi_pass php:9000;
36+
#fastcgi_pass unix:/var/run/php5-fpm.sock;
37+
#try_files $uri =404;
38+
}
39+
}
40+
41+
# uncomment to avoid processing of calls to non-existing static files by Yii
42+
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
43+
# try_files $uri =404;
44+
#}
45+
#error_page 404 /404.html;
46+
47+
location ~ /\.(ht|svn|git) {
48+
deny all;
49+
}
50+
}

docker/nginx/log/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

docker/php/build/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:5.6-fpm
2+
# Install modules
3+
RUN apt-get update && apt-get install -y zlibc zlib1g zlib1g-dev --no-install-recommends && rm -r /var/lib/apt/lists/*
4+
RUN docker-php-ext-configure mbstring
5+
RUN docker-php-ext-install mbstring zip
6+
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer global require --prefer-dist "fxp/composer-asset-plugin:~1.0"
8+
9+
CMD ["php-fpm"]

docker/php/log/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

docker/php/php-fpm.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; This file was initially adapated from the output of: (on PHP 5.6)
2+
; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default
3+
4+
[global]
5+
6+
error_log = /var/log/php-fpm/error.log
7+
daemonize = no
8+
9+
[www]
10+
11+
; if we send this to /proc/self/fd/1, it never appears
12+
access.log = /var/log/php-fpm/access.log
13+
14+
user = www-data
15+
group = www-data
16+
17+
listen = [::]:9000
18+
19+
pm = dynamic
20+
pm.max_children = 5
21+
pm.start_servers = 2
22+
pm.min_spare_servers = 1
23+
pm.max_spare_servers = 3

0 commit comments

Comments
 (0)