Skip to content

Commit d21be95

Browse files
Merge pull request #325 from CodeForPhilly/features/bindable-habitat
Bindable Habitat deploy option
2 parents 00d41f3 + bec7ac7 commit d21be95

File tree

6 files changed

+101
-21
lines changed

6 files changed

+101
-21
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Release Process](./operations/release-process.md)
1313
- [The `chime-live` Cluster](./operations/chime-live-cluster.md)
1414
- [Deploy to Heroku](./operations/heroku.md)
15+
- [Deploy with Chef Habitat](./operations/habitat.md)
1516
- [Deploy to Your Own Cluster](./operations/byok8s.md)
1617
- [Manual Validation](./operations/manual-validation.md)
1718
- [Limited Cluster Access for Deployment](./operations/limited-kubeconfigs/limited-kubeconfigs.md)

docs/operations/habitat.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Operations: Deploy with Chef Habitat
2+
3+
CHIME can be quickly deployed to any Linux system with [Chef Habitat](https://habitat.sh):
4+
5+
```bash
6+
hab svc load codeforphilly/chime
7+
```
8+
9+
This will download the latest CHIME build from [bldr.habitat.sh](bldr.habitat.sh) and start it as a service, serving the interface on the default port of [`8000`](http://localhost:8000)
10+
11+
## Enable HTTPS access
12+
13+
Providing HTTPS access can be easily done by making use of [Caddy](https://caddyserver.com/) and its built-in automatic HTTPS.
14+
15+
First, start the `jarvus/caddy-proxy` service with your CHIME service instance bound to the `backend` slot:
16+
17+
```bash
18+
hab svc load jarvus/caddy-proxy --bind backend:chime.default
19+
```
20+
21+
This will open an HTTP interface on port `80` that proxies to the CHIME service on port `8000`.
22+
23+
To enable the HTTPS interface, configure an email address and at least one publicly-resolvable hostname so that Caddy can use [Let's Encrypt](https://letsencrypt.org/) to automatically obtain a free SSL certificate:
24+
25+
```bash
26+
mkdir -p /hab/user/caddy-proxy/config
27+
28+
# use the editor of your choice:
29+
vim /hab/user/caddy-proxy/config/user.toml
30+
```
31+
32+
```toml
33+
hostnames = [
34+
"mydomain.org"
35+
]
36+
37+
[tls]
38+
39+
```
40+
41+
After you save `user.toml`, the Habitat supervisor will automatically detect the change and apply it. CHIME should now be available via HTTPS, with the HTTP port automatically redirecting.

habitat/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
## Habitat Service Package for CHIME
1+
# Habitat Service Package for CHIME
2+
23
This package can be used to run CHIME as a fully self-contained application.
34
See https://habitat.sh for more details.
45

5-
### Examples
6+
## Examples
7+
68
Quickstart With Docker "Shim" Container:
7-
```
8-
docker run -it -p 8000:8000 bixu/hab hab sup run "bixu/chime" --channel="unstable"
9+
10+
```bash
11+
docker run -it -p 8000:8000 bixu/hab hab sup run "codeforphilly/chime" --channel="unstable"
912
```
1013

1114
Local Prototyping Example:
12-
```
15+
16+
```bash
1317
set -e
1418
curl --silent "https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh" | sudo bash -s
1519
hab cli setup
@@ -20,7 +24,8 @@ hab sup run $HAB_ORIGIN/chime --channel="unstable"
2024
```
2125

2226
Complete `systemd` Bootstrap Example:
23-
```
27+
28+
```bash
2429
echo 'HAB_AUTH_TOKEN="<enter your token from https://bldr.habitat.sh/#/profile>"
2530
HAB_LICENSE="accept"
2631
HAB_NONINTERACTIVE="true"
@@ -50,5 +55,5 @@ sudo systemctl restart supervisor
5055
sudo groupadd hab || true
5156
sudo useradd --system --gid hab hab || true
5257

53-
sudo hab svc load "bixu/chime" --channel="unstable"
54-
```
58+
sudo hab svc load "codeforphilly/chime" --channel="unstable"
59+
```

habitat/config/.streamlit/config.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
[server]
2-
enableCORS = false
3-
headless = true
4-
port = 8000
1+
{{toToml cfg.streamlit}}

habitat/default.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[streamlit.server]
2+
enableCORS = false
3+
headless = true
4+
port = 8000

habitat/plan.sh

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
pkg_origin="bixu"
1+
pkg_origin="codeforphilly"
22
pkg_name="chime"
3-
pkg_version="0.1.0"
4-
pkg_maintainer="Blake Irvin <[email protected]>"
3+
pkg_maintainer="Code for Philly <[email protected]>"
54
pkg_license=('MIT')
65
pkg_deps=(
76
"core/python"
@@ -17,19 +16,52 @@ pkg_bin_dirs=(
1716
)
1817
pkg_svc_user="root"
1918

20-
do_prepare() {
21-
if ! ls "/etc/sudoers" &> "/dev/null"
22-
then
23-
echo "root ALL=(ALL) ALL" >> "/etc/sudoers"
19+
pkg_exports=(
20+
[port]=streamlit.server.port
21+
)
22+
23+
pkg_version() {
24+
if [ -n "${pkg_last_tag}" ]; then
25+
if [ ${pkg_last_tag_distance} -eq 0 ]; then
26+
echo "${pkg_last_version}"
27+
else
28+
echo "${pkg_last_version}-git+${pkg_last_tag_distance}.${pkg_commit}"
29+
fi
30+
else
31+
echo "${pkg_last_version}-git.${pkg_commit}"
2432
fi
33+
}
34+
35+
do_before() {
36+
do_default_before
37+
38+
# configure git repository
39+
export GIT_DIR="${PLAN_CONTEXT}/../.git"
40+
41+
# load version information from git
42+
pkg_commit="$(git rev-parse --short HEAD)"
43+
pkg_last_tag="$(git describe --tags --abbrev=0 ${pkg_commit} || true 2>/dev/null)"
44+
45+
if [ -n "${pkg_last_tag}" ]; then
46+
pkg_last_version=${pkg_last_tag#v}
47+
pkg_last_tag_distance="$(git rev-list ${pkg_last_tag}..${pkg_commit} --count)"
48+
else
49+
pkg_last_version="0.0.0"
50+
fi
51+
52+
# initialize pkg_version
53+
update_pkg_version
54+
}
55+
56+
do_prepare() {
2557
python -m venv "${pkg_prefix}"
2658
source "${pkg_prefix}/bin/activate"
27-
pip install --upgrade --force-reinstall "pip" "wheel"
59+
pip install --upgrade --force-reinstall "pip" "wheel" "setuptools"
2860
return $?
2961
}
3062

3163
do_build() {
32-
pip install -r ${PLAN_CONTEXT}/../requirements.txt
64+
pip install ${PLAN_CONTEXT}/../
3365
return $?
3466
}
3567

0 commit comments

Comments
 (0)