feat: better docker-compose

This commit is contained in:
Laureηt 2022-05-07 16:35:50 +02:00
parent c92ad3244f
commit be22ed4fe3
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
4 changed files with 70 additions and 68 deletions

19
.env Normal file
View 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
View file

@ -6,4 +6,4 @@ build
bin bin
# Ignore docker volume directory # Ignore docker volume directory
mariadb mysql-volume

View file

@ -1,11 +1,6 @@
plugins { plugins {
id 'java' id 'java'
id 'war' id 'war'
id "org.wildfly.build.provision" version "0.0.11"
}
provision {
variables['wildfly.version'] = '11.0.0.Final'
} }
repositories { repositories {
@ -24,7 +19,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.hibernate:hibernate-core:5.4.30.Final' 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 // des fonctions pratiques
implementation 'org.apache.commons:commons-lang3:3.0' implementation 'org.apache.commons:commons-lang3:3.0'
@ -36,7 +31,6 @@ dependencies {
// pour des getters/setters auto // pour des getters/setters auto
compileOnly 'org.projectlombok:lombok:1.18.24' compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24' testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
} }

View file

@ -1,71 +1,60 @@
version: "3" version: "2"
services: services:
wildfly: wildfly:
image: quay.io/wildfly/wildfly
container_name: wildfly container_name: wildfly
hostname: wildfly hostname: wildfly
ports: image: kaaass/wildfly-mysql
- 8080:8080
- 9990:9990
volumes:
- ./build/libs/:/opt/jboss/wildfly/standalone/deployments/
environment: environment:
- WILDFLY_USERNAME=admin - WILDFLY_DEBUG=${WILDFLY_DEBUG}
- WILDFLY_PASSWORD=password - WILDFLY_USER=${WILDFLY_ADMIN_USER}
- DB_PORT=3306 - WILDFLY_PASS=${WILDFLY_ADMIN_PASS}
- DB_HOST=mariadb - DB_NAME=${MYSQL_DATABASE}
command: > - DB_USER=${MYSQL_USER}
bash -c ' - DB_PASS=${MYSQL_PASSWORD}
- DB_URI=db:3306
(
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'
depends_on: depends_on:
mariadb: # db:
condition: service_healthy # condition: service_healthy
restart: always - db
volumes:
mariadb: - ${DEPLOYMENT_PATH}:/opt/jboss/wildfly/standalone/deployments/:rw
image: mariadb # - ${INIT_PATH}:/opt/jboss/wildfly/customization/init.d
container_name: mariadb
hostname: mariadb
environment:
- MYSQL_USER=user
- MYSQL_PASSWORD=mypassword
- MYSQL_DATABASE=mydatabase
- MYSQL_ROOT_PASSWORD=rootpassword
ports: 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: volumes:
- ./mariadb/:/var/lib/mysql/ # - ${DATABASE_INIT_PATH}:/docker-entrypoint-initdb.d/ # init database
healthcheck: - ${DATABASE_DATA_PATH}:/var/lib/mysql/ # data storage
test: ports:
[ - "13306:3306"
"CMD-SHELL", # cap_add:
'mysqladmin -p$$MYSQL_ROOT_PASSWORD -h localhost ping | grep "mysqld is alive" || exit 1', # - SYS_NICE
] # healthcheck:
interval: 2s # test:
retries: 10 # [
restart: always # "CMD-SHELL",
# 'mysqladmin -p$$MYSQL_ROOT_PASSWORD -h localhost ping | grep "mysqld is alive" || exit 1',
# ]
# interval: 2s
# retries: 20
restart: unless-stopped
volumes: volumes:
wildfly_data: db-data:
driver: local
mariadb:
driver: local driver: local
networks:
default:
driver: bridge