Skip to content

ZachElkins/Full-Stack-Checkbox-Snake

Repository files navigation


Heroku Node+PostgreSQL Docker Example

Description

Heroku Node+Postgres with Docker Example for CU Boulder CSCI 3308 Spring 2021 Lab 10

How to run

Setup

Build the docker images

docker-compose build

Once you setup the heroku-cli locally, get your API token with

heroku auth:token

Now copy the token into /heroku/.env as an environment variable HEROKU_API_KEY. This allows us to run the heroku-cli in a docker container. Most heroku commands can be ran locally, but we'll use this container for setting up Heroku Postgres.

Heroku Postgres

We can access the heroku-cli container:

docker-compose run heroku-cli

Here postgres is installed, all we need to do is run the following.

heroku pg:psql --app <your-app-name>

Local Development

We use docker-compose for local development. This uses a specific target stage (devapp) of our Dockerfile to run nodemon. We also have a local database container db.

We can run the development environment with:

docker-compose up

Deploying to Heroku

The final stage of our Dockerfile is prodapp, which contains no development dependencies (e.g. nodemon).

To deploy it to Heroku, run the following:

# login to Registry
heroku container:login
# build and push to registry
heroku container:push web -a <app_name>
# release
heroku container:release web -a <app_name>

To check everything worked, open you're browser.

heroku open -a <app_name>

For more details, see the Heroku Container Registry & Runtime Documentation

About

Checkbox snake with a database to keep track of stats.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published