Skip to content

Commit 27c8973

Browse files
committed
add .env variable db+path
1 parent a13cfe1 commit 27c8973

File tree

5 files changed

+22
-29
lines changed

5 files changed

+22
-29
lines changed

.env.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Symfony application's path
2+
SYMFONY_APP_PATH=/home/maxence/sites/lab/symfony-rest-beer-edition
3+
4+
# MySQL
5+
MYSQL_ROOT_PASSWORD=root
6+
MYSQL_DATABASE=mydb
7+
MYSQL_USER=user
8+
MYSQL_PASSWORD=userpass

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/logs
22
/.data
3+
.env

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ before_install:
1414
- docker -v
1515
# symfony application folder
1616
- mkdir symfony
17-
- line_old='../../sites/lab/symfony-rest-beer-edition:/var/www/symfony'
18-
- line_new='./symfony:/var/www/symfony'
19-
- sed -i "s%$line_old%$line_new%g" docker-compose.yml
17+
- cp .env.dist .env
2018
- cat docker-compose.yml
2119

2220
script:

README.md

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ Docker-symfony gives you everything you need for developing Symfony application.
88

99
## Installation
1010

11-
1. In the docker-compose file, indicate where's your Symfony project
11+
1. Create a `.env` from the `.env.dist` file. Adapt it according to your symfony application
1212

13-
```yml
14-
services:
15-
php:
16-
volumes:
17-
- path/to/your/symfony-project:/var/www/symfony
13+
```bash
14+
cp .env.dist .env
1815
```
1916

17+
2018
2. Build/run containers with (with and without detached mode)
2119

2220
```bash
@@ -29,35 +27,25 @@ Docker-symfony gives you everything you need for developing Symfony application.
2927

3028
```bash
3129
# get containers IP address and update host (replace IP according to your configuration)
32-
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -f name=nginx -q)
30+
$ docker inspect --format '{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}' $(docker ps -f name=nginx -q)
3331
# unix only (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
3432
$ sudo echo "171.17.0.1 symfony.dev" >> /etc/hosts
3533
```
3634

3735
**Note:** If it's empty, run `docker inspect $(docker ps -f name=nginx -q) | grep IPAddress` instead.
3836
3937
4. Prepare Symfony app
40-
1. Retrieve DB&Redis IP
41-
42-
```bash
43-
$ docker inspect --format '{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}' $(docker ps -f name=db -q)
44-
$ docker inspect --format '{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}' $(docker ps -f name=redis -q)
45-
```
46-
47-
**Note:** If it's empty, run `docker inspect $(docker ps -f name=db -q) | grep IPAddress` instead.
48-
49-
2. Update app/config/parameters.yml
38+
1. Update app/config/parameters.yml
5039
5140
```yml
5241
# path/to/your/symfony-project/app/config/parameters.yml
5342
parameters:
5443
database_host: mysqldb
55-
database_password: root
5644
#...
5745
redis_host: redis
5846
```
5947
60-
3. Composer install & create database
48+
2. Composer install & create database
6149
6250
```bash
6351
$ docker-compose exec php bash
@@ -167,8 +155,3 @@ Run `docker-compose up -d` instead.
167155
First of all, **thank you** for contributing ♥
168156
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).
169157
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-
172-
## TODO
173-
174-
- [ ] Upgrade ELK stack + install [Timelion](https://github.com/elastic/timelion) plugin <3

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ services:
88
volumes:
99
- "./.data/db:/var/lib/mysql"
1010
environment:
11-
MYSQL_ROOT_PASSWORD: root
11+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
12+
MYSQL_DATABASE: ${MYSQL_DATABASE}
13+
MYSQL_USER: ${MYSQL_USER}
14+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
1215
redis:
1316
image: redis:alpine
1417
ports:
@@ -21,7 +24,7 @@ services:
2124
- db:mysqldb
2225
- redis
2326
volumes:
24-
- ../../sites/lab/symfony-rest-beer-edition:/var/www/symfony
27+
- ${SYMFONY_APP_PATH}:/var/www/symfony
2528
- ./logs/symfony:/var/www/symfony/app/logs
2629
nginx:
2730
build: nginx

0 commit comments

Comments
 (0)