feat: better docker-compose
This commit is contained in:
parent
c92ad3244f
commit
be22ed4fe3
19
.env
Normal file
19
.env
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Paths
|
||||
INIT_PATH=./workdir/init/
|
||||
DEPLOYMENT_PATH=./build/libs/
|
||||
DATABASE_INIT_PATH=./workdir/db/init/
|
||||
DATABASE_DATA_PATH=./mysql-volume/
|
||||
|
||||
# Wildfly config
|
||||
WILDFLY_VERSION=23.0.0.Final
|
||||
WILDFLY_DEBUG=false
|
||||
WILDFLY_ADMIN_USER=admin
|
||||
WILDFLY_ADMIN_PASS=pass
|
||||
|
||||
# MySQL config
|
||||
MYSQL_VERSION=8.0
|
||||
MYSQL_DATABASE=pixel
|
||||
MYSQL_USER=mysql
|
||||
MYSQL_PASSWORD=mysql
|
||||
MYSQL_ROOT_PASSWORD=pass
|
||||
MYSQL_CONNECTOR_VERSION=8.0.23
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,4 +6,4 @@ build
|
|||
bin
|
||||
|
||||
# Ignore docker volume directory
|
||||
mariadb
|
||||
mysql-volume
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'war'
|
||||
id "org.wildfly.build.provision" version "0.0.11"
|
||||
}
|
||||
|
||||
provision {
|
||||
variables['wildfly.version'] = '11.0.0.Final'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -24,7 +19,7 @@ dependencies {
|
|||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
implementation 'org.hibernate:hibernate-core:5.4.30.Final'
|
||||
implementation 'mysql:mysql-connector-java:8.0.24'
|
||||
// implementation 'mysql:mysql-connector-java:8.0.24'
|
||||
|
||||
// des fonctions pratiques
|
||||
implementation 'org.apache.commons:commons-lang3:3.0'
|
||||
|
@ -36,7 +31,6 @@ dependencies {
|
|||
// pour des getters/setters auto
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
}
|
||||
|
|
|
@ -1,71 +1,60 @@
|
|||
version: "3"
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
wildfly:
|
||||
image: quay.io/wildfly/wildfly
|
||||
container_name: wildfly
|
||||
hostname: wildfly
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 9990:9990
|
||||
volumes:
|
||||
- ./build/libs/:/opt/jboss/wildfly/standalone/deployments/
|
||||
image: kaaass/wildfly-mysql
|
||||
environment:
|
||||
- WILDFLY_USERNAME=admin
|
||||
- WILDFLY_PASSWORD=password
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mariadb
|
||||
command: >
|
||||
bash -c '
|
||||
|
||||
(
|
||||
sleep 15 &&
|
||||
/opt/jboss/wildfly/bin/jboss-cli.sh \
|
||||
--connect controller=127.0.0.1 \
|
||||
--command=" \
|
||||
data-source add \
|
||||
--jndi-name=java:/MySqlDS \
|
||||
--name=MySQLDS \
|
||||
--connection-url=jdbc:mysql://$$DB_HOST:$$DB_PORT/mydatabase \
|
||||
--driver-name=backend.war_com.mysql.cj.jdbc.Driver_8_0 \
|
||||
--user-name=$$WILDFLY_USERNAME \
|
||||
--password=$$WILDFLY_PASSWORD \
|
||||
"
|
||||
)&
|
||||
|
||||
/opt/jboss/wildfly/bin/add-user.sh admin password --silent &&
|
||||
|
||||
/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0'
|
||||
- WILDFLY_DEBUG=${WILDFLY_DEBUG}
|
||||
- WILDFLY_USER=${WILDFLY_ADMIN_USER}
|
||||
- WILDFLY_PASS=${WILDFLY_ADMIN_PASS}
|
||||
- DB_NAME=${MYSQL_DATABASE}
|
||||
- DB_USER=${MYSQL_USER}
|
||||
- DB_PASS=${MYSQL_PASSWORD}
|
||||
- DB_URI=db:3306
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_healthy
|
||||
restart: always
|
||||
|
||||
mariadb:
|
||||
image: mariadb
|
||||
container_name: mariadb
|
||||
hostname: mariadb
|
||||
environment:
|
||||
- MYSQL_USER=user
|
||||
- MYSQL_PASSWORD=mypassword
|
||||
- MYSQL_DATABASE=mydatabase
|
||||
- MYSQL_ROOT_PASSWORD=rootpassword
|
||||
# db:
|
||||
# condition: service_healthy
|
||||
- db
|
||||
volumes:
|
||||
- ${DEPLOYMENT_PATH}:/opt/jboss/wildfly/standalone/deployments/:rw
|
||||
# - ${INIT_PATH}:/opt/jboss/wildfly/customization/init.d
|
||||
ports:
|
||||
- 3306:3306
|
||||
- "8080:8080" # application
|
||||
- "9990:9990" # admin console
|
||||
- "8787:8787" # java debug
|
||||
restart: unless-stopped
|
||||
db:
|
||||
container_name: db
|
||||
hostname: db
|
||||
image: "mysql:${MYSQL_VERSION}"
|
||||
environment:
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||
- MYSQL_USER=${MYSQL_USER}
|
||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||
volumes:
|
||||
- ./mariadb/:/var/lib/mysql/
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD-SHELL",
|
||||
'mysqladmin -p$$MYSQL_ROOT_PASSWORD -h localhost ping | grep "mysqld is alive" || exit 1',
|
||||
]
|
||||
interval: 2s
|
||||
retries: 10
|
||||
restart: always
|
||||
# - ${DATABASE_INIT_PATH}:/docker-entrypoint-initdb.d/ # init database
|
||||
- ${DATABASE_DATA_PATH}:/var/lib/mysql/ # data storage
|
||||
ports:
|
||||
- "13306:3306"
|
||||
# cap_add:
|
||||
# - SYS_NICE
|
||||
# healthcheck:
|
||||
# test:
|
||||
# [
|
||||
# "CMD-SHELL",
|
||||
# 'mysqladmin -p$$MYSQL_ROOT_PASSWORD -h localhost ping | grep "mysqld is alive" || exit 1',
|
||||
# ]
|
||||
# interval: 2s
|
||||
# retries: 20
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
wildfly_data:
|
||||
driver: local
|
||||
mariadb:
|
||||
db-data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
default:
|
||||
driver: bridge
|
||||
|
|
Loading…
Reference in a new issue