From e034c5aba8d95ee011f72398eb77562b2638b322 Mon Sep 17 00:00:00 2001 From: marcel-gepardec Date: Fri, 9 Aug 2024 14:36:43 +0200 Subject: [PATCH] updated readme and cd.yml --- .github/workflows/cd.yml | 14 ++++++------ README.adoc | 49 ++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 02b2430..d2436df 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,16 +19,16 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -40,7 +40,7 @@ jobs: echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT - name: Build & push docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: true @@ -55,8 +55,8 @@ jobs: - name: Image digest run: echo ${{ steps.build-and-push.outputs.digest }} - - uses: appleboy/ssh-action@v1.0.0 - name: Pull image and start container + - name: Pull image and start container + uses: appleboy/ssh-action@v1.0.3 with: host: ${{ env.SSH_HOST }} username: ${{ env.SSH_USER }} diff --git a/README.adoc b/README.adoc index 6d59ef6..ee04d59 100644 --- a/README.adoc +++ b/README.adoc @@ -19,7 +19,7 @@ [source,bash] ---- #Run mysql docker container -docker run --detach --name mysql-api-demo -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=ApiDemo -p 3306:3306 mysql:8.1.0 +$ docker run --detach --name mysql-api-demo -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=ApiDemo -p 3306:3306 mysql:8.1.0 ---- ==== Configure mysql @@ -27,34 +27,34 @@ docker run --detach --name mysql-api-demo -e MYSQL_ROOT_PASSWORD=password -e MYS [source,bash] ---- #Connect to bash in container -docker exec -it mysql-api-demo mysql -u root -ppassword +$ docker exec -it mysql-api-demo mysql -u root -ppassword ---- [source,bash] ---- #Create new user -CREATE USER 'TEST'@'%' IDENTIFIED BY 'password'; +MYSQL> CREATE USER 'TEST'@'%' IDENTIFIED BY 'password'; #Grant rights to new user -GRANT ALL ON `ApiDemo`.* TO 'TEST'@'%'; +MYSQL> GRANT ALL ON `ApiDemo`.* TO 'TEST'@'%'; +MYSQL> FLUSH PRIVILEGES; -FLUSH PRIVILEGES; - -#Exit mysql and check if logging into new user works -exit -docker exec -it mysql-api-demo mysql -u TEST -ppassword +#Exit mysql +MYSQL> exit +#Check if logging into new user works +$ docker exec -it mysql-api-demo mysql -u TEST -ppassword ---- -==== Create MPDS-tables in local MySQL ==== +==== Create ApiDemo-tables in local MySQL ==== (config data will also be inserted in the database) [source,bash] ---- #Clean database -mvn flyway:clean +$ mvn flyway:clean ---- [source,bash] ---- #Migrate database -mvn flyway:migrate +$ mvn flyway:migrate ---- ==== Configure IntelliJ to work with MySQL @@ -73,19 +73,23 @@ URL should be: jdbc:mysql://localhost:3306/ApiDemo ==== Configurate DB Connection in Wildfly [source,bash] ---- -cd ../tools/wildfly-33.0.0.Final/bin/ +$ cd /home/.../tools/wildfly-33.0.0.Final/bin/ + +#Linux +$ sh jboss-cli.sh --connect +#Windows +> .\jboss-cli.bat --connect -sh jboss-cli.sh --connect -module add --name=com.mysql --resources=/home/.../api-demo/src/main/resources/wildfly/modules/com/mysql/main/mysql-connector-j-9.0.0.jar --dependencies=javax.api,javax.transaction.api +[standalone@localhost:9990 /] module add --name=com.mysql --resources=/home/.../api-demo/src/main/resources/wildfly/modules/com/mysql/main/mysql-connector-j-9.0.0.jar --dependencies=javax.api,javax.transaction.api -/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.cj.jdbc.MysqlXADataSource) +[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.cj.jdbc.MysqlXADataSource) -data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:mysql://localhost:3306/ApiDemo --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=mysql --user-name=TEST --password=password --transaction-isolation=TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=50 --pool-prefill=true --allocation-retry=3 --allocation-retry-wait-millis=100 --valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter --enabled=true +[standalone@localhost:9990 /] data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:mysql://localhost:3306/ApiDemo --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=mysql --user-name=TEST --password=password --transaction-isolation=TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=50 --pool-prefill=true --allocation-retry=3 --allocation-retry-wait-millis=100 --valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter --enabled=true -/extension=org.wildfly.extension.microprofile.openapi-smallrye:add() +[standalone@localhost:9990 /] /extension=org.wildfly.extension.microprofile.openapi-smallrye:add() -/subsystem=microprofile-openapi-smallrye:add() +[standalone@localhost:9990 /] /subsystem=microprofile-openapi-smallrye:add() ---- === After Configuration @@ -98,8 +102,9 @@ Now you can start the WildFly server. === Or build and run Docker image locally [source,bash] ---- -docker build --platform linux/amd64 --build-arg DB_USER_NAME=TEST --build-arg DB_USER_PASSWORD=password -t wildfly . - -docker run --detach -p 8080:8080 wildfly +#Build docker image +$ docker build --platform linux/amd64 --build-arg DB_USER_NAME=TEST --build-arg DB_USER_PASSWORD=password -t wildfly . +#Run docker image +$ docker run --detach -p 8080:8080 wildfly ----