From a5aa1181573cb698ec2cfc0247b3240ad5763f7b Mon Sep 17 00:00:00 2001 From: marcel-gepardec Date: Thu, 8 Aug 2024 17:12:47 +0200 Subject: [PATCH] updated Dockerfile to generate war file --- Dockerfile | 28 ++++++++++++++++++---- src/main/resources/openapi/openapi-v1.yaml | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c9998a..686a642 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,21 @@ +# Stage 1: Build the WAR file using Maven +FROM maven:3.8.8-eclipse-temurin-17 AS build + +# Set the working directory +WORKDIR /app + +# Copy the pom.xml file and download dependencies +COPY pom.xml . + +# Download the dependencies +RUN mvn dependency:go-offline + +# Copy the rest of the application source code +COPY src ./src + +# Package the application to produce a WAR file +RUN mvn package + FROM quay.io/wildfly/wildfly:latest-jdk21 # Add Oracle driver module @@ -12,17 +30,17 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ sleep 10 && \ cd /tmp && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)" && \ - $JBOSS_HOME/bin/jboss-cli.sh --connect --command="data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:oracle:thin:@host.docker.internal:1521/XEPDB1?oracle.net.disableOob=true --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=oracle --user-name=${DB_USER_NAME} --password=${DB_USER_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.oracle.OracleValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter --enabled=true" && \ + $JBOSS_HOME/bin/jboss-cli.sh --connect --command="data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:oracle:thin:@host.docker.internal:1521/XEPDB1?oracle.net.disableOob=true --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=oracle --user-name="${DB_USER_NAME}" --password="${DB_USER_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.oracle.OracleValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter --enabled=true" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/extension=org.wildfly.extension.microprofile.openapi-smallrye:add()" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/subsystem=microprofile-openapi-smallrye:add()" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command=:shutdown; \ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ sleep 25; \ /bin/sh -c '$JBOSS_HOME/bin/standalone.sh -c=standalone.xml &' && \ - sleep 50 && \ + sleep 100 && \ cd /tmp && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)" && \ - $JBOSS_HOME/bin/jboss-cli.sh --connect --command="data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:oracle:thin:@host.docker.internal:1521/XEPDB1?oracle.net.disableOob=true --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=oracle --user-name=${DB_USER_NAME} --password=${DB_USER_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.oracle.OracleValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter --enabled=true" && \ + $JBOSS_HOME/bin/jboss-cli.sh --connect --command="data-source add --name=ApiDemoPersistenceDS --connection-url=jdbc:oracle:thin:@host.docker.internal:1521/XEPDB1?oracle.net.disableOob=true --jndi-name=java:jboss/datasources/ApiDemoPersistenceDS --driver-name=oracle --user-name="${DB_USER_NAME}" --password="${DB_USER_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.oracle.OracleValidConnectionChecker --validate-on-match=false --background-validation=true --background-validation-millis=30000 --stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter --enabled=true" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/extension=org.wildfly.extension.microprofile.openapi-smallrye:add()" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command="/subsystem=microprofile-openapi-smallrye:add()" && \ $JBOSS_HOME/bin/jboss-cli.sh --connect --command=:shutdown; \ @@ -34,8 +52,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ USER root RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent - -COPY ./target/*.war $JBOSS_HOME/standalone/deployments/ +WORKDIR /opt/jboss/wildfly/standalone/deployments/ +COPY --from=build /app/target/*.war $JBOSS_HOME/standalone/deployments/ ## Attempt fix permissions error ## # Attepmt to fix for Error: Could not rename /opt/jboss/wildfly/standalone/configuration/standalone_xml_history/current # See https://stackoverflow.com/questions/20965737/docker-jboss7-war-commit-server-boot-failed-in-an-unrecoverable-manner diff --git a/src/main/resources/openapi/openapi-v1.yaml b/src/main/resources/openapi/openapi-v1.yaml index b6e02e8..7a24a26 100644 --- a/src/main/resources/openapi/openapi-v1.yaml +++ b/src/main/resources/openapi/openapi-v1.yaml @@ -1,4 +1,4 @@ -openapi: 3.1.0 +openapi: 3.0.3 info: title: API Test description: API Test