You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you should now specify your root password, database, and username/password in the `.env` file instead of the `docker-compose.yml` file. This lets us keep the passwords local so we can add our `docker-compose.yml` file to our repo without compromising db security
Copy file name to clipboardExpand all lines: README.md
+23-3
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,23 @@ Here is an example of what my typical setup looks like
100
100
php-ini-overrides.ini
101
101
```
102
102
103
-
Then, **Find/Replace**`myapp` with the name of your app.
103
+
Next, **Update the Environment File**
104
+
105
+
Copy or Rename `docker/.env.sample` to `docker/.env`.
106
+
This is an environment file that your Docker Compose setup will look for automatically which gives us a great, simple way to store things like your mysql database credentials outside of the repo.
107
+
108
+
By default the file will contain the following
109
+
110
+
```
111
+
MYSQL_ROOT_PASSWORD=root
112
+
MYSQL_DATABASE=myapp
113
+
MYSQL_USER=myapp
114
+
MYSQL_PASSWORD=myapp
115
+
```
116
+
117
+
Docker Compose will automatically replace things like `${MYSQL_USER}` in the `docker-compose.yml` file with whatever corresponding variables it finds defined in `.env`
118
+
119
+
Lastly, **Find/Replace**`myapp` with the name of your app.
104
120
105
121
> **WHY?** by default the files are set to name the containers based on your app prefix. By default this is `myapp`.
106
122
> A find/replace on `myapp` is safe and will allow you to customize the names of the containers
@@ -118,9 +134,13 @@ That's it. You can now access your CakePHP app at
118
134
119
135
`localhost:8180`
120
136
137
+
> **tip**: start docker-compose with `-d` to run (or re-run changed containers) in the background.
138
+
>
139
+
> `docker-compose up -d`
140
+
121
141
**Connecting to your database**
122
142
123
-
Also by default the first time you run the app it will create a `MySQL` database with the following credentials
143
+
Also by default the first time you run the app it will create a `MySQL` database with the credentials you specified in your `.env` file (see above)
124
144
125
145
```yaml
126
146
host : myapp-mysql
@@ -146,7 +166,7 @@ Your `app/config.php` file should be set to the following (it connects through t
146
166
],
147
167
```
148
168
149
-
To change these defaults edit the `docker-compose.yml` file under `myapp-mysql`'s `environment` section.
169
+
To change these defaults edit the variables in the `docker/.env` file or tweak the `docker-compose.yml` file under `myapp-mysql`'s `environment` section.
0 commit comments