About a month ago, leave the Docker image as it is Now that I can deploy it to Heroku, I tried it. It's still in public beta.
reference Container registry public beta - deploy Docker images to Heroku ContainerRegistryandRuntime
The following is described assuming that it has already been completed.
I used my own Flask application as the deployment target. https://github.com/nanakenashi/image_clock
It is a simple clock application that switches images according to the time of day.
image_clock/
├ static/
├ templates/
├ Dockerfile
├ app.py
└ requirements.txt
#Use Alpine Linux with Python as base image
FROM python:3.5.2-alpine
#git installation
RUN apk update
RUN apk add git
#Python package installation
ADD requirements.txt /tmp
RUN pip install -r /tmp/requirements.txt
#Place the source code
WORKDIR /web
RUN git clone https://github.com/nanakenashi/image_clock.git clock
#launch flask application
ENV FLASK_APP /web/clock/app.py
CMD flask run -h 0.0.0.0 -p $PORT
The point is the launch of the flask application.
instead of
RUN`0.0.0.0
to match the IP of the execution environmentPORT
Make sure the docker
command is available
$ docker ps
Log in to Heroku.
$ heroku login
Get the source code from GitHub and change to the directory.
$ git clone https://github.com/nanakenashi/image_clock.git ./image_clock
$ cd image_clock
Secure a place for the application.
$ heroku create flask-clock-sample
At this stage, there is no sauce in it, so it's just a box. When you access it, it looks like this. ↓
Build a container based on the Dockerfile and send it to the repository.
$ heroku container:push --app flask-clock-sample web
--app flask-clock-sample
: Extract the container to the specified applicationweb
: Specify the process type (web
or worker
) on Heroku$ heroku open --app flask-clock-sample
I was able to confirm the operation of the clock application.
Because the application used this time does not use add-ons I was able to set it up and deploy it very simply.
It seems to be a little more difficult to create a Heroku-like configuration such as DB connection and log organization.
Recommended Posts