Skip to content

Commit a9b2256

Browse files
committed
Add nginx service
1 parent fcc05fa commit a9b2256

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ services:
66
volumes:
77
- ./:/var/www
88
- ./mariadb:/var/lib/mysql:rw
9+
- ./services/nginx/logs:/var/log/nginx
10+
- ./services/nginx/sites:/etc/nginx/conf.d
911
php-fpm:
1012
build:
1113
context: ./services/php
@@ -19,6 +21,16 @@ services:
1921
context: ./services/composer
2022
volumes:
2123
- ./:/app
24+
nginx:
25+
build:
26+
context: ./services/nginx
27+
volumes_from:
28+
- workspace
29+
ports:
30+
- 8080:80
31+
depends_on:
32+
- php-fpm
33+
restart: always
2234
mariadb:
2335
build:
2436
context: ./services/mariadb
@@ -40,5 +52,7 @@ services:
4052
volumes:
4153
php-fpm:
4254
driver: "local"
55+
nginx:
56+
driver: "local"
4357
mariadb:
4458
driver: "local"

services/nginx/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM nginx:1.13
2+
3+
# update image
4+
RUN apt-get update
5+
6+
# nginx configuration
7+
COPY nginx.conf /etc/nginx
8+
9+
# mark volume/s as externally mounted
10+
VOLUME ["/var/www", "/etc/nginx/conf.d", "/var/log/nginx"]
11+
12+
# starting point
13+
WORKDIR /var/www
14+
15+
CMD ["/usr/sbin/nginx"]

services/nginx/nginx.conf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
user root;
2+
worker_processes 1;
3+
daemon off;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
http {
13+
include /etc/nginx/mime.types;
14+
default_type application/octet-stream;
15+
16+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
17+
'$status $body_bytes_sent "$http_referer" '
18+
'"$http_user_agent" "$http_x_forwarded_for"';
19+
20+
access_log /var/log/nginx/access.log main;
21+
22+
sendfile on;
23+
tcp_nopush on;
24+
25+
keepalive_timeout 65;
26+
27+
gzip on;
28+
29+
include /etc/nginx/conf.d/*;
30+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
server {
2+
server_name localhost;
3+
root /var/www/public;
4+
index index.php;
5+
6+
client_max_body_size 100M;
7+
fastcgi_read_timeout 1800;
8+
9+
location / {
10+
try_files $uri $uri/ /index.php$is_args$args;
11+
}
12+
13+
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
14+
expires max;
15+
log_not_found off;
16+
access_log off;
17+
}
18+
19+
location ~ \.php$ {
20+
try_files $uri =404;
21+
include fastcgi_params;
22+
fastcgi_index index.php;
23+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
24+
fastcgi_pass php-fpm:9000;
25+
}
26+
}

0 commit comments

Comments
 (0)