In the last few years Docker has emerged as a de facto standard for packaging apps for deployment. Today, Heroku Container Registry and Runtime is generally available, allowing you to deploy your Docker images directly to Heroku.
With Container Registry, you get all of the benefits of Docker -- a great local development experience and flexibility to create your own stack -- with the benefits of running on Heroku: maintained infrastructure, container orchestration, routing, the leading add-ons ecosystem, and a world-class security & operations team.
To deploy your Docker image to Heroku, simply run one command in the directory of your Dockerfile:
$ heroku container:push web
=== Building web
Step 1 : FROM alpine:latest
...
Successfully built 74bab4bf0df3
=== Pushing web
The push refers to a repository [registry.heroku.com/yourapp/web]
c8821d626157: Pushed
...
Heroku Container Registry allows you to easily build your Docker image locally and deploy to Heroku. Both Common Runtime and Private Spaces are supported.
To get started, check out the Container Registry documentation.
Use Docker to Develop Your Heroku App
It can be especially frustrating when code that runs perfectly on your machine fails to run on another developer’s machine or a test/production environment. To solve this problem, many development teams are adopting container technologies, like Docker, to fully isolate their app from the underlying OS and local environment.
Docker is well-suited for local development, because a container that runs on your machine gives you confidence that it will also work on another developer’s machine. As a Heroku developer you can now add Docker to your toolbelt and take advantage of the local development experience it provides. When your code is ready, simply push the image directly to Heroku.
Create Your Own Stack
Traditionally, applications deployed on Heroku use a Ubuntu-based stack. With Container Registry you can use any base image, such as Alpine. You can also install any dependency, giving you choice in the stack that you run on Heroku.
In this example Dockerfile, we use an Alpine image, install the Python runtime, as well as ImagicMagick from the apk package manager.
# Grab the latest alpine image
FROM alpine:latest
# Install python runtime
RUN apk --update add python3 py-pip py-gunicorn py-psycopg2 bash
# Install ImageMagick
RUN apk add imagemagick
# Install dependencies
ADD ./python-getting-started/requirements.txt /tmp/requirements.txt
RUN pip install -qr /tmp/requirements.txt
# Add our code
ADD ./python-getting-started /opt/webapp/
WORKDIR /opt/webapp
# Run the app. CMD is required to run on Heroku
CMD gunicorn gettingstarted.wsgi --log-file -
How Is Container Registry Different than git push heroku master
?
When you run git push heroku master
your app is built with a buildpack and runs on a Ubuntu-based stack, both of which are maintained by Heroku. We provide a curated experience ensuring the OS, binaries, language runtime, and popular dependencies are up-to-date.
By using Docker you get the flexibility of defining your own stack, plus the benefits of running on Heroku, such as maintained infrastructure, a security and SRE team, platform orchestration of containers & routing, and a robust ecosystem of add-on services. It’s your stack to curate, backed by Heroku.
We’re Just Getting Started
Today, Container Registry and Runtime provides you with more choice; choice in tools you use to develop and choice in stack you use in your app. And with Container Registry and Runtime, we’re just getting started; exciting new features for customizing your build are on the horizon. If you have feedback about Container Registry, we’d love to hear from you: heroku-container-registry-feedback@salesforce.com.