2
2
3
3
[ ![ Build Status] ( https://travis-ci.org/maxpou/docker-symfony.svg?branch=master )] ( https://travis-ci.org/maxpou/docker-symfony )
4
4
5
- * Credit: this is a kind of fork from [ eko/docker-symfony ] ( https ://github.com/eko/ docker-symfony ) . Thanks to him :-) *
5
+ ![ ] ( http ://www.maxpou.fr/images/articles/symfony- docker/schema-v2.png )
6
6
7
- ![ ] ( http ://www.maxpou.fr/images/articles/symfony-docker/schema.png )
7
+ Docker-symfony gives you everything you need for developing Symfony application. This complete stack run with docker and [ docker-compose ] ( https ://docs.docker.com/compose/ ) .
8
8
9
9
## Installation
10
10
11
11
1 . Retrieve git project
12
12
13
13
``` bash
14
- $ git clone git@github.com:maxpou/docker-symfony.git
14
+ $ git clone https://github.com/maxpou/docker-symfony
15
+ ```
16
+
17
+ 2. In the docker-compose file, indicate where' s your Symfony project
18
+
19
+ ```yml
20
+ services:
21
+ php:
22
+ volumes:
23
+ - path/to/your/symfony-project:/var/www/symfony
15
24
```
16
25
17
- 2. Move your Symfony project into symfony folder
18
26
3. Build containers with (with and without detached mode)
19
27
20
28
```bash
27
35
```bash
28
36
# get containers IP address and update host (replace IP according to your configuration)
29
37
$ docker inspect --format ' {{ .NetworkSettings.IPAddress }}' $(docker ps -f name=nginx -q)
38
+ # unix only (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
30
39
$ sudo echo "171.17.0.1 symfony.dev" >> /etc/hosts
31
40
```
32
41
42
+ **Note:** If it' s empty, run ` docker inspect $( docker ps -f name=nginx -q) | grep IPAddress` instead.
43
+
33
44
5. Prepare Symfony app
34
45
1. Retrieve DB& Redis IP
35
46
38
49
$ docker inspect --format ' {{ .NetworkSettings.IPAddress }}' $( docker ps -f name=redis -q)
39
50
` ` `
40
51
41
- 2. Update app/paraeters.yml (adapt hosts according to previous results)
52
+ ** Note:** If it' s empty, run `docker inspect $(docker ps -f name=db -q) | grep IPAddress` instead.
53
+
54
+ 2. Update app/config/parameters.yml
42
55
43
56
```yml
57
+ # path/to/sfApp/app/config/parameters.yml
44
58
parameters:
45
- database_host: 172.17.0.4
46
- database_port: null
47
- database_name: symfony
48
- database_user: root
49
- database_password: root
50
- redis_host: 172.17.0.3
59
+ redis_host: redis
60
+ database_host: mysqldb
51
61
```
52
62
53
- 3. Composer install
63
+ 3. Composer install & create database
54
64
55
- ` ` ` yml
56
- $ docker exec -ti $( docker ps -f name=php -q) sh -c " cd /var/www/symfony/ && composer install"
65
+ ```bash
66
+ $ docker-compose exec php bash
67
+ $ composer install
68
+ $ sf doctrine:database:create
69
+ $ sf doctrine:schema:update --force
70
+ $ sf doctrine:fixtures:load --no-interaction
57
71
```
58
72
59
73
6. Enjoy :-)
60
74
61
- # # Using
75
+ ## Usage
76
+
77
+ Just run `docker-compose -d`, then:
62
78
63
79
* Symfony app: visit [symfony.dev](http://symfony.dev)
64
80
* Symfony dev mode: visit [symfony.dev/app_dev.php](http://symfony.dev/app_dev.php)
69
85
70
86
Have a look at the `docker-compose.yml` file, here are the `docker-compose` built images:
71
87
72
- * ` application` : This is the Symfony application code container,
73
88
* `db`: This is the MySQL database container,
74
89
* `php`: This is the PHP-FPM container in which the application volume is mounted,
75
90
* `nginx`: This is the Nginx webserver container in which application volume is mounted too,
@@ -82,7 +97,6 @@ This results in the following running containers:
82
97
$ docker-compose ps
83
98
Name Command State Ports
84
99
--------------------------------------------------------------------------------------------------
85
- dockersymfony_application_1 /bin/bash Up
86
100
dockersymfony_db_1 /entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
87
101
dockersymfony_elk_1 /usr/bin/supervisord -n -c ... Up 0.0.0.0:81->80/tcp
88
102
dockersymfony_nginx_1 nginx Up 443/tcp, 0.0.0.0:80->80/tcp
@@ -93,29 +107,32 @@ dockersymfony_redis_1 /entrypoint.sh redis-server Up 0.0.0.0:6
93
107
## Useful commands
94
108
95
109
```bash
96
- # Composer (e.g. composer update)
97
- $ docker exec -ti $( docker ps -f name= php -q ) sh -c " cd /var/www/symfony/ && composer update "
110
+ # bash commands
111
+ $ docker-compose exec php bash
98
112
99
- # SF commands
100
- $ docker exec -ti $( docker ps -f name= php -q ) php /var/www/symfony/app/console cache:clear
113
+ # Composer (e.g. composer update)
114
+ $ docker-compose exec php composer update
101
115
102
- # bash commands
103
- $ docker exec -ti $( docker ps -f name=php -q) /bin/bash
116
+ # SF commands (Tips: there is an alias inside php container)
117
+ $ docker-compose exec php php /var/www/symfony/app/console cache:clear
118
+ # Same command by using alias
119
+ $ docker-compose exec php bash
120
+ $ sf cache:clear
104
121
105
122
# MySQL commands
106
- $ docker exec -ti $( docker ps -f name=db -q ) mysql -uroot -p" root"
123
+ $ docker-compose exec db mysql -uroot -p"root"
107
124
108
125
# Redis commands
109
- $ docker exec -ti $( docker ps -f name= redis -q ) sh -c ' exec redis-cli'
126
+ $ docker-compose exec redis redis-cli
110
127
111
128
# F***ing cache/logs folder
112
- $ sudo chmod -R 777 symfony/ app/cache symfony/ app/logs
129
+ $ sudo chmod -R 777 app/cache app/logs
113
130
114
131
# Check CPU consumption
115
132
$ docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -q))
116
133
117
134
# Delete all containers
118
- $ docker rm $( docker ps -a -q )
135
+ $ docker rm $(docker ps -aq )
119
136
120
137
# Delete all images
121
138
$ docker rmi $(docker images -q)
@@ -129,9 +146,29 @@ Run `docker-compose up -d` instead.
129
146
130
147
* Permission problem? See [this doc (Setting up Permission)](http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup)
131
148
149
+ * How I can add PHPMyAdmin?
150
+ Simply add this: (then go to [symfony.dev:8080](http://symfony.dev:8080))
151
+
152
+ ```
153
+ phpmyadmin:
154
+ image: corbinu/docker-phpmyadmin
155
+ ports :
156
+ - "8080:80"
157
+ environment:
158
+ - MYSQL_USERNAME=root
159
+ - MYSQL_PASSWORD=root
160
+ links:
161
+ - db:mysql
162
+ ```
163
+
164
+
165
+ ## Contributing
166
+
167
+ First of all, **thank you** for contributing ♥
168
+ If you find any typo/misconfiguration/... please send me a PR or open an issue. You can also ping me on [twitter](https://twitter.com/_maxpou).
169
+ Also, while creating your Pull Request on GitHub, please write a description which gives the context and/or explains why you are creating it.
170
+
171
+
132
172
## TODO
133
173
134
- - [ ] Upgrade ELK stack. Install [Timelion](https://github.com/elastic/timelion) < 3
135
- - [ ] MySQL -> PostgreSQL
136
- - [ ] Move SF app folder?
137
- - [ ] use php7-fpm/php.ini
174
+ - [ ] Upgrade ELK stack + install [Timelion](https://github.com/elastic/timelion) plugin <3
0 commit comments