Last active
June 12, 2019 03:54
-
-
Save anthonygrees/18d3893c8c874846b9f32ed807277047 to your computer and use it in GitHub Desktop.
Habitat Jumpstart - National Parks
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=agr | |
pkg_version=1.0.0 | |
pkg_maintainer="Bill Meyer <[email protected]>" | |
pkg_license=('Apache-2.0') | |
pkg_deps=(core/tomcat8 core/corretto) | |
pkg_build_deps=(core/corretto core/maven) | |
pkg_svc_user="root" | |
#pkg_binds=( | |
# [database]="port" | |
#) | |
#pkg_exports=( | |
# [port]=server.port | |
#) | |
#pkg_exposes=(port) | |
do_prepare() | |
{ | |
export JAVA_HOME=$(hab pkg path core/jdk8) | |
} | |
do_build() | |
{ | |
cp -r $PLAN_CONTEXT/../ $HAB_CACHE_SRC_PATH/$pkg_dirname | |
cd ${HAB_CACHE_SRC_PATH}/${pkg_dirname} | |
mvn package | |
} | |
do_install() | |
{ | |
cp ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/target/${pkg_name}.war ${PREFIX}/ | |
} |
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 -x | |
echo "Preparing TOMCAT_HOME..." | |
# Move directories that ship in the package into place | |
cp -a {{pkgPathFor "core/tomcat8"}}/tc {{pkg.svc_var_path}}/ | |
cp {{pkg.path}}/*.war {{pkg.svc_var_path}}/tc/webapps | |
# Following lines are to copy project tomcat configs to run time tomcat8 directory | |
for file in $(cd {{pkg.svc_config_path}}; ls -1 *.xml) | |
do | |
echo "Linking $file" | |
target="${file//_//}" | |
ln -vsf {{pkg.svc_config_path}}/$file {{pkg.svc_var_path}}/tc/$target | |
done | |
echo "Done preparing TOMCAT_HOME" |
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 | |
export JAVA_HOME="{{pkgPathFor "core/jre8"}}" | |
export TOMCAT_HOME="{{pkgPathFor "core/tomcat8"}}/tc" | |
cp {{pkg.path}}/*.war $TOMCAT_HOME/webapps | |
exec ${TOMCAT_HOME}/bin/catalina.sh run |
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
[server] | |
port = "8080" | |
shutdown-port = "8005" | |
redirect-port = "8443" |
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= | |
pkg_version=1.0.0 | |
pkg_maintainer="Bill Meyer <[email protected]>" | |
pkg_license=('Apache-2.0') | |
pkg_deps=(core/tomcat8 core/corretto core/mongo-tools) | |
pkg_build_deps=(core/corretto core/maven) | |
pkg_svc_user="root" | |
pkg_binds=( | |
[database]="port" | |
) | |
pkg_exports=( | |
[port]=server.port | |
) | |
pkg_exposes=(port) | |
do_prepare() | |
{ | |
export JAVA_HOME=$(hab pkg path core/corretto) | |
} | |
do_build() | |
{ | |
cp -r $PLAN_CONTEXT/../ $HAB_CACHE_SRC_PATH/$pkg_dirname | |
cd ${HAB_CACHE_SRC_PATH}/${pkg_dirname} | |
mvn package | |
} | |
do_install() | |
{ | |
cp ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/target/${pkg_name}.war ${PREFIX}/ | |
cp -v ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/data/national-parks.json ${PREFIX}/ | |
} |
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 -x | |
echo "Preparing TOMCAT_HOME..." | |
# Move directories that ship in the package into place | |
cp -a {{pkgPathFor "core/tomcat8"}}/tc {{pkg.svc_var_path}}/ | |
cp {{pkg.path}}/*.war {{pkg.svc_var_path}}/tc/webapps | |
# Following lines are to copy project tomcat configs to run time tomcat8 directory | |
for file in $(cd {{pkg.svc_config_path}}; ls -1 *.xml) | |
do | |
echo "Linking $file" | |
target="${file//_//}" | |
ln -vsf {{pkg.svc_config_path}}/$file {{pkg.svc_var_path}}/tc/$target | |
done | |
echo "Done preparing TOMCAT_HOME" | |
{{#if bind.database ~}} | |
{{pkgPathFor "core/mongo-tools"}}/bin/mongoimport --drop -d demo -c nationalparks --type json --jsonArray --file {{pkg.path}}/national-parks.json --host={{bind.database.first.sys.ip}} --port={{bind.database.first.cfg.port}} | |
{{/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 | |
{{#if bind.database ~}} | |
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{bind.database.first.sys.ip}} | |
-DMONGODB_SERVICE_PORT={{bind.database.first.cfg.port}} | |
-DMONGODB_DATABASE={{cfg.mongodb_database}}" | |
{{/if ~}} | |
export JAVA_HOME="{{pkgPathFor "core/corretto"}}" | |
export TOMCAT_HOME="{{pkgPathFor "core/tomcat8"}}/tc" | |
cp {{pkg.path}}/*.war $TOMCAT_HOME/webapps | |
exec ${TOMCAT_HOME}/bin/catalina.sh run |
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
mongodb_database = "demo" | |
[server] | |
port = "8080" | |
shutdown-port = "8005" | |
redirect-port = "8443" |
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
[mongod] | |
[mongod.net] | |
bind_ip = "0.0.0.0" | |
[mongod.security] | |
cluster_auth_mode = "" |
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
maxconn = 32 | |
httpchk = 'GET /national-parks' | |
[front-end] | |
listen = '*' | |
port = 8085 | |
mode = 'http' | |
[status] | |
enabled = true | |
listen = '*' | |
port = 8000 | |
user = 'admin' | |
password = 'password' | |
uri = '/haproxy-stats' |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Map of National Parks</title> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/> | |
<script src="https://code.jquery.com/jquery-2.0.0.min.js"></script> | |
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | |
<style type="text/css"> | |
body { | |
padding: 0; | |
margin: 0; | |
} | |
html, body, #map { | |
height: 100%; | |
font-family: 'oswald'; | |
} | |
.leaflet-container .leaflet-control-zoom { | |
margin-left: 13px; | |
margin-top: 70px; | |
} | |
#map { | |
z-index: 1; | |
} | |
#title { | |
z-index: 2; | |
position: absolute; | |
left: 10px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1 id="title">U.S. National Parks v6.4.0</h1> | |
<div id="map"></div> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script> | |
<script type="text/coffeescript" src="scripts/sprite.coffee"></script> | |
<script type="text/coffeescript" src "script.coffee"></script> | |
<script> | |
center = new L.LatLng(39.82, -98.57); | |
zoom = 5; | |
var map = L.map('map').setView(center, zoom); | |
var markerLayerGroup = L.layerGroup().addTo(map); | |
L.tileLayer('https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=816f897a456b4595a09bf8e1d42cfa0b', { | |
maxZoom: 18, | |
attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>' | |
}).addTo(map); | |
function getPins(e) { | |
bounds = map.getBounds(); | |
url = "ws/parks/within?lat1=" + | |
bounds.getNorthEast().lat + "&lon1=" + bounds.getNorthEast().lng + | |
"&lat2=" + bounds.getSouthWest().lat + "&lon2=" + bounds.getSouthWest().lng; | |
$.get(url, pinTheMap, "json") | |
} | |
Number.prototype.toCurrencyString = function () { | |
return "$" + Math.floor(this).toLocaleString() + (this % 1).toFixed(2).toLocaleString().replace(/^0/, ''); | |
} | |
function pinTheMap(data) { | |
//clear the current pins | |
map.removeLayer(markerLayerGroup); | |
//add the new pins | |
var markerArray = new Array(data.length) | |
for (var i = 0; i < data.length; i++) { | |
nationalPark = data[i]; | |
var popupInformation = "<b>" + nationalPark.locationName + "</b></br>" + | |
nationalPark.address + "</br>" + | |
nationalPark.city + ", " + nationalPark.state + "</br>" + | |
nationalPark.zipCode + "</br>"; | |
markerArray[i] = L.marker( | |
[nationalPark.location.coordinates[1], nationalPark.location.coordinates[0]], { icon: L.icon({ iconUrl: 'images/redicon.png', iconAnchor: [12.5,40]}) }).bindPopup(popupInformation); | |
} | |
markerLayerGroup = L.layerGroup(markerArray).addTo(map); | |
} | |
map.on('dragend', getPins); | |
map.on('zoomend', getPins); | |
map.whenReady(getPins) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment