Either I'm doing something wrong or Heroku is messing up. Heroku supports targeting a particular stage in a Dockerfile
. I have a multistage Dockerfile but Heroku is not respecting the build.docker.release.target
in my heroku.yml
. For what it's worth, targeting works fine with docker-compose.yml
.
I'm trying to keep dev and prod in the same Dockerfile
. Essentially dev
and prod
are forked from base
. I could flesh it out more, but the stages are:
FROM python:3.10.0-slim-buster AS venv
...
FROM python:3.10.0-slim-buster as base
...
FROM base AS dev
...
ENTRYPOINT ["entrypoint.dev.sh"]
FROM base AS prod
...
ENTRYPOINT ["entrypoint.prod.sh"]
My heroku.yml
specifically targets the prod
stage:
setup:
addons:
- plan: heroku-postgresql
as: DATABASE
build:
docker:
release:
dockerfile: image/app/Dockerfile
target: prod
web: image/app/Dockerfile
config:
DJANGO_ENV: production
release:
image: web
command:
- ./deployment-tasks.sh
run:
web: gunicorn server.wsgi:application --bind 0.0.0.0:$PORT --log-level debug --access-logfile - --error-logfile -
However, Heroku builds all the stages, seems like it just runs down the Dockerfile till the end. The Heroku build logs show that first dev follows base
and then prod follows dev
I would expect it to jump from base
to prod
, skipping dev
.
Is this an issue on my side or Heroku's?