Saltar a contenido

Heroku CLI

"Clase de la hoja"

########################################################################################################################################################################################################################################################## Copiar todos los comandos
########################################################################################################################################################################################################################################################## Generar PDF seleccionado/button

■/div titulada

Completo Heroku CLI comandos y flujos de trabajo para implementar y gestionar aplicaciones en la plataforma Heroku.

Instalación " Autenticación

Command Description
heroku login Login to Heroku
heroku login -i Login interactively
heroku logout Logout from Heroku
heroku auth:whoami Show current user
heroku auth:token Display auth token

App Management

Operaciones básicas de aplicación

Command Description
heroku apps List all apps
heroku apps:create myapp Create new app
heroku apps:destroy myapp Delete app
heroku apps:info Show app info
heroku apps:rename newname Rename app
heroku apps:open Open app in browser

Configuración de la aplicación

Command Description
heroku config Show config vars
heroku config:set KEY=value Set config var
heroku config:unset KEY Remove config var
heroku config:get KEY Get specific config var
heroku buildpacks List buildpacks
heroku buildpacks:set heroku/nodejs Set buildpack

Despliegue

Git Deployment

Command Description
git push heroku main Deploy from main branch
git push heroku develop:main Deploy from develop branch
heroku git:remote -a myapp Add Heroku remote
heroku releases List releases
heroku releases:rollback v123 Rollback to specific release

Despliegue de contenedores

Command Description
heroku container:login Login to container registry
heroku container:push web Build and push container
heroku container:release web Release container
heroku container:rm web Remove container

Dynos y Scaling

Dyno Management

Command Description
heroku ps List dynos
heroku ps:scale web=2 Scale web dynos
heroku ps:scale worker=1 Scale worker dynos
heroku ps:restart Restart all dynos
heroku ps:restart web.1 Restart specific dyno
heroku ps:stop web.1 Stop specific dyno

Tipos de Dyno

Command Description
heroku ps:type Show dyno types
heroku ps:resize web=standard-1x Resize dyno type
heroku ps:exec SSH into dyno

Complementos

Gestión adicional

Command Description
heroku addons List app add-ons
heroku addons:create heroku-postgresql Add PostgreSQL
heroku addons:create heroku-redis Add Redis
heroku addons:destroy ADDON_NAME Remove add-on
heroku addons:upgrade ADDON_NAME:PLAN Upgrade add-on plan
heroku addons:downgrade ADDON_NAME:PLAN Downgrade add-on plan
Command Description
heroku addons:create sendgrid Add SendGrid email
heroku addons:create papertrail Add Papertrail logging
heroku addons:create newrelic Add New Relic monitoring
heroku addons:create scheduler Add Heroku Scheduler

Operaciones de base de datos

PostgreSQL

Command Description
heroku pg List PostgreSQL databases
heroku pg:info Show database info
heroku pg:psql Connect to database
heroku pg:reset DATABASE_URL Reset database
heroku pg:backups List backups
heroku pg:backups:capture Create backup
heroku pg:backups:restore BACKUP_URL DATABASE_URL Restore backup

Mantenimiento de bases de datos

Command Description
heroku pg:maintenance Show maintenance info
heroku pg:maintenance:run Run maintenance
heroku pg:stats Show database stats
heroku pg:diagnose Diagnose database issues

Logging and Monitoring

Logs

Command Description
heroku logs Show recent logs
heroku logs --tail Stream logs
heroku logs --source app Show app logs only
heroku logs --dyno web.1 Show specific dyno logs
heroku logs --num 1000 Show more log lines

Supervisión

Command Description
heroku ps:autoscale:enable Enable autoscaling
heroku ps:autoscale:disable Disable autoscaling
heroku metrics Show app metrics

Dominios y SSL

Gestión del dominio

Command Description
heroku domains List domains
heroku domains:add example.com Add custom domain
heroku domains:remove example.com Remove domain
heroku domains:info example.com Show domain info

Certificados SSL

Command Description
heroku certs List SSL certificates
heroku certs:add cert.pem key.pem Add SSL certificate
heroku certs:remove Remove SSL certificate
heroku certs:auto:enable Enable automatic SSL
heroku certs:auto:disable Disable automatic SSL

Pipelines y aplicaciones de revisión

Pipeline Management

Command Description
heroku pipelines List pipelines
heroku pipelines:create mypipeline Create pipeline
heroku pipelines:destroy mypipeline Delete pipeline
heroku pipelines:add mypipeline --stage staging Add app to pipeline
heroku pipelines:remove Remove app from pipeline

Promociones

Command Description
heroku pipelines:promote --remote staging Promote to production
heroku releases:rollback --remote production Rollback production

Aplicaciones de revisión

Command Description
heroku reviewapps:enable Enable review apps
heroku reviewapps:disable Disable review apps

Equipos y Colaboración

Gestión del equipo

Command Description
heroku teams List teams
heroku members List team members
heroku members:add user@example.com Add team member
heroku members:remove user@example.com Remove team member

Control de acceso

Command Description
heroku access List app collaborators
heroku access:add user@example.com Add collaborator
heroku access:remove user@example.com Remove collaborator

CLI Plugins

Gestión de plugins

Command Description
heroku plugins List installed plugins
heroku plugins:install PLUGIN_NAME Install plugin
heroku plugins:uninstall PLUGIN_NAME Uninstall plugin
heroku plugins:update Update all plugins

Plugins populares

Command Description
heroku plugins:install heroku-repo Install repo plugin
heroku repo:reset Reset git repository
heroku repo:purge_cache Purge build cache

Environment Management

Múltiples entornos

Command Description
heroku git:remote -a myapp-staging -r staging Add staging remote
heroku git:remote -a myapp-production -r production Add production remote
git push staging main Deploy to staging
git push production main Deploy to production

Medio ambiente

Command Description
heroku config --remote staging Show staging config
heroku config:set NODE_ENV=production --remote production Set production config

Mantenimiento y solución de problemas

Modo de mantenimiento

Command Description
heroku maintenance:on Enable maintenance mode
heroku maintenance:off Disable maintenance mode
heroku maintenance Check maintenance status

Solución de problemas

Command Description
heroku run bash Run bash shell
heroku run rails console Run Rails console
heroku run python manage.py shell Run Django shell
heroku run node Run Node.js REPL

Ejecución

Command Description
heroku labs:enable preboot Enable preboot
heroku labs:disable preboot Disable preboot
heroku ps:wait Wait for dyno to be ready

Buenas prácticas

Despliegue

  1. Use Pipelines: Establecer entornos de puesta en escena y producción
  2. ** Variables del medio ambiente**: Configuración de la tienda en vars de configuración
  3. Migraciones de base de datos: Ejecutar las migraciones durante el despliegue
  4. ** Comprobaciones de salud**: Implementar los puntos finales del control de salud

Seguridad

  1. SSL: Utilice siempre SSL para aplicaciones de producción
  2. Separación del medio ambiente: Mantener el estancamiento y la producción separados
  3. ** Control de acceso**: Acceso limitado a los colaboradores
  4. Secrets Management: Use vars de configuración para datos sensibles

Ejecución

  1. Dyno Sizing: Elija los tipos de dino apropiados
  2. Caching: Implementar estrategias de caché
  3. ** Optimización de la base de datos**: Supervisar y optimizar las consultas de bases de datos
  4. CDN: Use CDN for static assets

Supervisión

  1. Logging: Implementar un registro completo
  2. Métricos: Control de métricas de aplicación
  3. Alertas: Establecer alertas para cuestiones críticas
  4. Error Tracking: Use los servicios de seguimiento de errores