Skip to content

Commit 2157d11

Browse files
add different config for each env for db and nginx services
1 parent 849606a commit 2157d11

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

.docker/dev/db/scripts/.keep

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
upstream php-fpm {
2+
server php-fpm:9000;
3+
}
4+
5+
server {
6+
server_name project.dev;
7+
root /project/public;
8+
9+
location / {
10+
# try to serve file directly, fallback to index.php
11+
try_files $uri /index.php$is_args$args;
12+
}
13+
14+
location ~ ^/index\.php(/|$) {
15+
fastcgi_pass php-fpm;
16+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
17+
include fastcgi_params;
18+
19+
# optionally set the value of the environment variables used in the application
20+
# fastcgi_param APP_ENV prod;
21+
# fastcgi_param APP_SECRET <app-secret-id>;
22+
# fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
23+
24+
# When you are using symlinks to link the document root to the
25+
# current version of your application, you should pass the real
26+
# application path instead of the path to the symlink to PHP
27+
# FPM.
28+
# Otherwise, PHP's OPcache may not properly detect changes to
29+
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
30+
# for more information).
31+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
32+
fastcgi_param DOCUMENT_ROOT $realpath_root;
33+
# Prevents URIs that include the front controller. This will 404:
34+
# http://domain.tld/index.php/some-path
35+
# Remove the internal directive to allow URIs like this
36+
internal;
37+
}
38+
39+
# return 404 for all other php files not matching the front controller
40+
# this prevents access to other php files you don't want to be accessible.
41+
location ~ \.php$ {
42+
return 404;
43+
}
44+
45+
error_log /var/log/nginx/project_error.log;
46+
access_log /var/log/nginx/project_access.log;
47+
}

.docker/prod/db/scripts/.keep

Whitespace-only changes.

docker-compose.override.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ services:
66
target: development
77
volumes:
88
- ./.docker/dev/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xxdebug.ini
9+
db:
10+
volumes:
11+
- .docker/dev/db/scripts:/docker-entrypoint-initdb.d
12+
13+
nginx:
14+
image: nginx:latest
15+
volumes:
16+
- ./.docker/dev/nginx/etc/conf.d/default.conf:/etc/nginx/conf.d/default.conf

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
image: postgres:latest
2121
volumes:
2222
- db_data:/var/data
23+
- .docker/prod/db/scripts:/docker-entrypoint-initdb.d
2324
networks:
2425
- project
2526
environment:
@@ -37,6 +38,7 @@ services:
3738
- ./.docker/prod/nginx/etc/conf.d/default.conf:/etc/nginx/conf.d/default.conf
3839
ports:
3940
- "80:80"
41+
- "443:443"
4042
networks:
4143
- project
4244

0 commit comments

Comments
 (0)