Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions habitat/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"listen": {
"address": "{{cfg.listen.address}}",
"port": {{cfg.listen.port}}
},
"storage": {
"path": "{{cfg.storage.path}}"
}
}
7 changes: 7 additions & 0 deletions habitat/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[listen]
address = "0.0.0.0"
port = 8228

[storage]
path = "/srv/leverage/leverage.sqlite"

7 changes: 7 additions & 0 deletions habitat/hooks/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
ln -sf {{pkg.path}}/api/package.json {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/api/app.js {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/api/node_modules {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/api/lib {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/api/controllers {{pkg.svc_var_path}}
ln -sf {{pkg.svc_config_path}}/config.json {{pkg.svc_var_path}}
4 changes: 4 additions & 0 deletions habitat/hooks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd {{pkg.svc_var_path}}
exec node app.js 2>&1
65 changes: 65 additions & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
pkg_origin=leverage
pkg_name=leverage
pkg_version=0.1.0
pkg_maintainer="Chris Alfano <chris@codeforphilly.org>"
pkg_license=(MIT)
pkg_upstream_url=https://github.com/Lever-age/leverage
pkg_source=leverage.tar.gz
pkg_deps=(bochener/node)
pkg_expose=(8228)
pkg_build_deps=(core/coreutils core/git)
pkg_interpreters=(bin/env)

do_download() {
return 0
}

do_verify() {
return 0
}

do_unpack() {
return 0
}

do_prepare() {
# The `/usr/bin/env` path is hardcoded, so we'll add a symlink if needed.
# We can't do fix_interpreter here without adding a coreutils runtime dep.
if [[ ! -r /usr/bin/env ]]; then
ln -sv "$(pkg_path_for coreutils)/bin/env" /usr/bin/env
_clean_env=true
fi
}

do_build() {
git clone --depth 1 --branch develop https://github.com/Lever-age/api.git $HAB_CACHE_SRC_PATH/$pkg_dirname/api
git clone --depth 1 --branch develop https://github.com/Lever-age/frontend.git $HAB_CACHE_SRC_PATH/$pkg_dirname/frontend

cd $HAB_CACHE_SRC_PATH/$pkg_dirname/api
npm install
}

do_install() {
# Our source files were copied over to HAB_CACHE_SRC_PATH/$pkg_dirname in do_build(),
# and now they need to be copied from that directory into the root directory of our package
# through the use of the pkg_prefix variable.

mkdir -p ${pkg_prefix}/api
cp -v api/package.json ${pkg_prefix}/api
cp -v api/app.js ${pkg_prefix}/api
cp -vr api/controllers ${pkg_prefix}/api
cp -vr api/lib ${pkg_prefix}/api
cp -r api/node_modules ${pkg_prefix}/api

mkdir -p ${pkg_prefix}/frontend
cp -v frontend/*.html ${pkg_prefix}/frontend
cp -vr frontend/assets ${pkg_prefix}/assets
ln -vs discover.html ${pkg_prefix}/frontend/index.html
}

do_end() {
# Clean up the `env` link, if we set it up.
if [[ -n "$_clean_env" ]]; then
rm -fv /usr/bin/env
fi
}