Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. It supports several programming languages including Ruby, Java, Node.js, Scala, Clojure, Python, PHP, and Go.
The Heroku Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly from the terminal.
Installation: Follow the instructions at: https://devcenter.heroku.com/articles/heroku-cli
Login to Heroku:
heroku login
Basic Command Structure:
heroku <command> <options>
Get Help:
heroku help
heroku help <command>
Create a New App:
heroku create my-app-name
List Your Apps:
heroku apps
Get App Info:
heroku apps:info --app my-app-name
Rename an App:
heroku apps:rename new-name --app old-name
Delete an App:
heroku apps:destroy --app my-app-name --confirm my-app-name
Deploy with Git:
git push heroku main
Deploy from a Specific Branch:
git push heroku feature-branch:main
Deploy a Specific Commit:
git push heroku <commit-hash>:main
Set the Buildpack:
heroku buildpacks:set heroku/nodejs
View Build Logs:
heroku builds:info
Set Config Vars:
heroku config:set KEY=value
Get Config Vars:
heroku config
Remove a Config Var:
heroku config:unset KEY
Set Multiple Config Vars:
heroku config:set KEY1=value1 KEY2=value2
Scale Dynos:
heroku ps:scale web=2 worker=1
View Current Dyno Formation:
heroku ps
Restart All Dynos:
heroku ps:restart
Stop All Dynos:
heroku ps:scale web=0 worker=0
List Available Add-ons:
heroku addons:services
Add an Add-on:
heroku addons:create heroku-postgresql:hobby-dev
List Installed Add-ons:
heroku addons
Remove an Add-on:
heroku addons:destroy heroku-postgresql
View Logs:
heroku logs
Tail Logs:
heroku logs --tail
View Specific Number of Log Lines:
heroku logs -n 200
View Application Metrics:
heroku metrics
Create a PostgreSQL Database:
heroku addons:create heroku-postgresql:hobby-dev
Connect to PostgreSQL:
heroku pg:psql
Run a Database Backup:
heroku pg:backups:capture
Download Latest Backup:
heroku pg:backups:download
Add a Custom Domain:
heroku domains:add www.example.com
List Domains:
heroku domains
Remove a Domain:
heroku domains:remove www.example.com
Add SSL Certificate:
heroku certs:add server.crt server.key
Add a Collaborator:
heroku access:add user@example.com
List Collaborators:
heroku access
Remove a Collaborator:
heroku access:remove user@example.com
Create a Pipeline:
heroku pipelines:create my-pipeline
Add an App to a Pipeline:
heroku pipelines:add my-pipeline --app my-app --stage production
Promote an App:
heroku pipelines:promote --app my-staging-app
View Pipeline:
heroku pipelines:info my-pipeline
Enable Heroku CI:
heroku ci:enable --app my-app
Run CI:
heroku ci:run --app my-app
View CI Results:
heroku ci:info --app my-app
Use Environment Variables for Configuration Store configuration in environment variables, not in your code.
Implement Proper Logging Use Heroku's logging system to diagnose issues and monitor your app.
Scale Your App Appropriately Use Heroku's scaling features to handle traffic efficiently.
Use Buildpacks Wisely Choose the right buildpacks for your application stack.
Utilize Add-ons Take advantage of Heroku's add-on ecosystem for additional functionality.
Implement Continuous Integration/Continuous Deployment (CI/CD) Use Heroku Pipelines and Heroku CI for streamlined deployment processes.
Regular Backups Regularly backup your databases and other important data.
Monitor Application Performance Use Heroku's metrics and New Relic add-on to monitor your app's performance.
Optimize for Ephemerality Design your app to work with Heroku's ephemeral filesystem.
Keep Your Dependencies Updated Regularly update your application's dependencies to ensure security and performance.
2024 © All rights reserved - buraxta.com