Skip to content

Commit a0fc92f

Browse files
Merge pull request #7 from pmorie/eap
Add a JBossEAP on RHEL image
2 parents 6963712 + 9e40571 commit a0fc92f

10 files changed

+223
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rhel-jbosseap/*.zip
2+
rhel-jbosseap/*.jar

rhel-jbosseap/Dockerfile

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM rhel6:latest
2+
3+
ADD ./openshift-origin-deps.repo /etc/yum.repos.d/openshift-origin-deps.repo
4+
5+
# Execute system update
6+
RUN yum -y update
7+
8+
# Install packages necessary to install and run EAP
9+
RUN yum -y install java-1.7.0-openjdk-devel maven3 unzip
10+
RUN yum clean all
11+
12+
# Copy the EAP to image, unpack and clean up afterwards
13+
ADD jboss-eap-6.2.0.zip /opt/
14+
RUN unzip -q /opt/jboss-eap-6.2.0.zip -d /opt/
15+
16+
# Upgrade to 6.2.2
17+
ADD jboss-eap-6.2.2.zip /opt/
18+
RUN /opt/jboss-eap-6.2/bin/jboss-cli.sh --command="patch apply /opt/jboss-eap-6.2.2.zip"
19+
20+
# Install mysql module
21+
ADD mysql-module.xml /opt/jboss-eap-6.2/modules/system/layers/base/com/mysql/jdbc/main/module.xml
22+
ADD mysql-connector-java-5.1.30-bin.jar /opt/jboss-eap-6.2/modules/system/layers/base/com/mysql/jdbc/main/mysql-connector-java.jar
23+
24+
# Install the mongodb module
25+
ADD mongodb-module.xml /opt/jboss-eap-6.2/modules/system/layers/base/com/mongodb/main/module.xml
26+
ADD mongo-java-driver-2.9.3.jar /opt/jboss-eap-6.2/modules/system/layers/base/com/mongodb/main/mongo-java-driver.jar
27+
28+
RUN groupadd -r jbosseap -g 433 && \
29+
useradd -u 431 -r -g jbosseap -d /opt/jboss-eap-6.2 -s /sbin/nologin -c "JBossEAP user" jbosseap && \
30+
chown -R jbosseap:jbosseap /opt/jboss-eap-6.2
31+
32+
# Link the EAP installation
33+
RUN ln -s /opt/jboss-eap-6.2 /eap
34+
35+
# Add the launch script
36+
ADD launch /opt/jboss-eap-6.2/bin/
37+
38+
# Specify default values for entry point
39+
CMD ["/eap/bin/launch", "standalone", "-c", "standalone-ha.xml", "-b", "0.0.0.0"]
40+
41+
# Add scripts for sti compatibility
42+
ADD ./prepare /usr/bin/prepare
43+
ADD ./run /usr/bin/run
44+
ADD ./save-artifacts /usr/bin/save-artifacts
45+
RUN chmod a+rx /usr/bin/{prepare,run,save-artifacts}
46+
47+
USER jbosseap
48+
49+
# Expose ports
50+
EXPOSE 8080

rhel-jbosseap/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
rhel-jbosseap
2+
=============
3+
4+
JBoss Enterprise Application Platform 6.x (EAP) Red Hat Enterprise Linux 6
5+
6+
## Required binaries for build
7+
8+
To build this image, you will need the following binaries in the build context:
9+
10+
1. `jboss-eap-6.2.0.zip` and `jboss-eap-6.2.2.zip`
11+
2. [`mongo-java-driver-2.9.3.jar`](https://github.com/downloads/mongodb/mongo-java-driver/mongo-2.9.3.jar)
12+
3. [`mysql-connector-java-5.1.30-bin.jar`](https://dev.mysql.com/downloads/connector/j/)

rhel-jbosseap/launch

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
grep jbosseap /etc/passwd
4+
ls -l /opt/jboss-eap-6.2/standalone
5+
ls -l /opt/jboss-eap-6.2/standalone/configuration
6+
ls -l /opt/jboss-eap-6.2/standalone/configuration/application-users.properties
7+
8+
9+
if [ $# -lt 1 ]; then
10+
echo "Usage: $0 <configuration> [options]"
11+
echo
12+
echo "Launches JBoss EAP in the selected configuration with specified options (if any)"
13+
echo
14+
echo "<configuration> - standalone or domain"
15+
echo "[options] - options accepted by the standalone/domain.sh scripts"
16+
echo
17+
echo "Examples:"
18+
echo
19+
echo "* To run JBoss EAP in standalone mode with default options:"
20+
echo
21+
echo " $0 standalone"
22+
echo
23+
echo "* To run JBoss EAP in standalone mode with custom options:"
24+
echo
25+
echo " $0 standalone -b 0.0.0.0"
26+
exit 1
27+
fi
28+
29+
JBOSS_HOME=/opt/jboss-eap-6.2
30+
JBOSS_BIN_DIR=${JBOSS_HOME}/bin
31+
JBOSS_CLI=$JBOSS_BIN_DIR/jboss-cli.sh
32+
33+
function deploy() {
34+
echo "Deploying artifact $1..."
35+
36+
`$JBOSS_CLI -c "deploy $1" 2>&1 || :`
37+
if [ $? -eq 0 ]; then
38+
echo "Artifact $1 deployed"
39+
return 0
40+
fi
41+
42+
echo "Failed to deploy artifact $1"
43+
return 1
44+
}
45+
46+
function wait_for_server() {
47+
until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
48+
sleep 1
49+
done
50+
}
51+
52+
function deploy_all_wars() {
53+
artifact_dir=/opt/jboss-eap-6.2/artifacts
54+
55+
if [ ! -d "$artifact_dir" ]; then
56+
return 1
57+
fi
58+
59+
wait_for_server
60+
61+
for f in $artifact_dir/*.war
62+
do
63+
deploy $f
64+
done
65+
}
66+
67+
if [ "$1" = "standalone" ] || [ "$1" = "domain" ]; then
68+
CONFIGURATION=$1
69+
else
70+
echo "Only domain and standalone configuration are valid, you provided '$1'. Aborting."
71+
exit 1
72+
fi
73+
74+
# Run the deployment in the background
75+
deploy_all_wars &
76+
77+
shift 1
78+
79+
exec $JBOSS_HOME/bin/${CONFIGURATION}.sh $@
80+

rhel-jbosseap/mongodb-module.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<module xmlns="urn:jboss:module:1.1" name="com.mongodb">
4+
<resources>
5+
<resource-root path="mongo-java-driver.jar"/>
6+
</resources>
7+
8+
<dependencies>
9+
<module name="javax.api"/>
10+
</dependencies>
11+
</module>

rhel-jbosseap/mysql-module.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc">
4+
<resources>
5+
<resource-root path="mysql-connector-java.jar"/>
6+
</resources>
7+
8+
<dependencies>
9+
<module name="javax.api"/>
10+
<module name="javax.transaction.api"/>
11+
</dependencies>
12+
</module>
13+
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[openshift-origin-deps]
2+
name=openshift-origin-deps
3+
baseurl=http://mirror.openshift.com/pub/origin-server/release/3/rhel-6/dependencies/x86_64/
4+
gpgcheck=0
5+
enabled=1

rhel-jbosseap/prepare

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
function restore_saved_artifacts() {
4+
if [ -f /tmp/artifacts/maven.tar.gz ]; then
5+
pushd / &> /dev/null
6+
echo -n "Restoring saved artifacts from prior build..."
7+
tar zxf /tmp/artifacts/maven.tar.gz
8+
echo "...done"
9+
popd &> /dev/null
10+
fi
11+
}
12+
13+
local_source_dir=/opt/jboss-eap-6.2/sti-source
14+
artifact_dir=/opt/jboss-eap-6.2/artifacts
15+
16+
mkdir -p $local_source_dir
17+
mkdir -p $artifact_dir
18+
19+
cp -ad /tmp/src/* $local_source_dir
20+
21+
if [ -f "$local_source_dir/pom.xml" ]; then
22+
restore_saved_artifacts
23+
pushd $local_source_dir &> /dev/null
24+
mvn package
25+
26+
if [ $? -ne 0 ]; then
27+
exit $?
28+
fi
29+
30+
echo -n "Copying built war files into $artifact_dir for later deployment..."
31+
cp target/*.war $artifact_dir/
32+
echo "...done"
33+
34+
popd &> /dev/null
35+
else
36+
echo -n "Copying binaries in source directory into $artifact_dir for later deployment..."
37+
cp $local_source_dir/*.war $artifact_dir/
38+
echo "...done"
39+
fi
40+

rhel-jbosseap/run

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
/opt/jboss-eap-6.2/bin/launch standalone -c standalone-ha.xml -b 0.0.0.0 $@

rhel-jbosseap/save-artifacts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
echo -n "Saving build artifacts..."
4+
cd /
5+
tar czf /tmp/artifacts/maven.tar.gz opt/jboss-eap-6.2/.m2
6+
echo "...done"
7+

0 commit comments

Comments
 (0)