Running the Apollo Runtime in Heroku

Hey folks - has anyone figure out how to run the apollo-runtime image in Heroku - lots of docs on most other standard docker architectures, but Heroku has some special requirements, and I’m having a hell of a time trying to get the PORT bindings to work properly with their infra. Everything works fine locally :zany_face:

For reference - this is what I have so far: GitHub - mjfaga/apollo-runtime-on-heroku

1 Like

Hi Mark, I’m asking around internally. We’ll get you a reply asap!

1 Like

Hi @mjfaga

I’m one of the engineers who built the runtime container so should be able to help here. Are you trying to deploy the container so you can use MCP? If that is the case it might be a bit of a challenge because Heroku only lets you expose one web port per Docker Image deployed. This is also true of Google Cloud Run too so it’s not just a Heroku issue.

Further it also requires you to use a $PORT environment variable which at the moment the container doesn’t support (no reason it couldn’t in the future of course but that’s the position as it is right now)

I was going to start with just getting the Router rolling. From there, I am likely going to define a different dyno process in heroku and then also expose the MCP server separately (to your point about their port limitations.

It’s a bit overkill, but I have two trains of thought here. 1) Local environment is still simple - run a single container with both, and 2) I’m not sure I’ll in the heroku environment for much longer, so I figured it made more sense to get comfortable with that image.

You’ll see in the repo I posted, I’m listing to the $PORT env, but maybe not correctly. The setup in that repo works locally just fine, and I can run the router on any port. My next step would have been doing something similar to expose the MCP port properly. Let me know thoughts, or if you have other recommendations instead!

Just had a look at it again and yer you’re right, that should work, are you getting any specific errors or is it just failing to do anything when it starts?

I noted it an an issue, but here are the details:

2025-07-08T14:01:27.455589+00:00 heroku[web.1]: Starting process with command `/init`
2025-07-08T14:02:27.955800+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2025-07-08T14:02:27.968913+00:00 heroku[web.1]: Stopping process with SIGKILL
2025-07-08T14:02:28.019225+00:00 heroku[web.1]: Process exited with status 137
2025-07-08T14:02:28.038795+00:00 heroku[web.1]: State changed from starting to crashed

I can give you access to the heroku project if it’s helpful and you want to try a few things yourself? - Let me know where to send the invite. It’s out there running and failing constantly right now.

@mjfaga! :waving_hand:
Hmm, kill -KILL could be the host environment refusing to let the process continue — is it possible that it doesn’t have enough memory?

I can try bumping the size of the dyno tonight to see if that is it :+1:

No dice… scaling them vertically didn’t work.

Been digging around in this for a bit, and I’m worried this is a slightly different limitation of Heroku due to how the container fundamentally works: Is there a workaround to run /init with non-zero PID? · Issue #383 · just-containers/s6-overlay · GitHub

It seems as though Heroku reserves PID 1 for their own stuff, so even if the container could boot I don’t think it’ll work because S6 needs to be PID 1 so we can run multiple processes in the container itself. This looks like a fundamental limitation of Heroku though which is super annoying

Ooooof - that is a big bummer. Appreciate you digging and and finding that, and sorry for the trouble. Happy to put up a docs PR with some details about not being able to run in Heroku due to their own system limitations if you’d like?

Don’t worry, it was a very fun rabbit hole to fall down. All PRs are greatfully accepted so yes feel free to add it

1 Like