-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (51 loc) · 2.68 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Use a custom WildFly for Jakarta EE 9 image from LabES.
FROM labesufes/wildfly-jakarta-ee
# Appserver
ENV WILDFLY_USER admin
ENV WILDFLY_PASS adminPassword
# Database
ENV DB_NAME smartbid
ENV DB_USER smartbid
ENV DB_PASS smartbid
ENV DB_URI mysql
ENV MYSQL_VERSION 8.0.11
ENV JBOSS_HOME /opt/wildfly
ENV JBOSS_CLI $JBOSS_HOME/bin/jboss-cli.sh
ENV DEPLOYMENT_DIR $JBOSS_HOME/standalone/deployments/
#ENV JAVA_OPTS
# Setting up WildFly Admin Console
RUN echo "=> Adding WildFly administrator"
RUN $JBOSS_HOME/bin/add-user.sh -u $WILDFLY_USER -p $WILDFLY_PASS --silent
#ADD standalone.conf $JBOSS_HOME/bin/standalone.conf
# Configure Wildfly server
RUN echo "=> Starting WildFly server" && \
bash -c '$JBOSS_HOME/bin/standalone.sh &' && \
echo "=> Waiting for the server to boot" && \
bash -c 'until `$JBOSS_CLI -c ":read-attribute(name=server-state)" 2> /dev/null | grep -q running`; do echo `$JBOSS_CLI -c ":read-attribute(name=server-state)" 2> /dev/null`; sleep 1; done' && \
echo "=> Downloading MySQL driver" && \
curl --location --output /tmp/mysql-connector-java-${MYSQL_VERSION}.jar --url http://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/${MYSQL_VERSION}/mysql-connector-java-${MYSQL_VERSION}.jar && \
echo "=> Adding MySQL module" && \
$JBOSS_CLI --connect --command="module add --name=com.mysql --resources=/tmp/mysql-connector-java-${MYSQL_VERSION}.jar --dependencies=javax.api,javax.transaction.api" && \
echo "=> Adding MySQL driver" && \
#/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql.driver,driver-class-name=com.mysql.jdbc.Driver)
$JBOSS_CLI --connect --command="/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.cj.jdbc.Driver)" && \
echo "=> Creating a new datasource" && \
$JBOSS_CLI --connect --command="data-source add \
--name=${DB_NAME} \
--jndi-name=java:jboss/datasources/${DB_NAME} \
--user-name=${DB_USER} \
--password=${DB_PASS} \
--driver-name=mysql \
--connection-url=jdbc:mysql://${DB_URI}/${DB_NAME} \
--use-ccm=false \
--max-pool-size=25 \
--blocking-timeout-wait-millis=5000 \
--enabled=true" && \
echo "=> Shutting down WildFly and Cleaning up" && \
$JBOSS_CLI --connect --command=":shutdown" && \
rm -rf $JBOSS_HOME/standalone/configuration/standalone_xml_history/ $JBOSS_HOME/standalone/log/* && \
rm -f /tmp/*.jar
EXPOSE 8787
# Copy the Web application to the server.
RUN echo "=> Deploying the application..."
ADD target/SmartBid-1.0-SNAPSHOT.war $DEPLOYMENT_DIR