Skip to content

Commit

Permalink
changed cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-gepardec committed Aug 8, 2024
1 parent dbc5bd7 commit 333dc74
Show file tree
Hide file tree
Showing 4 changed files with 584 additions and 69 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ jobs:
run: |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
- name: Build and Push Docker Image
run: |
docker buildx build --platform linux/amd64,linux/arm64 \
--tag ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest \
--build-arg DB_USER_NAME=${{ env.DB_USER_NAME }} \
--build-arg DB_USER_PASSWORD=${{ env.DB_USER_PASSWORD }} \
--push .
- name: Verify Image
run: |
docker pull ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
docker images
- name: Build & push docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64 # Specify the platforms you need
tags: ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest
file: Dockerfile # Adjust if your Dockerfile is not in the root directory
build-args: |
DB_USER_NAME=${{ env.DB_USER_NAME }}
DB_USER_PASSWORD=${{ env.DB_USER_PASSWORD }}
#Add here your environment Variables which you implemented above

- name: Image digest
run: echo ${{ steps.build-and-push.outputs.digest }}
Expand Down
77 changes: 21 additions & 56 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,34 @@ COPY src ./src
# Package the application to produce a WAR file
RUN mvn package

FROM quay.io/wildfly/wildfly:latest-jdk21
FROM quay.io/wildfly/wildfly:33.0.0.Final-jdk21

# Add Oracle driver module
COPY src/main/resources/wildfly/modules $JBOSS_HOME/modules

ARG DB_USER_NAME
ARG DB_USER_PASSWORD

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
/bin/sh -c '$JBOSS_HOME/bin/standalone.sh -c=standalone.xml &' && \
echo "Waiting for WildFly to be ready..." && \
for i in {1..30}; do \
if curl http://localhost:9990; then \
echo "WildFly is up and running!" && \
break; \
else \
echo "Waiting for WildFly... ($i/30)" && \
sleep 5; \
fi; \
done && \
if ! curl http://localhost:9990; then \
echo "WildFly did not start in time!" && \
echo "WildFly logs:" && \
cat $JBOSS_HOME/standalone/log/server.log && \
exit 1; \
fi && \
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="/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 &' && \
echo "Waiting for WildFly to be ready..." && \
for i in {1..30}; do \
if curl http://localhost:9990; then \
echo "WildFly is up and running!" && \
break; \
else \
echo "Waiting for WildFly... ($i/30)" && \
sleep 5; \
fi; \
done && \
if ! curl http://localhost:9990; then \
echo "WildFly did not start in time!" && \
echo "WildFly logs:" && \
cat $JBOSS_HOME/standalone/log/server.log && \
exit 1; \
fi && \
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="/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; \
else \
echo "Unknown architecture: ${TARGETPLATFORM}"; \
fi

# User root to modify war owners
ENV CONFIG_DIR=/tmp/config

ENV JBOSS_HOME=/opt/jboss/wildfly
ENV CONFIG_DIR=/tmp/config
ENV DEPLOYMENT_DIR=$JBOSS_HOME/standalone/deployments

# Create a temporary directory for configuration files
RUN mkdir -p $CONFIG_DIR

# Copy your standalone.xml to the temporary directory
COPY src/main/resources/wildfly/config/standalone.xml $CONFIG_DIR/

# Replace placeholder text in standalone.xml using sed
RUN sed -i 's/DB_USER_NAME/'${DB_USER_NAME}'/g' $CONFIG_DIR/standalone.xml
RUN sed -i 's/DB_USER_PASSWORD/'${DB_USER_PASSWORD}'/g' $CONFIG_DIR/standalone.xml

# Copy the modified standalone.xml to the WildFly configuration directory
RUN cp $CONFIG_DIR/standalone.xml $JBOSS_HOME/standalone/configuration/standalone.xml

# User root to modify war owners
USER root

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* docker

=== Product wide
* WildFly 27.0.1.Final
* WildFly 33.0.0.Final
* Oracle XE 21c

=== Database setup (Oracle XE 21c)
Expand Down
Loading

0 comments on commit 333dc74

Please sign in to comment.