Skip to content

Commit

Permalink
upgrade to wildfly 18, added validation query for database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonin Stoklasek committed Oct 13, 2019
1 parent 69daf5e commit 78be81b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
FROM tonda100/wildfly-empty
FROM jboss/wildfly:18.0.0.Final
MAINTAINER Antonin Stoklasek

ENV WILDFLY_HOME /opt/jboss/wildfly
ENV DEPLOY_DIR ${WILDFLY_HOME}/standalone/deployments/

# setup timezone
ENV TZ=Europe/Prague
USER root
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
USER jboss

ENV DATASOURCE_NAME ApplicationDS
ENV DATASOURCE_JNDI java:/ApplicationDS

Expand All @@ -22,9 +31,8 @@ COPY startWithPostgres.sh $WILDFLY_HOME/bin
USER root
RUN chown jboss:jboss $WILDFLY_HOME/bin/startWithPostgres.sh
RUN chmod 755 $WILDFLY_HOME/bin/startWithPostgres.sh
RUN yum -y install wget
USER jboss

RUN wget -P /tmp https://jdbc.postgresql.org/download/postgresql-9.4.1212.jar
COPY postgresql-42.2.8.jar /tmp

ENTRYPOINT $WILDFLY_HOME/bin/startWithPostgres.sh
ENTRYPOINT $WILDFLY_HOME/bin/startWithPostgres.sh
Binary file added postgresql-42.2.8.jar
Binary file not shown.
15 changes: 13 additions & 2 deletions startWithPostgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ $JBOSS_CLI -c << EOF
batch
# Add PostgreSQL driver
module add --name=org.postgres --resources=/tmp/postgresql-9.4.1212.jar --dependencies=javax.api,javax.transaction.api
module add --name=org.postgres --resources=/tmp/postgresql-42.2.8.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
# Add the datasource
data-source add --jndi-name=$DATASOURCE_JNDI --name=$DATASOURCE_NAME --connection-url=jdbc:postgresql://$DB_HOST:$DB_PORT/$DB_NAME --driver-name=postgres --user-name=$DB_USER --password=$DB_PASS
data-source add \
--jndi-name=$DATASOURCE_JNDI \
--name=$DATASOURCE_NAME \
--connection-url=jdbc:postgresql://$DB_HOST:$DB_PORT/$DB_NAME \
--driver-name=postgres \
--user-name=$DB_USER \
--password=$DB_PASS \
--check-valid-connection-sql="SELECT 1" \
--background-validation=true \
--background-validation-millis=60000 \
--flush-strategy=IdleConnections \
--min-pool-size=10 --max-pool-size=100 --pool-prefill=false
# Execute the batch
run-batch
Expand Down

0 comments on commit 78be81b

Please sign in to comment.