Skip to content

Instantly share code, notes, and snippets.

@nathenharvey
Last active January 5, 2017 16:10
Show Gist options
  • Save nathenharvey/d6f74a065be68ab6d2055344ae254569 to your computer and use it in GitHub Desktop.
Save nathenharvey/d6f74a065be68ab6d2055344ae254569 to your computer and use it in GitHub Desktop.
national-parks lab
{{~#if bind.database}}
{{~#each bind.database.members}}
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{address}} -DMONGODB_SERVICE_PORT={{port}}"
{{~/each}}
{{~/if}}
#!/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 {{pkg.path}}/national-parks.json ${MONGOIMPORT_OPTS}
{{~#if bind.database}}
{{~#each bind.database.members}}
export MONGOIMPORT_OPTS="--host={{address}} --port={{port}}"
{{~/each}}
{{~/if}}
pkg_origin=firstnamelastname
pkg_name=national-parks
pkg_description="A sample JavaEE Web app deployed in Tomcat8"
pkg_version=0.1.3
pkg_maintainer="First Last <[email protected]>"
pkg_license=('Apache-2.0')
pkg_source=https://github.com/billmeyer/national-parks/archive/v${pkg_version}.tar.gz
pkg_shasum=56a70d7fc432ad275ba256150bd010ce2581346c848e40ddc0fd0f62c5b17a54
pkg_upstream_url=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"
pkg_svc_group="root"
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)
mvn package
}
do_install() {
build_line "do_install() ==================================="
# The files created during do_build() need to be copied into the
# tomcat webapps directory.
local webapps_dir="$(hab pkg path core/tomcat8)/tc/webapps"
cp target/${pkg_name}.war ${webapps_dir}/
# Seed data will be loaded into Mongo using our init hook
cp target/${pkg_name}.war ${pkg_prefix}
cp national-parks.json ${pkg_prefix}
}
#!/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"
cp "$(hab pkg path {{pkg.origin}}/{{pkg.name}})/{{pkg.name}}.war" "$TOMCAT_HOME/webapps/"
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