Heroku commands CLI

Heroku


Principle: Build Dockerfile.build locally, test then deploy Dockerfile.prod

## Install the CLI

```bash
sudo snap install --classic heroku
```
```bash
export PATH=$PATH:/snap/bin
```

## Login

```bash
heroku login
```

Generate Auth Token for Gitlab CI/CD

heroku auth:token

## Create App if it doesn't exist

```bash
heroku create <app_name>
```

## Set envionment variables

On Heroku

## Set project as containerized

```bash
heroku stack:set container
```

## Postgresql add-on (if not installed)

```bash
heroku addons:create heroku-postgresql:hobby-dev
```

heroku addons:create heroku-postgresql:hobby-dev -a <app_name>
Connect to Postgres  
heroku pg:psql -a <app_name>
\dt

And run other postgres commands

## Heroku Builds

```bash
heroku plugins:install heroku-builds
# usage
heroku builds:cancel -a django-react-boiler-v1
```

## Remote App

```bash
heroku git:remote -a <app_name>
```

## Rename staging remotes if necessary

```bash
git remote rename heroku heroku-staging
```

## [Test] Build heroku Dockerfile.prod locally

To test, build the new image and spin up a new container:
```bash
docker build -f Dockerfile.build -t web:latest .
docker run -d --name django-heroku -e "PORT=8765" -e "DEBUG=1" -p 8007:8765 web:latest
```
List static files
```bash
docker exec django-heroku ls /app/staticfiles
```

## Deploy

```bash
git push heroku-staging production:main
```

Commentaires

Posts les plus consultés de ce blog

Kubectl Commands

HMS Interface Translation