Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (67 sloc) 2.21 KB
### 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: