Skip to content

Commit 61447f7

Browse files
committed
Added Docker support for development
1 parent d8cb7ec commit 61447f7

File tree

11 files changed

+313
-5
lines changed

11 files changed

+313
-5
lines changed

.env.docker.example

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
APP_ENV=local
2+
APP_KEY=
3+
APP_DEBUG=true
4+
APP_LOG_LEVEL=debug
5+
APP_URL=http://localhost
6+
APP_DEMO=false
7+
8+
DB_CONNECTION=mysql
9+
DB_HOST=mariadb
10+
DB_PORT=3306
11+
DB_DATABASE=jogging_time
12+
DB_USERNAME=jogging_time
13+
DB_PASSWORD=secret
14+
15+
BROADCAST_DRIVER=log
16+
CACHE_DRIVER=redis
17+
SESSION_DRIVER=file
18+
QUEUE_DRIVER=redis
19+
20+
REDIS_HOST=redis
21+
REDIS_PASSWORD=null
22+
REDIS_PORT=6379
23+
24+
MAIL_DRIVER=smtp
25+
MAIL_HOST=mmailcatcher
26+
MAIL_PORT=1025
27+
MAIL_USERNAME=null
28+
MAIL_PASSWORD=null
29+
MAIL_ENCRYPTION=null
30+
31+
PUSHER_APP_ID=
32+
PUSHER_KEY=
33+
PUSHER_SECRET=

Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM php:7.2-fpm
2+
3+
# Get repository and install wget and vim
4+
RUN apt-get update && apt-get install --no-install-recommends -y wget vim git unzip apt-transport-https gnupg
5+
6+
RUN apt-get install -y locales \
7+
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
8+
&& locale-gen
9+
10+
# Install PHP extensions deps
11+
RUN apt-get update \
12+
&& apt-get install --no-install-recommends -y \
13+
libfreetype6-dev \
14+
libjpeg62-turbo-dev \
15+
libpng-dev \
16+
zlib1g-dev \
17+
libicu-dev \
18+
unixodbc-dev \
19+
libssl-dev \
20+
g++
21+
22+
# Install PHP extensions
23+
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
24+
&& docker-php-ext-install \
25+
mbstring \
26+
pdo_mysql \
27+
zip \
28+
ftp \
29+
&& docker-php-ext-enable \
30+
opcache
31+
32+
# Install Composer
33+
RUN curl -sS https://getcomposer.org/installer | php -- \
34+
--install-dir=/usr/local/bin \
35+
--filename=composer
36+
37+
# Install supervisor
38+
RUN apt-get install -y supervisor
39+
40+
# Install Node
41+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
42+
&& apt-get install -y nodejs
43+
44+
# Install Yarn
45+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
46+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
47+
&& apt-get update && apt-get install -y yarn
48+
49+
# Clean repository
50+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
51+
52+
# Set timezone
53+
RUN rm /etc/localtime
54+
RUN ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
55+
RUN "date"
56+
57+
CMD mkdir -p /app
58+
59+
VOLUME /app
60+
61+
CMD chown -R www-data:www-data /app
62+
63+
WORKDIR /app
64+
65+
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"laravel/framework": "5.5.*",
1313
"laravel/passport": "^4.0.3",
1414
"laravel/tinker": "^1.0",
15-
"mpociot/laravel-apidoc-generator": "^2.0"
15+
"mpociot/laravel-apidoc-generator": "^2.0",
16+
"predis/predis": "^1.1"
1617
},
1718
"require-dev": {
1819
"barryvdh/laravel-debugbar": "^2.3",

composer.lock

Lines changed: 51 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: '2'
2+
services:
3+
4+
php:
5+
build: ./
6+
container_name: jogging_time_php
7+
image: jogging_time_php
8+
volumes:
9+
- .:/app:cached
10+
- ./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini
11+
- ./docker/supervisord.conf:/etc/supervisord.conf
12+
links:
13+
- mariadb
14+
- mailcatcher
15+
- redis
16+
17+
nginx:
18+
image: nginx:alpine
19+
container_name: jogging_time_nginx
20+
ports:
21+
- 8080:80
22+
volumes:
23+
- .:/app
24+
- ./docker/default.conf:/etc/nginx/conf.d/default.conf
25+
links:
26+
- php
27+
28+
mariadb:
29+
image: mariadb:latest
30+
container_name: jogging_time_mysql
31+
ports:
32+
- 33060:3306
33+
volumes:
34+
- mysql:/var/lib/mysql
35+
environment:
36+
MYSQL_ROOT_PASSWORD: secret
37+
MYSQL_DATABASE: jogging_time
38+
MYSQL_USER: jogging_time
39+
MYSQL_PASS: secret
40+
41+
mailcatcher:
42+
image: schickling/mailcatcher
43+
container_name: jogging_time_mailcatcher
44+
ports:
45+
- 1080:1080
46+
47+
redis:
48+
image: redis:3-alpine
49+
container_name: jogging_time_redis
50+
ports:
51+
- 63790:6379
52+
53+
volumes:
54+
mysql:

docker/default.conf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
server {
2+
listen 80;
3+
4+
#charset koi8-r;
5+
#access_log /var/log/nginx/log/host.access.log main;
6+
7+
client_max_body_size 200M;
8+
9+
index index.html index.php;
10+
error_log /var/log/nginx/error.log;
11+
access_log /var/log/nginx/access.log;
12+
root /app/public;
13+
14+
location / {
15+
try_files $uri $uri/ /index.php?$query_string;
16+
}
17+
18+
error_page 404 /404.html;
19+
20+
# redirect server error pages to the static page /50x.html
21+
error_page 500 502 503 504 /50x.html;
22+
location = /50x.html {
23+
root /usr/share/nginx/html;
24+
}
25+
26+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
27+
location ~* \.php$ {
28+
try_files $uri =404;
29+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
30+
fastcgi_pass php:9000;
31+
fastcgi_index index.php;
32+
include fastcgi_params;
33+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
34+
fastcgi_param PATH_INFO $fastcgi_path_info;
35+
}
36+
37+
# deny access to .htaccess files, if Apache's document root
38+
# concurs with nginx's one
39+
location ~ /\.ht {
40+
deny all;
41+
}
42+
}

docker/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
memory_limit = 256M
2+
opcache.validate_timestamps = 1
3+
opcache.revalidate_freq = 1

docker/supervisord.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[supervisord]
2+
nodaemon=true
3+
logfile=/var/log/supervisor/supervisord.log
4+
pidfile=/var/run/supervisord.pid
5+
childlogdir=/var/log/supervisor
6+
7+
[program:php-fpm]
8+
process_name=%(program_name)s_%(process_num)02d
9+
command=/usr/local/sbin/php-fpm -F
10+
numprocs=1
11+
stdout_logfile=/dev/stdout
12+
stdout_logfile_maxbytes=0
13+
stderr_logfile=/dev/stderr
14+
stderr_logfile_maxbytes=0
15+
autorestart=true
16+
startretries=0
17+
18+
[program:laravel-queue]
19+
process_name=%(program_name)s_%(process_num)02d
20+
command=php /app/artisan queue:work --sleep=1 --tries=3
21+
numprocs=2
22+
redirect_stderr=true
23+
stdout_logfile=/app/storage/logs/queue.log
24+
autorestart=true
25+
startretries=0

readme.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ If you don't have installed yarn, run `npm install -g yarn`
5151
* Full Phpunit test coverage
5252
* E2E tests with Cypress
5353
* Continuous integration with Travis CI
54+
* Development configuration with Docker
5455

5556

5657
### Includes ###
@@ -62,6 +63,7 @@ If you don't have installed yarn, run `npm install -g yarn`
6263
* [Vuex](https://vuex.vuejs.org/en/intro.html) State management pattern + library for Vue.js
6364
* [Vue-Router](https://router.vuejs.org/en/) Router library for Vue.js
6465
* [Axios](https://github.com/axios/axios) HTTP client
66+
* [Docker](https://www.docker.com/) Development setup with Docker
6567

6668

6769
### Other Features ###
@@ -109,9 +111,42 @@ yarn production -- --env.analyzer true
109111
```
110112

111113

114+
### Development with Docker ###
115+
116+
If you want to use more features like Redis queues, MariaDB database,
117+
sending and viewing sent emails you can use Docker setup on this project.
118+
119+
For you you will need Docker installed on your host [https://docs.docker.com/install/](https://docs.docker.com/install/)
120+
121+
To build the image for Docker, run:
122+
123+
docker-compose build
124+
125+
It will build all images and run all needed containers.
126+
127+
Then use ENV variables, prepared specificly for Docker:
128+
129+
cp .env.docker.example .env
130+
docker-compose run php php artisan key:generate
131+
132+
Migrate and seed database, and install Passport:
133+
134+
docker-compose run php php artisan migrate --seed
135+
docker-compose run php php artisan passport:install
136+
137+
To run the project in Docker just run:
138+
139+
docker-compose up
140+
141+
And open http://localhost:8080
142+
143+
To run all the Artisan or Test commands you can use `docker-compose run php` before the command to run it in the container.
144+
If you want to run command in currently running container, use `docker-compose exec php`.
145+
146+
112147
### Tests ###
113148

114-
To run all Phpunit tests:
149+
To run all PHPUnit tests:
115150

116151
```
117152
./vendor/bin/phpunit

resources/assets/js/components/pages/admin/entry/partials/Row.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<tr :id="`entry-row-${row.id}`">>
2+
<tr :id="`entry-row-${row.id}`">
33
<td>
44
<router-link v-if="row.user" :to="'/admin/user/show/' + row.user.id">{{ row.user.name }}</router-link>
55
</td>

0 commit comments

Comments
 (0)