- Create Something to Deploy
- Create a
Dockerfile
in the root directory of the project- The
Dockerfile
location determines the root directory that the docker file's environment is built from- I.E. it'll affect
ADD
,COPY
,VOLUME
, etc.
- I.E. it'll affect
- This should set up the environment for the project to run
- IF THIS RELIES ON WEB TRAFFIC: a
$PORT
environment variable is required to be used because Heroku by default doesn't allow port selection. This means you need to rely on the environment having the $PORT variable available when crafting the launch command- Example:
CMD gunicorn --bind 0.0.0.0:$PORT example.wsgi
- Example:
- The
- Try to do all set up in here. A script will only complicate it and make it hard to understand deployment
- Create a
- (Optional) Clean up
- List existing remotes
git remote --verbose
- Delete unecessary remotes
git remote rm $REMOTE_NAME
- List Heroku apps
heroku apps
- Destroy heroku app if needed
heroku apps:destroy $HEROKU_APP_NAME --confirm=$HEROKU_APP_NAME
- List existing remotes
- Create a
heroku.yml
in the root of the repository- Please see the documentation for how it should look.
- Pitfall: The dockerfile's location will determine the context for when
docker build
is called on it- Example
build: docker: example_image: example_api/Dockerfile
- In the above example the root context for the build will be
example_api
- In the above example the root context for the build will be
- Example
- Create Heroku App if it doesn't exist
heroku create $HEROKU_APP_NAME --remote $HEROKU_APP_GIT_REMOTE_NAME
--remote $HEROKU_APP_GIT_REMOTE_NAME
doesn't need to provided, it will default toheroku
--remote $HEROKU_APP_GIT_REMOTE_NAME
is used because this is a mono repo so different repos will be deploying through different git remote hooks
- This should only need to be done once in the repo to connect it to heroku
- Set heroku to use a container stack in order to use Docker/
heroku.yml
deploymentsheroku stack:set container
- What is a Stack?
- Deploy to Heroku
- Default deploy
git push $HEROKU_APP_GIT_REMOTE_NAME $DESIRED_BRANCH_TO_DEPLOY:master
- Forcing a deploy in the current branch
git push --force $HEROKU_APP_GIT_REMOTE_NAME HEAD:master
- Default deploy
Last active
March 30, 2019 06:42
-
-
Save loganknecht/b5e5673c8321651c572b207328c23431 to your computer and use it in GitHub Desktop.
HOW TO: Heroku Docker Deployment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment