Self Hosted GitHub Runner on Google Cloud Run with no ingress port

Viewed 551

I want to run docker containers on Google Cloud Run that act as GitHub Self Hosted Runners, but I'm having problems when deploying the container to CloudRun as it complaining about the port. The error is like:

Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.

In my Dockerfile I am not setting any port variable or exposing any ports, as the GitHub runner does not need ingress, only egress to 443.

Is there a way to deploy a service to Cloud Run, but not expose an ingress port?

If it's a case of exposing the default 8080 port just to get it running (though there is no service actually listening on that port) then I am assuming i can just add an EXPOSE 8080 in the dockerfile?

From the CloudRun logs I can see the github runner service succesfully starts and registers with GitHub, but then exits due to this error.

What am I missing?

1 Answers

Cloud Run contract is pretty simple:

  • Stateless app (no volume mount on the container)
  • Answer to HTTP request (you need a webserver)

The message that you get is because there is nothing listening on the port (here the default 8080) and thus your don't respect the contract.

In summary, you can't run background process (for now) on Cloud Run, only webserver (API backend for example).

If you are looking for a managed container solution which runs container in background, your can have a look to GKE autopilot. First cluster is free and you pay per pod (1 or several containers)

Related