How to deploy to Heroku from a local docker image

Deployment flow

1 Create a Heroku app on Heroku. (URL is given)

2 Push the Docker image to Heroku's container registry (Docker image storage on Heroku).

3 Release Docker image to app

4 Access the deployed application with a browser

Create an account and register your credit card in advance. (You cannot publish without registering your credit card.)

Install heroku cli (mac)

brew install heroku/brew/heroku

Login to heroku

heroku login

Log in from the browser that starts automatically.

Log in to the container registry

heroku container:login

Go to app

If you try to run apache on heroku, an error will occur, so some measures are required.

Create an error handling configuration file

run-apache2.sh


sed -i "s/Listen 80/Listen ${PORT:-80}/g" /etc/apache2/ports.conf
rm /etc/apache2/mods-enabled/mpm_event.conf
rm /etc/apache2/mods-enabled/mpm_event.load
apache2-foreground "$@"

Add description and execution command to copy to container with dockerfile

dockerfile for heroku.


COPY ./docker/app/run-apache2.sh /usr/local/bin/
CMD [ "run-apache2.sh" ]

Grant execute permission to the error handling configuration file

chmod +x run-apache2.sh

Create heroku app

heroku create

Install add-ons to work with the database. (ignite => free)

heroku addons:create cleardb:ignite

Check the cleardb connection settings.

heroku config | grep CLEARDB_DATABASE_URL

mysql://username:password@hostname/Database name?

Setting environment variables

heroku config:add DB_USERNAME=username

heroku config:add DB_PASSWORD=password

heroku config:add DB_DB_HOST='hostname' (.Because it contains'Enclose in)

heroku config:add DB_DATABASE=username

Confirmation

heroku config

Creating a table

heroku run "File containing table creation functions"

Push to registry container

heroku container:push web

Release to registry container

heroku container:release web

Access from the browser

heroku open
heroku apps:info

Look up the application name and at the end of the command

--app app name

Is given.

How to remove heroku app

heroku apps:destroy --app app name-confirm app name

Check heroku logs (monitored with --tail)

heroku logs --tail

Reflect the correction. Fixed local files.

Push to registry container

heroku container:push web

Release to registry container

heroku container:release web

Recommended Posts

How to deploy to Heroku from a local docker image
How to deploy an app that references a local jar to heroku
How to get a heapdump from a Docker container
How to deploy on heroku
Deploy Flask's Docker image on Heroku
Deploy Rails on Docker to heroku
How to deploy a simple Java Servlet app on Heroku
[Personal notes] How to push a Docker image to GitHub Packages
How to redo a deployment on Heroku
Deploy to heroku with Docker (Rails 6, MySQL)
How to deploy
heroku: docker: deploy
How to migrate a web application created in a local docker environment to AWS
How to deploy a container on AWS Lambda
How to make Spring Boot Docker Image smaller
How to give your image to someone with docker
Steps to deploy to Heroku
[For beginners] Laravel Docker AWS (EC2) How to easily deploy a web application (PHP) from 0 (free) ①-Overview-
How to install Docker
How to create a small docker image of openjdk 11 (ea) application (1GB → 85MB)
How to jump from Eclipse Java to a SQL file
List how to learn from Docker to AKS on AWS
How to connect to ClearDB from Sequel Pro on Heroku
[Java] How to erase a specific character from a character string
[Rails 6] How to set a background image in Rails [CSS]
How to check CircleCI code and automatically deploy to Heroku
How to pass image pixel information natively from Unity
I want to connect to Heroku MySQL from a client
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
Deploy Vapor Project to Heroku
Migrating from vargrant to docker
How to leave a comment
Extract files from Docker Image
How to set Docker nginx
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
How to migrate from JUnit4 to JUnit5
How to insert a video
How to create a method
How to create a lightweight container image for Java apps
How to write a migration from Rails datetime type to date type
[iOS] [Objective-C] How to update a widget from an Objective-C app
How to create a form to select a date from the calendar
[Java] How to convert a character string from String type to byte type
How to store a string from ArrayList to String in Java (Personal)
How to Burning a Install Disk of Windows from Ubuntu
How to deploy a kotlin (java) app on AWS fargate
[IOS14] How to get Data type image data directly from PHPickerViewController?
[Docker context] ~ How to access docker in remote environment from VScode ~
How to deploy a Rails application on AWS (article summary)
[Docker] How to access the host from inside the container. http://host.docker.internal:
Connect to AWS RDS from your local PC Docker environment
How to deploy jQuery on Rails
Deploy a Docker application with Greengrass
How to push from Tarminal to GitHub
How to add columns to a table
How to deploy Laravel on CentOS 7
Create a lightweight STNS Docker image
How to make a Java container
How to sign a Minecraft MOD
Migrate Docker image to another server
How to make a JDBC driver