-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9afc4b
commit 63431f8
Showing
4 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
[holomapping] | ||
files = [ | ||
"*/**", | ||
"!.vscode/", | ||
"!docs/" | ||
"!.github/**", | ||
"!.vscode/**", | ||
"!cypress/**", | ||
"!docs/**", | ||
"!script/**", | ||
] | ||
after = "*" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
#!/bin/bash | ||
hab pkg install emergence/studio | ||
|
||
# install dependent studios | ||
hab pkg install emergence/studio jarvus/mkdocs-studio | ||
|
||
# disable studios printing their own help | ||
export STUDIO_NOHELP="yes" | ||
|
||
source "$(hab pkg path emergence/studio)/studio.sh" | ||
|
||
export DOCS_HOLOBRANCH="docs-site" | ||
source "$(hab pkg path jarvus/mkdocs-studio)/studio.sh" | ||
|
||
|
||
## final init and output | ||
studio-help | ||
|
||
|
||
# final blank line | ||
echo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
|
||
# script/-studio-bootstrap: Check dependencies for Chef Habitat studio. | ||
|
||
set -e | ||
cd "$(dirname "$0")/.." | ||
|
||
|
||
echo | ||
echo "==> studio-bootstrap: verifying Docker…" | ||
|
||
if ! [ -x "$(command -v docker)" ]; then | ||
echo "Please install Docker Engine: https://docs.docker.com/engine/install/" | ||
exit 1 | ||
fi | ||
|
||
if ! docker info > /dev/null 2>&1; then | ||
echo "Docker Engine is not running, or your user does not have access to connect." | ||
echo "Try starting Docker Engine, and adding your user to the docker group: sudo gpasswd -a $USER docker" | ||
exit 1 | ||
fi | ||
|
||
|
||
echo | ||
echo "==> studio-bootstrap: verifying Chef Habitat…" | ||
|
||
if ! [ -x "$(command -v hab)" ]; then | ||
echo "Please install Chef Habitat: https://www.habitat.sh/docs/install-habitat/" | ||
exit 1 | ||
fi | ||
|
||
set +e | ||
hab_version="$(hab --version < /dev/null)" | ||
if [ $? -ne 0 ]; then | ||
echo | ||
echo " Failed to read hab version, you may need to accept the Chef Habitat" | ||
echo " license. Please run \`hab setup\` or configure HAB_LICENSE in the environment" | ||
exit 1 | ||
fi | ||
set -e | ||
|
||
if ! [[ $hab_version =~ ^hab[[:space:]][0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]]; then | ||
echo | ||
echo " Could not parse hab version: ${hab_version}" | ||
echo " Please install hab 1.6+" | ||
exit 1 | ||
fi | ||
|
||
hab_version="$(echo "${hab_version}" | awk '{print $2}' | awk -F'/' '{print $1}')" | ||
echo " Found hab version: ${hab_version}" | ||
|
||
|
||
# check that node >= MAJOR.MINOR | ||
hab_min_major="1" | ||
hab_min_minor="6" | ||
|
||
IFS='.' read -ra hab_version_split <<< "${hab_version#v}" | ||
if [ "${hab_version_split[0]}" -lt "${hab_min_major}" ] || [[ "${hab_version_split[0]}" -le "${hab_min_major}" && "${hab_version_split[1]}" -lt "${hab_min_minor}" ]]; then | ||
echo | ||
echo " Please install hab >= ${hab_min_major}.${hab_min_minor}.x" | ||
exit 1 | ||
fi | ||
|
||
if ! [ -f ~/.hab/etc/cli.toml ] || ! grep -q '^origin =' ~/.hab/etc/cli.toml; then | ||
echo "Please re-run \`hab setup\` and choose to set a default origin, it can be anything" | ||
exit 1 | ||
fi | ||
|
||
_origin=$(awk -F'"' '/^origin = /{print $2}' ~/.hab/etc/cli.toml) | ||
|
||
|
||
echo | ||
echo "==> studio-bootstrap: verifying origin '${_origin}'…" | ||
|
||
_root_owned_key_count=$(ls -l ~/.hab/cache/keys | cut -f 3,4 -d " " | grep "root root" | wc -l) | ||
|
||
if [ "$_root_owned_key_count" -gt 0 ]; then | ||
echo "Working around: https://github.com/habitat-sh/habitat/issues/7737" | ||
echo "Found ${_root_owned_key_count} keys owned by root. Chowning them to $USER:$USER." | ||
sudo chown $USER:$USER ~/.hab/cache/keys/* | ||
fi | ||
|
||
if ! hab origin key export --type secret "${_origin}" > /dev/null; then | ||
echo "No key has been generated for origin ${_origin}, run: hab origin key generate ${_origin}" | ||
exit 1 | ||
fi | ||
|
||
|
||
echo | ||
echo "==> studio-bootstrap: all set 👍" | ||
echo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/sh | ||
|
||
# script/studio: Enter a Chef Habitat studio for the application. | ||
|
||
set -e | ||
cd "$(dirname "$0")/.." | ||
|
||
|
||
script/-studio-bootstrap | ||
|
||
|
||
unset DEBUG | ||
[ -n "${1}" ] && cd "${1}" | ||
|
||
|
||
echo | ||
echo "==> studio: configuring Chef Habitat studio Docker options…" | ||
STUDIO_NAME="${STUDIO_NAME:-laddr-studio}" | ||
export HAB_DOCKER_OPTS=" | ||
--name ${STUDIO_NAME} | ||
-p 9070:80 | ||
-p 9078:8000 | ||
-p 9076:3306 | ||
-v $(cd ~/.ssh; pwd)/known_hosts:/root/.ssh/known_hosts:ro | ||
--env STUDIO_DEVELOPER_UID=$(id -u) | ||
--env STUDIO_DEVELOPER_GID=$(id -g) | ||
" | ||
echo "${HAB_DOCKER_OPTS}" | ||
|
||
|
||
launch_studio=true | ||
if [ "$(docker ps -aq -f name="${STUDIO_NAME}")" ]; then | ||
echo | ||
echo "==> studio: a ${STUDIO_NAME} container is already running…" | ||
echo | ||
while true; do | ||
read -p "==> studio: would you like to (A)ttach to it, (s)top it, or do (n)othing? [A/s/n] " choice | ||
case "${choice}" in | ||
r|R|a|A|"") | ||
echo | ||
echo "==> studio: you can run studio-help at anytime to get a list of commands" | ||
echo | ||
docker attach "${STUDIO_NAME}" | ||
launch_studio=false | ||
break;; | ||
s|S) | ||
echo "==> studio: stopping existing container…" | ||
docker stop "${STUDIO_NAME}" > /dev/null | ||
break;; | ||
n|N) | ||
echo "==> studio: doing nothing with existing container… an error is likely to occur" | ||
break ;; | ||
*) | ||
echo "==> studio: $choice is invalid";; | ||
esac | ||
done | ||
fi | ||
|
||
if [ $launch_studio = true ]; then | ||
echo | ||
echo "==> studio: launching Docker-powered Chef Habitat studio…" | ||
set +e | ||
if ! hab studio enter -D; then | ||
echo "===> studio: failed to launch studio… try executing the following and try again:" | ||
echo "docker rm -f ${STUDIO_NAME}" | ||
fi | ||
fi |