Pages

Thursday, July 5, 2018

Building daycare website [Part 9]: Running the production Docker image on Heroku

On the previous posts I described how to build a production image for the web application. The next couple of posts will go over how to automate the deployment of the application to Heroku. First, let's deploy from the development machine using the Heroku CLI.

1. Start by creating a new Heroku application:

daycare-heroku

2. Next, using the Heroku CLI, build and push the image to Heroku's container registry:

heroku container:push web -a YOUR_APP_NAME 


3. Finally, you can release the image:

heroku container:release web -a YOUR_APP_NAME 


Your application is now available in Heroku! For example https://daycare-sample.herokuapp.com. One question you may have is how does Heroku manage the mapping of the port to your container? The answer is that $PORT variable that was set on the Dockerfile (which defaults to 5000). Heroku will automatically assign a port number and makes it available to your application using the $PORT variable.

Next up, how to automate the deployment using CircleCI.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.