Skip to content

Instantly share code, notes, and snippets.

@double-z
Created August 9, 2016 10:32
Show Gist options
  • Save double-z/ff3c7743cca9c18d0306b3fef63f8976 to your computer and use it in GitHub Desktop.
Save double-z/ff3c7743cca9c18d0306b3fef63f8976 to your computer and use it in GitHub Desktop.
Habitat Quickstart Guide

#Habitat Quickstart Guide

Everything you need to run your first Habitat artifact (.hart package) inside of a docker-machine instance.

Based off my experiences trying to follow: https://www.habitat.sh/tutorials/getting-started-overview/

Dependencies

  • Docker 1.9+
  • Docker-Machine 0.5+
brew update
brew install docker-machine

####Habitat binaries: For reference, we'll install these in the following steps

Setup your Habitat origin/depot

You'll need this later when you're ready to upload your finished Habitat artifacts.

  • Go to https://app.habitat.sh/#/origins
  • Sign up, follow steps to setup Github auth
    • NOTE: Your email must be public in github settings
  • Add an origin for yourself

Optional: Beef up docker machine

# You could create a non-default instance here too,
# but the remaining steps will assume you used 'default'

# Skip if you don't already have a default docker-machine instance
docker-machine rm default

docker-machine create --driver virtualbox --virtualbox-cpu-count "2" --virtualbox-disk-size "40960" --virtualbox-memory "4096" default
eval $(docker-machine env default)

Install Habitat on OSX

curl -s -J -L -o /tmp/hab-darwin-0.8.0.tar.gz "https://bintray.com/habitat/stable/download_file?file_path=darwin%2Fx86_64%2Fhab-0.8.0-20160708205701-x86_64-darwin.zip"
unzip -u /tmp/hab-darwin-0.8.0.tar.gz -d /tmp
cp /tmp/hab-0.8.0-20160708205701-x86_64-darwin/hab /usr/local/bin/

# Answer 'Yes' to all the token/depot setup questions
# Use the same origin you setup in the Habitat UI
# Setup a github auth token when prompted and paste it in, needs 'user:email' rights only.
hab setup
hab origin key upload <your origin name>

Install Habitat on docker-machine

Add this to your bashrc/profile and run it:

function hab-init {
  eval $(docker-machine env default)
  # https://github.com/habitat-sh/habitat/issues/755
  docker-machine ssh default "sudo /usr/sbin/adduser -D hab"
  docker-machine ssh default "mkdir -p ~docker/.local/bin"
  curl -s -J -L -o /tmp/hab-0.8.0.tar.gz "https://bintray.com/habitat/stable/download_file?file_path=linux%2Fx86_64%2Fhab-0.8.0-20160708161531-x86_64-linux.tar.gz"
  tar --strip 1 -C /tmp -xzf /tmp/hab-0.8.0.tar.gz
  docker-machine scp /tmp/hab default:~docker/.local/bin/
  docker-machine scp -r ~/.hab default:
}

Run something!

See https://app.habitat.sh/#/pkgs/core for more pre-built Hab artifacts to run.

docker-machine ssh
sudo -s
hab start core/redis

Rebuild your docker/hab-machine from scratch

docker-machine restart
hab-init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment