Skip to content

Commit 05a83d3

Browse files
committed
Major updates.
- upgrade docker compose to v2 - build images locally instead of pulling them from the registry - separate php container form nginx container - support all the php versions including php 7.0 - remove beanstalked container to be optionally added later by the user
1 parent 1205183 commit 05a83d3

11 files changed

Lines changed: 232 additions & 60 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/logs

data/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM debian:jessie
2+
3+
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
4+
5+
CMD ["true"]

docker-compose.yml

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,65 @@
1-
# PHP + NGINX Container #----------------------------------
2-
php-nginx:
3-
image: laradock/php56nginx:0.1.0
4-
container_name: php-nginx
5-
ports:
6-
- "80:80"
7-
volumes:
8-
- ./settings/nginx:/etc/nginx/sites-available
9-
- ../:/var/www
10-
- ./logs/nginx:/var/log/nginx
11-
links:
12-
- mysql
13-
- redis
14-
privileged: true
15-
16-
# MySQL Container #----------------------------------------
17-
mysql:
18-
image: laradock/mysql:0.1.0
19-
container_name: mysql
20-
ports:
21-
- "3306:3306"
22-
volumes_from:
23-
- data
24-
environment:
25-
MYSQL_DATABASE: homestead
26-
MYSQL_USER: homestead
27-
MYSQL_PASSWORD: secret
28-
privileged: true
29-
30-
# Redis Container #----------------------------------------
31-
redis:
32-
image: laradock/redis:0.1.0
33-
container_name: redis
34-
ports:
35-
- "6379:6379"
36-
volumes_from:
37-
- data
38-
volumes:
39-
- ./logs/redis:/var/log/redis
40-
privileged: true
41-
42-
# Data Volume Container #----------------------------------
43-
data:
44-
image: laradock/data:0.1.0
45-
container_name: data
46-
volumes:
47-
- /var/lib/mysql
48-
- /var/lib/redis
49-
50-
# Beanstalkd Container #-----------------------------------
51-
# beanstalkd:
52-
# image: laradock/beanstalkd:0.1.0
53-
# container_name: beanstalkd
54-
# ports:
55-
# - "11300:11300"
56-
# privileged: true
57-
58-
#----------------------------------------------------------
1+
version: '2'
2+
services:
3+
4+
### Nginx Server Container ##################################
5+
6+
nginx:
7+
build: ./nginx
8+
container_name: nginx
9+
volumes_from:
10+
- php
11+
volumes:
12+
- ./logs/nginx/:/var/log/nginx
13+
ports:
14+
- "80:80"
15+
links:
16+
- php
17+
18+
### PHP Container ###########################################
19+
20+
php:
21+
build: ./php
22+
container_name: php
23+
volumes:
24+
- ../:/var/www/laravel
25+
- ./logs/php/:/usr/local/var/log
26+
expose:
27+
- "9000"
28+
links:
29+
- mysql
30+
31+
### MySQL Container #########################################
32+
33+
mysql:
34+
build: ./mysql
35+
container_name: mysql
36+
volumes_from:
37+
- data
38+
ports:
39+
- "3306:3306"
40+
environment:
41+
MYSQL_DATABASE: homestead
42+
MYSQL_USER: homestead
43+
MYSQL_PASSWORD: secret
44+
MYSQL_ROOT_PASSWORD: root
45+
46+
### Redis Container #########################################
47+
48+
redis:
49+
build: ./redis
50+
container_name: redis
51+
volumes_from:
52+
- data
53+
ports:
54+
- "6379:6379"
55+
56+
### DATA Container ##########################################
57+
58+
data:
59+
build: ./data
60+
container_name: data
61+
volumes:
62+
- /var/lib/mysql
63+
- /var/lib/redis
64+
65+
### Add more Containers below ###############################

mysql/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mysql:latest
2+
3+
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
4+
5+
VOLUME /var/lib/mysql
6+
7+
CMD ["mysqld"]
8+
9+
EXPOSE 3306

