Skip to content

Instantly share code, notes, and snippets.

View devigned's full-sized avatar

David Justice devigned

View GitHub Profile
@devigned
devigned / secrets.yml
Created May 11, 2017 00:30
Level 1 Secrets.yml
development:
secret_key_base: 39beccc6c842da3ba78f001a09dcb383bc45f927438f668392fc1ba354cd8ef487951c8ca9d6e70eab72af847ff831c3ae62888eae7a2b9c56cb5c202ea59ff1
test:
secret_key_base: 80f167c6678b032aca5c77a6feababbf9b9bbc46820bcd574053385f7e40c0f181dc55547b4b10bbc02df74fb7f64908ef8cfd238f5f35831ae0685dfce216e1
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
<% if Rails.env.production? # to save time, only run this when in production mode %>
@devigned
devigned / mongoid.yml
Created May 11, 2017 00:30
Level 1 Mongoid Config
development:
clients:
default:
database: todo_dev
hosts:
- <%= ENV['DB_HOST'] || 'localhost:27017' %>
test:
clients:
default:
database: todo_test
@devigned
devigned / deploy.rb
Created May 11, 2017 00:11
Level 1 Cap Deploy
# Change the 'YOUR_AZURE_VM_IP' to the publicIpAddress from the output of
# `az vm create` command executed above
require 'json'
role :app, JSON.parse(`az vmss list-instance-connection-info -g level1 -n level1-vmss`)
# Change the YOUR_GITHUB_NAME to your github user name
set :repo_url, '[email protected]:devigned/level1.git'
set :repo_tree, 'api-ruby'
set :application, 'level1'
set :user, 'deploy'
@devigned
devigned / provision.sh
Created May 10, 2017 23:40
level 1 provisioning script
#!/usr/bin/env bash
# add 'x' to the set command to see verbose output from each of the statements
set -eu
group_id="level1"
location="westus"
name_prefix="level1"
# shellcheck disable=SC2005
new_name=$(echo "$(mktemp -u ${name_prefix}XXXXX)" | tr '[:upper:]' '[:lower:]')
@devigned
devigned / cloud-init.yml
Last active May 12, 2017 16:03
cloud-init for level 1 blog post
#cloud-config
# Upgrade the instance on first boot
apt_upgrade: true
# Update apt database on first boot
apt_update: true
apt_sources:
- source: "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main"
@devigned
devigned / program.go
Created March 27, 2017 23:40
Domain name patch example
package main
import (
"fmt"
"io"
"net/http"
"os"
"sync"
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
@devigned
devigned / cap-initial-deploy.sh
Last active February 15, 2017 23:22
Initial Capistrano deploy (rails, nginx, puma)
# commit all of our changes and push them to the Github
git add .
git commit -am 'my first deploy'
git push origin master
# show what keys have been added to the ssh-agent (not needed, but helpful if debugging)
# ssh-add -l
# ensure you have added the id_rsa identity to your ssh agent
ssh-add ~/.ssh/id_rsa
@devigned
devigned / nginx.conf
Created February 15, 2017 17:30
Nginx config for Rails puma
upstream puma {
server unix:///home/deploy/apps/level0/shared/tmp/sockets/level0-puma.sock;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/deploy/apps/level0/current/public;
access_log /home/deploy/apps/level0/current/log/nginx.access.log;
@devigned
devigned / cap-puma-nginx-rails-config-deploy.rb
Last active February 1, 2023 07:13
Capistrano deploy configuration for simple puma, nginx rails application
# Change the 'YOUR_AZURE_VM_IP' to the publicIpAddress from the output of
# `az vm create` command executed above
server 'YOUR_AZURE_VM_IP', roles: [:web, :app, :db], primary: true
# Change the YOUR_GITHUB_NAME to your github user name
set :repo_url, '[email protected]:YOUR_GITHUB_NAME/level0.git'
set :application, 'level0'
set :user, 'deploy'
set :puma_threads, [4, 16]
set :puma_workers, 0
@devigned
devigned / Capfile
Last active February 15, 2017 15:58
# Load DSL and Setup Up Stages
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'