Skip to content

Instantly share code, notes, and snippets.

@Sporky023
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sporky023/1e02f68941545ee93858 to your computer and use it in GitHub Desktop.
Save Sporky023/1e02f68941545ee93858 to your computer and use it in GitHub Desktop.

how to deploy app.vencaf.org to heroku

step 1: create a local copy (assumes you have git installed)

option A: get the code from github

visit github.com/vencaf/theapp in browser
on right side of page, click to save the "clone url"

git clone [paste clone url]
will look like: git clone git@github.com:vencaf/theapp.git

step 2: set up new deploy on heroku

cd theapp

within the app directory:

heroku apps:create vencaf-chigao --remote chicago

optional: confirm we're all set in git: cat .git/config. Output should look like:

Lukes-MacBook-Air:know_list luke$ cat .git/config
    
[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
  ignorecase = true
  precomposeunicode = true
[remote "origin"]
  url = git@github.com:vencaf/theapp.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[remote "chicago"]
  url = git@heroku.com:vencaf-chicago.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

The "remotes" are the important part.

  • one remote is called "origin", and that is the github repo
  • the other is called "chicago", and is the deploy on heroku

git push chicago master -> starts the deploy to heroku
Theoretically should work smoothly since it's the same as the code already deployed to heroku.
But this will probably fail with various errors.
Can paste these errors into google for solutions.

step 3: point subdomain at the new heroku deploy

add a CNAME record to the vencaf.org DNS with these values:

Name: chi.vencaf.org
TTL: 14400
Type: CNAME
Address: vencaf-chicago.herokuapp.com

see: http://stackoverflow.com/questions/13715556/how-to-point-subdomain-to-a-heroku-app-and-root-domain-to-another-heroku-app
Then assign the subdomain in heroku's system:
heroku domains:add --app vencaf-chicago.herokuapp.com chi.vencaf.org

That should do the trick, but will probably require debugging.

aside: making sure the app is ready to run in multiple places

Each separate running copy of the app, with its own database, is called "a deploy" of the app.
Each deploy of the app might require certain variables to differ.
For example, if storing images in S3, a different app should use a different S3 bucket.

has_attached_file(:portrait, storage: :s3, s3_options: {bucket_name: 'vencaf'})

Here the app is using an external service, and the connection is configured inside the code.
To allow for multiple deployes, the code should be changed to use an Environment Variable.

has_attached_file(:portrait, storage: :s3, s3_options: {bucket_name: ENV['S3_BUCKET_NAME']})

Environment variables are set using the "config" command on heroku like this:

heroku config:add S3_BUCKET_NAME=vencaf --app original-app.herokuapp.com
heroku config:add S3_BUCKET_NAME=vencaf-chi --app vencaf-chicago.herokuapp.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment