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
Copy file name to clipboardExpand all lines: jekyll/_cci2/postgres-config.md
+58-16Lines changed: 58 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -212,36 +212,78 @@ jobs:
212
212
path: /tmp/test-results
213
213
```
214
214
215
-
## Example Ruby Project with MYSQL and Dockerize
215
+
## Example MYSQL project.
216
216
217
-
The following example uses MySQL and dockerize, see the [sample project on GitHub](https://github.com/tkuchiki/wait-for-mysql-circleci-2.0) for additional links.
217
+
The following example sets up MYSQL as a secondary container alongside a PHP container.
218
218
219
219
```yaml
220
220
version: 2
221
221
jobs:
222
222
build:
223
-
working_directory: ~/test-circleci
224
223
docker:
225
-
- image: circleci/ruby:2.4-node-jessie
226
-
- image: tkuchiki/delayed-mysql
224
+
- image: circleci/php:7.1-apache-node-browsers # The primary container where steps are run
# Our primary container isn't MYSQL so run a sleep command until it's ready.
236
+
name: Waiting for MySQL to be ready
237
+
command: |
238
+
for i in `seq 1 10`;
239
+
do
240
+
nc -z 127.0.0.1 3306 && echo Success && exit 0
241
+
echo -n .
242
+
sleep 1
243
+
done
244
+
echo Failed waiting for MySQL && exit 1
240
245
- run:
241
-
name: MySQL version
242
-
command: bundle exec ruby mysql_version.rb
246
+
name: Install MySQL CLI; Import dummy data; run an example query
247
+
command: |
248
+
sudo apt-get install mysql-client
249
+
mysql -h 127.0.0.1 -u user -ppassw0rd test_db < sql-data/dummy.sql
250
+
mysql -h 127.0.0.1 -u user -ppassw0rd --execute="SELECT * FROM test_db.Persons"
251
+
workflows:
252
+
version: 2
253
+
build-deploy:
254
+
jobs:
255
+
- build
243
256
```
244
257
258
+
While it is possible to make MySQL as your primary and only container, this example
259
+
does not. As a more practical use case, the example uses a PHP docker image as
260
+
its primary container, and will wait until MySQL is up and running before performing any `run` commands
261
+
involving the DB.
262
+
263
+
Once the DB is up, we install the `mysql` client into the primary container so that we can run a command to connect and import the dummy data, presumably found at, `sql-data/dummy.sql` at the root of your project. In this case, that dummy data contains an example set of SQL commands:
0 commit comments