Last active
October 17, 2017 12:32
-
-
Save lnxchk/0a63e9f52f1ad680d6ecdd46a25b4410 to your computer and use it in GitHub Desktop.
Files for Habitat Java Workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{~#if bind.has_database}} | |
{{~#each bind.database.members}} | |
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{ip}} -DMONGODB_SERVICE_PORT={{port}}" | |
{{~/each}} | |
{{~/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg_name=national-parks | |
pkg_description="A sample JavaEE Web app deployed in the Tomcat8 package" | |
pkg_origin=manditest | |
pkg_version=0.1.3 | |
pkg_maintainer="Mandi <mandi@chef.io>" | |
pkg_license=('Apache-2.0') | |
pkg_source=https://github.com/billmeyer/national-parks | |
pkg_deps=(core/tomcat8 billmeyer/mongodb) | |
pkg_build_deps=(core/git core/maven) | |
pkg_expose=(8080) | |
pkg_svc_user="root" | |
do_download() { | |
build_line "do_download()======================================" | |
cd ${HAB_CACHE_SRC_PATH} | |
build_line "\$pkg_dirname=${pkg_dirname}" | |
build_line "\$pkg_filename=${pkg_filename}" | |
if [ -d "${pkg_dirname}" ]; then | |
rm -rf ${pkg_dirname} | |
fi | |
mkdir ${pkg_dirname} | |
cd ${pkg_dirname} | |
GIT_SSL_NO_VERIFY=true git clone --branch v${pkg_version} https://github.com/billmeyer/national-parks.git | |
return 0 | |
} | |
do_clean() { | |
build_line "do_clean() =======================================" | |
return 0 | |
} | |
do_unpack() { | |
# Nothing to unpack when pulling code straight from github | |
return 0 | |
} | |
do_build() { | |
build_line "do_build() =====================================" | |
# Maven requires JAVA_HOME to be set, and can be set via: | |
export JAVA_HOME=$(hab pkg path core/jdk8) | |
cd ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/${pkg_filename} | |
mvn package | |
} | |
do_install() { | |
build_line "do_install() ===================================" | |
# Our source files were copied over in do_build(), so now they | |
# need to be copied into the root of our package through the pkg_prefix | |
# variable so we have the source files available in the package. | |
local source_dir="${HAB_CACHE_SRC_PATH}/${pkg_dirname}/${pkg_filename}" | |
local webapps_dir="$(hab pkg path core/tomcat8)/tc/webapps" | |
cp ${source_dir}/target/${pkg_filename}.war ${webapps_dir}/ | |
# Seed data will be loaded into Mongo using our init hook | |
cp ${source_dir}/national-parks.json ${pkg_prefix}/ | |
} | |
do_verify() { | |
build_line "do_verify() ===================================" | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exec 2>&1 | |
echo "Seeding Mongo Collection" | |
MONGODB_HOME=$(hab pkg path billmeyer/mongodb) | |
source {{pkg.svc_config_path}}/mongoimport-opts.conf | |
echo "\$MONGOIMPORT_OPTS=$MONGOIMPORT_OPTS" | |
# billmeyer/mongodb requirement to run mongoimport properly : | |
ln -s $(hab pkg path core/glibc)/lib/ld-2.22.so /lib/ld-linux-x86-64.so.2 2>/dev/null | |
${MONGODB_HOME}/bin/mongoimport --drop -d demo -c nationalparks --type json --jsonArray --file $(hab pkg path {{pkg.origin}}/national-parks)/national-parks.json ${MONGOIMPORT_OPTS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{~#if bind.has_database}} | |
{{~#each bind.database.members}} | |
export MONGOIMPORT_OPTS="--host={{ip}} --port={{port}}" | |
{{~/each}} | |
{{~/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exec 2>&1 | |
echo "Starting Apache Tomcat" | |
export JAVA_HOME=$(hab pkg path core/jdk8) | |
export TOMCAT_HOME="$(hab pkg path core/tomcat8)/tc" | |
source {{pkg.svc_config_path}}/catalina-opts.conf | |
echo "\$CATALINA_OPTS=$CATALINA_OPTS" | |
exec ${TOMCAT_HOME}/bin/catalina.sh run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment