Skip to content

Instantly share code, notes, and snippets.

@rkeppner
Last active January 12, 2016 00:33
Show Gist options
  • Select an option

  • Save rkeppner/fbc22cf459d1eb2f6833 to your computer and use it in GitHub Desktop.

Select an option

Save rkeppner/fbc22cf459d1eb2f6833 to your computer and use it in GitHub Desktop.
Creating a New Heroku Pipeline with Multiple Apps for HTML/PHP Hosting

Creating a New Heroku Pipeline with Multiple Apps for HTML/PHP Hosting

Scope

These directions are for setting up a new Heroku pipeline and adding 2 apps to it: staging and production. This is intended for hosting a "static" HTML site, not for Lar $ .

Prerequisites

  1. Configure your Laravel Homestead environment. Those directions are found elsewhere.

  2. If you haven't already done so, create an account at heroku.com.

  3. If you haven't done so previously, install the Heroku Toolbelt on your machine.

  4. If not done previously, install the Heroku pipeline addon:

     $ heroku plugins:install heroku-pipelines
    

Step-by-Step Instructions

Create and Configure the Git Repository

  1. Create an empty repository in Bitbucket: https://bitbucket.org/repo/create.

  2. Map the Git repository on your local environment:

     $ cd ~/Code
     $ mkdir keppnerhaus
     $ cd keppnerhaus
     $ git init
     $ git remote add origin [email protected]:rkeppner/keppnerhaus.git
    

Create Heroku pipeline and apps

Execute these commands in your local environment, to add the Heroku remotes for promotion:

$ heroku apps:create -b https://github.com/heroku/heroku-buildpack-php -r production keppnerhaus
$ heroku pipelines:create -s production -a keppnerhaus keppnerhaus
$ heroku apps:create -b https://github.com/heroku/heroku-buildpack-php -r staging keppnerhaus-staging
$ heroku pipelines:add -s staging -r staging keppnerhaus
$ git config heroku.remote staging

Add configuration files needed by Heroku

  1. Procfile
    Directives for Heroku environment configuration:

    web: vendor/bin/heroku-php-nginx -C nginx.conf
    
  2. nginx.conf
    Nginx configuration for the Heroku environment:

    # Nginx directives can be added below, as needed.
    location / {
        index index.html index.php;
    }
  3. composer.json
    Composer configuration file:

    {
        "name": "rkeppner/keppnerhaus",
        "description": "Keppnerhaus corporate website.",
        "license": "proprietary",
        "require": {
          "php": ">=5.6"
        }
    }
  4. index.php
    PHP home page.

  5. index.html
    HTML home page.

  6. .gitignore
    Instruct Git to ignore dependencies installed by Composer:

    /vendor
    

Deploy code to Heroku

  1. Commit changes to staging via Git (command line instructions given below, but this can also be done in SourceTree):

     $ composer update
     $ git add -A .
     $ git commit -m "Added Heroku configuration."
     $ git push -u origin master
     $ git push staging master
    
  2. Share/QA the results at: http://keppnerhaus-staging.herokuapp.com

  3. When approved, promote the changes to production:

     $ heroku pipelines:promote -r staging
    
  4. Double-check site at: http://keppnerhaus.herokuapp.com

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