Skip to content

Instantly share code, notes, and snippets.

@daniil4udo
Created June 16, 2019 12:03
Show Gist options
  • Save daniil4udo/7d4f750a79e65ea2dd1748be45e49abf to your computer and use it in GitHub Desktop.
Save daniil4udo/7d4f750a79e65ea2dd1748be45e49abf to your computer and use it in GitHub Desktop.
Deploying to Heroku
# Implying you already have Heroku CLI
# Create Procfile & add script from package.json to run
touch Procfile
echo > "web: npm run prod" Procfile
# Create new app
heroku create
# Add config variable
heroku config:set NODE_ENV=production
# List all env variables (useful for setting secret tokens or key, that you dont want keep in you codebase)
heroku config
# Also set your port in you server configuration file to
# const PORT = process.env.PORT || 8080;
# If doesnt exist
touch .env
echo "NODE_ENV=production" > .env
# Check
heroku local
# If ready for prod
git push heroku heroku:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment