Skip to content

Instantly share code, notes, and snippets.

View devigned's full-sized avatar

David Justice devigned

View GitHub Profile
@devigned
devigned / rails-todo-hab-kube.sh
Last active March 7, 2018 14:07
Kubernetes commands for deploying Rails todo from private registry
# fetch the hostname of the Azure Container Registry
registry=$(az acr list -g habitat-k8s --query "[?starts_with(name, 'habk8s')] | [0].loginServer" -o tsv)
# run the image sourced from the private repository, and expose port 3000
kubectl run rails-todo --image=${registry}/rails-todo:latest --port 3000
# watch our pod provision
watch kubectl get po
# once the pod is running exit watch
@devigned
devigned / rails-todo-hab-img-push.sh
Created May 31, 2017 15:36
Push Habitat Rails todo image to private image registry
# fetch the hostname of the Azure Container Registry
registry=$(az acr list -g habitat-k8s --query "[?starts_with(name, 'habk8s')] | [0].loginServer" -o tsv)
# tag the latest image with our registry hostname
docker tag devigned/rails-todo:latest ${registry}/rails-todo:latest
# push the image to our private registry
docker push ${registry}/rails-todo:latest
@devigned
devigned / rails-todo-run.sh
Created May 31, 2017 14:35
Habitat run hook for Rails todo
#!/bin/sh
export GEM_HOME="{{pkg.svc_static_path}}/vendor/bundle/ruby/2.4.0"
export GEM_PATH="$(hab pkg path core/ruby)/lib/ruby/gems/2.4.0:$(hab pkg path core/bundler):$GEM_HOME"
export LD_LIBRARY_PATH="$(hab pkg path core/gcc-libs)/lib"
export RAILS_ENV="production"
export RAILS_SERVE_STATIC_FILES="true"
export SSL_CERT_FILE="$(hab pkg path core/cacerts)/ssl/certs/cacert.pem"
cd {{pkg.svc_static_path}}
@devigned
devigned / rails-todo-init.sh
Created May 31, 2017 14:29
Habitat init hook for Rails todo
#!/bin/sh
rm -rf {{pkg.svc_static_path}}/*
cp -R {{pkg.path}}/static/* {{pkg.svc_static_path}}
rm -rf "{{pkg.svc_static_path}}/config/secrets.yml" "{{pkg.svc_static_path}}/config/mongoid.yml"
ln -sf {{pkg.svc_config_path}}/secrets.yml {{pkg.svc_static_path}}/config/secrets.yml
ln -sf {{pkg.svc_config_path}}/mongoid.yml {{pkg.svc_static_path}}/config/mongoid.yml
@devigned
devigned / default.toml
Created May 30, 2017 23:44
Default toml for Rails todo Habitat demo
# Connection string for mongodb
mongodb_uri = "some_connection_string"
# our secret key for Rails (don't check this in...)
secret_key_base = "cb6bca2c702c8954382c30acb7ff98eaa1e53af5fe77292b9f825113ba6419714d39d1663ebabaf8ea138b4ed066252df7e77cb7dc27a7ec41f8bf61a728bbaa"
# Rails related IP info
rails_binding_ip = "0.0.0.0"
rails_port = 3000
@devigned
devigned / mongoid.yml
Created May 30, 2017 23:42
Habitat handlebars Mongoid configuration file
production:
clients:
default:
uri: {{cfg.mongodb_uri}}
options:
# The default timeout is 5, which is the time in seconds
# for a connection to time out.
# We recommend 15 because it allows for plenty of time
# in most operating environments.
connect_timeout: 15
@devigned
devigned / plan.sh
Last active May 31, 2017 14:48
Habitat plan for building a Rails application
pkg_origin=devigned
pkg_name=rails-todo
pkg_version=0.1.0
pkg_maintainer="David Justice"
pkg_license=('MIT')
pkg_upstream_url=https://github.com/devigned/hab-rails-todo
pkg_source=nosuchfile.tar.gz
pkg_deps=(
core/ruby/2.4.1
core/cacerts
@devigned
devigned / provision.sh
Last active June 8, 2017 19:50
Provision Azure Container Service (Kubernetes), Container Registry, CosmosDB and install Kubernetes developer tools
#!/usr/bin/env bash
set -euf -o pipefail
group="habitat-k8s"
location='westus'
vm_name="habitat-dev"
cluster_name="k8s-cluster"
name_prefix="habk8s"
new_name=$(echo $(mktemp -u ${name_prefix}XXXX) | tr '[:upper:]' '[:lower:]')
@devigned
devigned / run.sh
Created May 11, 2017 00:41
Level 1 - Run the app
git clone https://github.com/devigned/level1.git
cd level1/api-ruby
bundle install
bundle exec rails server
cd todo-ember
npm install
npm install -g ember-cli
ember serve
@devigned
devigned / deploy.sh
Created May 11, 2017 00:38
Level 1 - Deploy the App
git clone https://github.com/devigned/level1.git
cd level1
./script/provision.sh
cd api-ruby
bundle install
bundle exec cap production deploy:initial