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