commit
81ceab98f0
7 changed files with 155 additions and 0 deletions
-
87.sti/scripts/assemble.ignore
-
3.sti/scripts/run.ignore
-
4README.md
-
50pom.xml
-
0src/main/java/.gitkeep
-
0src/main/resources/.gitkeep
-
11src/main/webapp/index.html
@ -0,0 +1,87 @@ |
|||
#!/bin/bash |
|||
|
|||
# restore maven dependencies downloaded in a previous build, |
|||
# so they do not have to be downloaded again. |
|||
# /tmp/artifacts will only be present in the incremental build scenario |
|||
# in which the target image name is an existing docker image which contains |
|||
# dependencies from a prior build execution. |
|||
function restore_saved_artifacts() { |
|||
if [ -f /tmp/artifacts/maven.tar.gz ]; then |
|||
pushd / &> /dev/null |
|||
echo -n "Restoring saved artifacts from prior build..." |
|||
tar zxf /tmp/artifacts/maven.tar.gz |
|||
echo "...done" |
|||
popd &> /dev/null |
|||
fi |
|||
} |
|||
|
|||
# Source code provided to STI will be bind-mounted at /tmp/src |
|||
# and then copied into /opt/wildfly/source for building. |
|||
local_source_dir=/opt/wildfly/source |
|||
mkdir -p $local_source_dir |
|||
|
|||
# Resulting WAR files will be deployed to /wildfly/standalone/deployments |
|||
deploy_dir=/wildfly/standalone/deployments |
|||
mkdir -p $deploy_dir |
|||
|
|||
# Copy the source from the bind mount in preparation for compilation |
|||
cp -ad /tmp/src/* $local_source_dir |
|||
|
|||
# If a pom.xml is present, this is a normal build scenario |
|||
# so run maven. |
|||
if [ -f "$local_source_dir/pom.xml" ]; then |
|||
# restore any maven dependencies which will be present if this is an |
|||
# incremental build |
|||
restore_saved_artifacts |
|||
|
|||
pushd $local_source_dir &> /dev/null |
|||
JAVA_HOME=/etc/alternatives/java_sdk_1.7.0 |
|||
mvn clean package -Popenshift -DskipTests |
|||
err=$? |
|||
if [ $err -ne 0 ]; then |
|||
echo "Aborting due to error code $err from mvn package" |
|||
exit $err |
|||
fi |
|||
|
|||
echo "Copying built war files into $deploy_dir for later deployment..." |
|||
if [ -d $local_source_dir/target ]; then |
|||
cp $local_source_dir/target/*.war $deploy_dir >& /dev/null |
|||
fi |
|||
if [ -d $local_source_dir/deployments ]; then |
|||
cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null |
|||
fi |
|||
|
|||
if [ -d $local_source_dir/cfg ]; then |
|||
echo "Copying config files from project..." |
|||
cp cfg/* /wildfly/standalone/configuration |
|||
fi |
|||
|
|||
if [ -d $local_source_dir/modules ]; then |
|||
echo "Copying modules from project..." |
|||
mkdir /wildfly/provided_modules |
|||
cp -r modules/* /wildfly/provided_modules |
|||
fi |
|||
|
|||
echo "...done" |
|||
|
|||
popd &> /dev/null |
|||
else |
|||
echo "Copying binaries in source directory into $deploy_dir for later deployment..." |
|||
if [ -d $local_source_dir/target ]; then |
|||
cp $local_source_dir/target/*.war $deploy_dir >& /dev/null |
|||
fi |
|||
if [ -d $local_source_dir/deployments ]; then |
|||
cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null |
|||
fi |
|||
if [ -d $local_source_dir/cfg ]; then |
|||
echo "Copying config files from project..." |
|||
cp cfg/* /wildfly/standalone/configuration |
|||
fi |
|||
|
|||
if [ -d $local_source_dir/modules ]; then |
|||
echo "Copying modules from project..." |
|||
mkdir /wildfly/provided_modules |
|||
cp -r modules/* /wildfly/provided_modules |
|||
fi |
|||
echo "...done" |
|||
fi |
|||
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
echo hello world |
|||
exec /wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 |
|||
@ -0,0 +1,4 @@ |
|||
Getting Started with Java on OpenShift Sample Application |
|||
==================== |
|||
|
|||
This is a sample application for the book, Getting Started with Java on OpenShift |
|||
@ -0,0 +1,50 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>SampleApp</groupId> |
|||
<artifactId>SampleApp</artifactId> |
|||
<packaging>war</packaging> |
|||
<version>1.0</version> |
|||
<name>SampleApp</name> |
|||
|
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
<maven.compiler.source>1.7</maven.compiler.source> |
|||
<maven.compiler.target>1.7</maven.compiler.target> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>javax</groupId> |
|||
<artifactId>javaee-api</artifactId> |
|||
<version>7.0</version> |
|||
<scope>provided</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. --> |
|||
<!-- Use this profile for any OpenShift specific customization your app will need. --> |
|||
<!-- By default that is to put the resulting archive into the 'deployments' folder. --> |
|||
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html --> |
|||
<id>openshift</id> |
|||
<build> |
|||
<finalName>SampleApp</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-war-plugin</artifactId> |
|||
<version>2.3</version> |
|||
<configuration> |
|||
<failOnMissingWebXml>false</failOnMissingWebXml> |
|||
<outputDirectory>target</outputDirectory> |
|||
<warName>ROOT</warName> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
</profiles> |
|||
</project> |
|||
@ -0,0 +1,11 @@ |
|||
<!doctype html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<title>Welcome to OpenShift</title> |
|||
</head> |
|||
<body> |
|||
<h1>Welcome to Getting Started with Java on OpenShift!</h1> |
|||
</body> |
|||
</html> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue