This repository has been archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose-using-healthcheck.yml
69 lines (67 loc) · 2.21 KB
/
docker-compose-using-healthcheck.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
### Before running any Compose services, make sure you have an .env file
# inside your current folder and that it has been populated with the following content:
# mysql_root_password=<MYSQL_ROOT_PASSWORD>
#
# mysql_database_name=jdbcwithdocker
# mysql_database_user=<DB_USER_NAME>
# mysql_database_password=<DB_PASSWORD>
#
# healthcheck_interval=2s
# healthcheck_timeout=5s
# healthcheck_retries=20
#
# java_jvm_flags=-Xmx512m
#
# java_debug_port=9876
# java_debug_settings=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9876
### Start Docker containers with the following command executed inside a Powershell run as admin:
# mvn `
# ;docker-compose --file docker-compose-using-healthcheck.yml down --rmi local `
# ;docker-compose --file docker-compose-using-healthcheck.yml build `
# ;docker-compose --file docker-compose-using-healthcheck.yml up
version: '2.3'
services:
db:
image: mysql:5.7.20
environment:
MYSQL_ROOT_PASSWORD: ${mysql_root_password}
MYSQL_DATABASE: ${mysql_database_name}
MYSQL_USER: ${mysql_database_user}
MYSQL_PASSWORD: ${mysql_database_password}
stdin_open: true
tty: true
healthcheck:
test: >
mysql \
--host='localhost' \
--user='${mysql_database_user}' \
--password='${mysql_database_password}' \
--execute='USE ${mysql_database_name}' \
interval: ${healthcheck_interval}
timeout: ${healthcheck_timeout}
retries: ${healthcheck_retries}
ports:
- 3306
volumes:
- jdbc-with-docker-mysql-data:/var/lib/mysql
app:
image: satrapu/jdbc-with-docker-console-runner
build:
context: .
dockerfile: ./Dockerfile-jdbc-with-docker-console-runner
args:
JAVA_DEBUG_PORT: ${java_debug_port}
environment:
JDBC_URL: jdbc:mysql://address=(protocol=tcp)(host=db)(port=3306)/${mysql_database_name}?useSSL=false
JDBC_USER: ${mysql_database_user}
JDBC_PASSWORD: ${mysql_database_password}
JAVA_OPTIONS: ${java_jvm_flags} ${java_debug_settings}
stdin_open: true
tty: true
ports:
- ${java_debug_port}
depends_on:
db:
condition: service_healthy
volumes:
jdbc-with-docker-mysql-data: