Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a heroku docker image for a specific context

Tags:

docker

heroku

When using heroku.yml developer preview (https://devcenter.heroku.com/articles/build-docker-images-heroku-yml). Is there currently any way of specifying a docker build context as well as the dockerfile?

The command I'd like to emulate is:

docker build -f cmd/api/Dockerfile .

Note: I provide the path . for the build context here.

Currently, I'm able to successfully run the following:

build:
  docker:
    web: cmd/api/Dockerfile

Or, using the more explicit version:

build:
  docker:
    web:
      dockerfile: cmd/api/Dockerfile

Based on the ability to target a stage from a multi-stage build, my assumption was that I would also be able to provide context in the same way I would docker-compose as a field for the build:

build:
  docker:
    web:
      dockerfile: cmd/api/Dockerfile
      context: .

However, this returns the following error response from Heroku:

remote: Building source:
remote: === Fetching app code
remote:
remote: =!= There were problems parsing your heroku.yml. We've detected the following issues:
remote:
remote: build.docker.web.context in body is a forbidden property
remote: Verifying deploy...
remote:
remote: !       Push rejected to docker-build-context-test.
remote:

Is this a known feature that I can implement? It's very possible I might need to send in a feature request, as this functionality is a developer preview, but it feels like something they would've included.

Hope you guys have some answers!

like image 538
syntaqx Avatar asked Oct 11 '25 17:10

syntaqx


1 Answers

https://devcenter.heroku.com/articles/build-docker-images-heroku-yml

The Docker build context is always set to the directory containing the Dockerfile and cannot be configured independently.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!