Skip to content

Commit c4b4a58

Browse files
author
Vincent Composieux
committed
Fix Nginx configuration, namespace containers and clear docker-compose.yml
Fix comments
1 parent 53b2da1 commit c4b4a58

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ $ git clone git@github.com:eko/docker-symfony.git
1313

1414
Next, put your Symfony application into `symfony` folder and do not forget to add `symfony.dev` in your `/etc/hosts` file.
1515

16+
Now, you have to build your Docker images:
17+
18+
```bash
19+
$ docker build -t symfony/code code
20+
$ docker build -t symfony/php-fpm php-fpm
21+
$ docker build -t symfony/nginx nginx
22+
```
23+
1624
Then, run:
1725

1826
```bash

docker-compose.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
application:
2-
image: code
2+
image: symfony/code
33
volumes:
4-
- "symfony:/var/www/symfony"
5-
- "logs/symfony:/var/www/symfony/app/logs"
4+
- symfony:/var/www/symfony
5+
- logs/symfony:/var/www/symfony/app/logs
66
tty: true
77
db:
88
image: mysql
99
ports:
10-
- "3306:3306"
10+
- 3306:3306
1111
environment:
1212
MYSQL_ROOT_PASSWORD: root
1313
MYSQL_DATABASE: symfony
1414
MYSQL_USER: root
1515
MYSQL_PASSWORD: root
1616
php:
17-
image: php-fpm
17+
image: symfony/php-fpm
1818
expose:
19-
- "9000:9000"
19+
- 9000:9000
2020
volumes_from:
2121
- application
2222
links:
2323
- db
2424
nginx:
25-
image: nginx
25+
image: symfony/nginx
2626
ports:
27-
- "80:80"
27+
- 80:80
2828
links:
2929
- php
3030
volumes_from:
3131
- application
3232
volumes:
33-
- "logs/nginx/:/var/log/nginx"
34-
hostname: symfony.dev
33+
- logs/nginx/:/var/log/nginx

nginx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN rm /etc/nginx/sites-enabled/default
1212

1313
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
1414

15-
WORKDIR /etc/nginx
15+
RUN usermod -u 1000 www-data
1616

1717
CMD ["nginx"]
1818

nginx/symfony.conf

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ server {
22
server_name symfony.dev;
33
root /var/www/symfony/web;
44

5+
56
location / {
6-
# try to serve file directly, fallback to app.php
7-
try_files $uri /app.php$is_args$args;
7+
try_files $uri @rewriteapp;
8+
}
9+
10+
location @rewriteapp {
11+
rewrite ^(.*)$ /app.php/$1 last;
812
}
913

10-
# PROD
11-
location ~ ^/app\.php(/|$) {
14+
location ~ ^/(app|app_dev|config)\.php(/|$) {
1215
fastcgi_pass php-upstream;
1316
fastcgi_split_path_info ^(.+\.php)(/.*)$;
1417
include fastcgi_params;
1518
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1619
fastcgi_param HTTPS off;
17-
# Prevents URIs that include the front controller. This will 404:
18-
# http://domain.tld/app.php/some-path
19-
# Remove the internal directive to allow URIs like this
20-
internal;
2120
}
2221

2322
error_log /var/log/nginx/symfony_error.log;

php-fpm/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ ADD symfony.ini /etc/php5/cli/conf.d/
99

1010
ADD symfony.pool.conf /etc/php5/fpm/pool.d/
1111

12+
RUN usermod -u 1000 www-data
13+
1214
CMD ["php5-fpm", "-F"]
1315

1416
EXPOSE 9000

0 commit comments

Comments
 (0)