nginx/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM nginx:latest
2+
3+
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
4+
5+
ADD nginx.conf /etc/nginx/
6+
ADD laravel.conf /etc/nginx/sites-available/
7+
8+
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
9+
10+
RUN usermod -u 1000 www-data
11+
12+
CMD ["nginx"]
13+
14+
EXPOSE 80 443
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ server {
22
listen 80 default_server;
33
listen [::]:80 default_server ipv6only=on;
44

5-
root /var/www/public;
5+
root /var/www/laravel/public;
66
index index.php index.html index.htm;
77

88
location / {
@@ -11,7 +11,7 @@ server {
1111

1212
location ~ \.php$ {
1313
try_files $uri /index.php =404;
14-
fastcgi_pass unix:/var/run/php5-fpm.sock;
14+
fastcgi_pass php-upstream;
1515
fastcgi_index index.php;
1616
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1717
include fastcgi_params;
@@ -21,3 +21,6 @@ server {
2121
deny all;
2222
}
2323
}
24+
25+
26+

nginx/nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
user www-data;
2+
worker_processes 4;
3+
pid /run/nginx.pid;
4+
5+
events {
6+
worker_connections 2048;
7+
multi_accept on;
8+
use epoll;
9+
}
10+
11+
http {
12+
server_tokens off;
13+
sendfile on;
14+
tcp_nopush on;
15+
tcp_nodelay on;
16+
keepalive_timeout 15;
17+
types_hash_max_size 2048;
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
access_log off;
21+
error_log off;
22+
gzip on;
23+
gzip_disable "msie6";
24+
include /etc/nginx/conf.d/*.conf;
25+
include /etc/nginx/sites-available/*;
26+
open_file_cache max=100;
27+
}
28+
29+
daemon off;

php/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:7.0-fpm
2+
3+
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
4+
5+
ADD ./laravel.ini /usr/local/etc/php/conf.d
6+
ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/
7+
8+
# Install extensions using the helper script provided by the base image
9+
RUN docker-php-ext-install \
10+
pdo_mysql
11+
12+
RUN usermod -u 1000 www-data
13+
14+
CMD ["php-fpm"]
15+
16+
EXPOSE 9000

php/laravel.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
date.timezone = UTC
2+
display_errors = Off
3+
log_errors = On

php/laravel.pool.conf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
; Unix user/group of processes
2+
; Note: The user is mandatory. If the group is not set, the default user's group
3+
; will be used.
4+
user = www-data
5+
group = www-data
6+
7+
; The address on which to accept FastCGI requests.
8+
; Valid syntaxes are:
9+
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
10+
; a specific port;
11+
; 'port' - to listen on a TCP socket to all addresses on a
12+
; specific port;
13+
; '/path/to/unix/socket' - to listen on a unix socket.
14+
; Note: This value is mandatory.
15+
listen = 0.0.0.0:9000
16+
17+
; Choose how the process manager will control the number of child processes.
18+
; Possible Values:
19+
; static - a fixed number (pm.max_children) of child processes;
20+
; dynamic - the number of child processes are set dynamically based on the
21+
; following directives. With this process management, there will be
22+
; always at least 1 children.
23+
; pm.max_children - the maximum number of children that can
24+
; be alive at the same time.
25+
; pm.start_servers - the number of children created on startup.
26+
; pm.min_spare_servers - the minimum number of children in 'idle'
27+
; state (waiting to process). If the number
28+
; of 'idle' processes is less than this
29+
; number then some children will be created.
30+
; pm.max_spare_servers - the maximum number of children in 'idle'
31+
; state (waiting to process). If the number
32+
; of 'idle' processes is greater than this
33+
; number then some children will be killed.
34+
; ondemand - no children are created at startup. Children will be forked when
35+
; new requests will connect. The following parameter are used:
36+
; pm.max_children - the maximum number of children that
37+
; can be alive at the same time.
38+
; pm.process_idle_timeout - The number of seconds after which
39+
; an idle process will be killed.
40+
; Note: This value is mandatory.
41+
pm = dynamic
42+
43+
; The number of child processes to be created when pm is set to 'static' and the
44+
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
45+
; This value sets the limit on the number of simultaneous requests that will be
46+
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
47+
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
48+
; CGI. The below defaults are based on a server without much resources. Don't
49+
; forget to tweak pm.* to fit your needs.
50+
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
51+
; Note: This value is mandatory.
52+
pm.max_children = 20
53+
54+
; The number of child processes created on startup.
55+
; Note: Used only when pm is set to 'dynamic'
56+
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
57+
pm.start_servers = 2
58+
59+
; The desired minimum number of idle server processes.
60+
; Note: Used only when pm is set to 'dynamic'
61+
; Note: Mandatory when pm is set to 'dynamic'
62+
pm.min_spare_servers = 1
63+
64+
; The desired maximum number of idle server processes.
65+
; Note: Used only when pm is set to 'dynamic'
66+
; Note: Mandatory when pm is set to 'dynamic'
67+
pm.max_spare_servers = 3
68+
69+
;---------------------
70+
71+
; Make specific Docker environment variables available to PHP
72+
env[DB_1_ENV_MYSQL_DATABASE] = $DB_1_ENV_MYSQL_DATABASE
73+
env[DB_1_ENV_MYSQL_USER] = $DB_1_ENV_MYSQL_USER
74+
env[DB_1_ENV_MYSQL_PASSWORD] = $DB_1_ENV_MYSQL_PASSWORD
75+
76+
catch_workers_output = yes

0 commit comments

Comments
 (0)