Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip! feat(symphony-ws): Add Dockerfile #1

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions symphony-ws/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM maven:3.9.6-eclipse-temurin-17 as build

WORKDIR /app

COPY . .

RUN mvn package -DskipTests

FROM quay.io/wildfly/wildfly:26.1.2.Final-jdk17 as production

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

ENV DATASOURCE_NAME ApplicationDS
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if symphony-ws requires a specific name here.

ENV DATASOURCE_JNDI java:/SymphonyDS

ENV DB_HOST database
ENV DB_PORT 5432
ENV DB_USER user
ENV DB_PASS password
ENV DB_NAME symphony

# create temporary deployment dir, because wars can deploy after the datasource is created
USER jboss
RUN mkdir /tmp/deploments
ENV DEPLOY_DIR /tmp/deploments

RUN mkdir /tmp/jboss-cli
ENV CLI_DIR /tmp/jboss-cli

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
USER jboss

RUN wget -O /tmp/postgresql-42.2.28.jar https://jdbc.postgresql.org/download/postgresql-42.2.28.jre7.jar

COPY --from=build /app/target/symphony-ws-1.19.0-SNAPSHOT.war /tmp/deployments/

ENTRYPOINT $WILDFLY_HOME/bin/startWithPostgres.sh
65 changes: 65 additions & 0 deletions symphony-ws/startWithPostgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
zapling marked this conversation as resolved.
Show resolved Hide resolved

echo "=> Who Am I?"
whoami

if [ ! -f wildfly.started ]; then
JBOSS_CLI=$WILDFLY_HOME/bin/jboss-cli.sh

function wait_for_server() {
until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
echo "Waiting"
sleep 1
done
}

echo "=> Starting WildFly server"
$WILDFLY_HOME/bin/standalone.sh -b=0.0.0.0 -c standalone.xml > /dev/null &

echo "=> Waiting for the server to boot"
wait_for_server

echo "=> Setup Datasource"
$JBOSS_CLI -c << EOF
batch

# Add PostgreSQL driver
module add --name=org.postgres --resources=/tmp/postgresql-42.2.28.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 \
--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
EOF

FILES=$CLI_DIR/*.cli
for f in $FILES
do
echo "Processing $f file..."
$JBOSS_CLI -c --file=$f
done

echo "=> Shutdown Wildfly"
$JBOSS_CLI -c ":shutdown"

echo "=> DEPLOY WARs"
cp ${DEPLOY_DIR}/* ${WILDFLY_HOME}/standalone/deployments/

touch wildfly.started
fi

echo "=> Start Wildfly"
$WILDFLY_HOME/bin/standalone.sh -b=0.0.0.0 -c standalone.xml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme mentions the standalone-full.xml but unsure what the difference is