Skip to content

Deploy with Heroku

JP Barbosa edited this page May 28, 2016 · 9 revisions

Deploy with Heroku

Add bower install and gulp --production to composer.json
nano composer.json
...
    "scripts": {
        ...
        "compile": [
            "./node_modules/.bin/bower install",
            "./node_modules/.bin/gulp --production"
        ]
    },
    ...
composer update
Add procfile
nano Procfile
web: vendor/bin/heroku-php-apache2 public/
worker: php artisan queue:listen
Add deploy with Heroku to Git
git add .
git commit -m "Add deploy with Heroku"
Create Heroku App
heroku create
Set buildpacks (Node must be the first)
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php
heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs
Get host name
export HOST_NAME_HEROKU=`heroku domains | grep herokuapp.com`
Add host name to Recaptcha domains
open https://www.google.com/recaptcha/admin#list
Create database and Redis
heroku addons:create heroku-postgresql:hobby-dev
heroku addons:create heroku-redis:hobby-dev
Get Postgres and Redis connection info
heroku config:get DATABASE_URL
heroku config:get REDIS_URL
Set ENV variables to Heroku
source .env
heroku config:set \
       APP_DEBUG=false \
       APP_ENV=production \
       APP_KEY=$APP_KEY \
       APP_LOG=errorlog \
       APP_URL=http://$HOST_NAME_HEROKU \
       CACHE_DRIVER=$CACHE_DRIVER \
       HOST_NAME=$HOST_NAME_HEROKU \
       DB_CONNECTION=pgsql \
       DB_DATABASE= \
       DB_HOST= \
       DB_PASSWORD= \
       DB_USERNAME= \
       MAIL_DRIVER=$MAIL_DRIVER \
       MAIL_HOST=$MAIL_HOST \
       MAIL_PORT=$MAIL_PORT \
       MAIL_USERNAME=$MAIL_USER \
       MAIL_PASSWORD=$MAIL_PASS \
       MAIL_ADDRESS=$MAIL_ADDRESS \
       MAIL_NAME="$MAIL_NAME" \
       QUEUE_DRIVER=$QUEUE_DRIVER \
       RECAPTCHA_PUBLIC_KEY=$RECAPTCHA_PUBLIC_KEY \
       RECAPTCHA_PRIVATE_KEY=$RECAPTCHA_PRIVATE_KEY \
       REDIS_HOST= \
       REDIS_PASSWORD= \
       REDIS_PORT= \
       SESSION_DRIVER=$SESSION_DRIVER \
       WEATHER_APPID=$WEATHER_APPID
Push to Heroku and migrate
git push heroku master
heroku run php artisan migrate
Start worker dyno
heroku ps:scale worker=1
Add scheduler to run commands on every hour
heroku addons:create scheduler:standard
heroku addons:open scheduler
php artisan schedule:run

Set scheduler on Heroku

Open the app
heroku open
Add Papertrail
heroku addons:create papertrail
heroku addons:open papertrail
Next step: Deploy with Forge
Clone this wiki locally