-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
61 lines (53 loc) · 2.83 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
59
60
61
# WildFly 8 on Docker with Centos 7 and OpenJDK 1.7
FROM jboss/wildfly:latest
# Maintainer
MAINTAINER Christian Metz <[email protected]>
# Appserver
ENV WILDFLY_USER admin
ENV WILDFLY_PASS adminPassword
# Database
ENV DB_NAME sample
ENV DB_USER mysql
ENV DB_PASS mysql
ENV DB_URI db:3306
ENV MYSQL_VERSION 6.0.6
ENV JBOSS_CLI /opt/jboss/wildfly/bin/jboss-cli.sh
ENV DEPLOYMENT_DIR /opt/jboss/wildfly/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
# 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-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)" && \
echo "=> Creating a new datasource" && \
$JBOSS_CLI --connect --command="data-source add \
--name=${DB_NAME}DS \
--jndi-name=java:/jdbc/datasources/${DB_NAME}DS \
--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 http and admin ports
EXPOSE 8080 9990
#echo "=> Restarting WildFly"
# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interfaces
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]