Skip to content

Commit 5632b62

Browse files
author
Adegoke Obasa
committed
doc(readme): Add docker instructions
chore(docker): Complete docker setup
1 parent 5458632 commit 5632b62

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed

.dockerignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.git/*
2-
env/.env
32
config/local.php
43
config/console-local.php
5-
runtime
6-
web/assets
4+
app/runtime
5+
app/web/assets
76
vendor

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ RUN composer self-update --no-progress && \
2222
composer install --no-progress
2323

2424
# Copy the working dir to the image's web root
25-
COPY ./var/www/html
25+
COPY . /var/www/html
2626

2727

2828
# The following directories are .dockerignored to not pollute the docker images
2929
# with local logs and published assets from development. So we need to create
3030
# empty dirs and set right permissions inside the container.ADD
3131

32-
RUN mkdir runtime web/assets \
33-
&& chown www-data:www-data runtime web/assets
32+
RUN mkdir app/runtime app/web/assets \
33+
&& chown www-data:www-data app/runtime app/web/assets
3434

3535
# Expose everything under the /var/www (vendor + html)
3636
# This is only required for the nginx setup

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,29 @@ Make a copy of `.env.sample` to `.env` in the env directory.
7676

7777

7878
## Docker
79+
80+
This project is dockerized using the LEMP stack. The stack consists of:
81+
- PHP 7
82+
- nginx
83+
7984
Inspired by [yii2-dockerized](https://github.com/codemix/yii2-dockerized/blob/master/Dockerfile)
8085

86+
### Installation
87+
[Mac](https://www.docker.com/docker-mac)
88+
[Windows](https://www.docker.com/docker-windows)
89+
[Ubuntu](https://www.docker.com/docker-ubuntu)
90+
91+
### Running Containers
92+
- Ensure docker is running
93+
- Change directory to project directory
94+
- Run the command `docker-compoose up`
95+
- To rebuild the containers after updates to docker config files, run `docker-composer up --build`
96+
97+
### Entering Container CLI
98+
- Run the command `docker ps`
99+
- Check the Container ID for container with image ending with "_web"
100+
- Run the command `docker exec -it [container_id] bash`
101+
81102
## Change log
82103

83104
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"name": "cottacush/yii2-base-project",
33
"description": "A Yii 2 Base Project Template",
44
"keywords": ["yii2", "framework", "basic", "project template", "improved"],
5-
"version": "1.4.0",
65
"type": "project",
76
"license": "MIT",
87
"minimum-stability": "stable",
98
"require": {
10-
"php": ">=5.5.0",
9+
"php": "~5.5.0|~7.0",
1110
"yiisoft/yii2": ">=2.0.8",
1211
"yiisoft/yii2-bootstrap": "*",
1312
"yiisoft/yii2-swiftmailer": "*",
1413
"vlucas/phpdotenv": "^2.2",
1514
"lukasoppermann/http-status": "^2.0",
16-
"smilemd/yii2-htmlcompress": "^1.0"
15+
"smilemd/yii2-htmlcompress": "^1.0",
16+
"cottacush/yii2-utils": "~1.7.0"
1717
},
1818
"require-dev": {
1919
"yiisoft/yii2-codeception": "*",
@@ -26,8 +26,7 @@
2626
"phpmd/phpmd" : "@stable",
2727
"sebastian/phpcpd": "*",
2828
"theseer/phpdox": "*",
29-
"phpunit/phpunit": "4.8",
30-
"cottacush/yii2-utils": "~1.0.0"
29+
"phpunit/phpunit": "4.8"
3130
},
3231
"config": {
3332
"process-timeout": 1800,

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ services:
44
web:
55
build: ./
66
restart: always
7+
expose:
8+
- "9000"
79
volumes:
810
- ./:/var/www/html/
911
environment:

nginx/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ http {
3333

3434
listen 80;
3535

36-
root /var/www/html/web;
36+
root /var/www/html/app/web;
3737
index index.php;
3838

3939
location / {
@@ -49,7 +49,7 @@ http {
4949
location ~ \.php$ {
5050
include fastcgi_params;
5151
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
52-
fastcgi_pass app:9000;
52+
fastcgi_pass web:9000;
5353
try_files $uri =404;
5454
}
5555

0 commit comments

Comments
 (0)