router icon indicating copy to clipboard operation
router copied to clipboard

router container image isn't working on GCP Cloud Run

Open garypen opened this issue 1 year ago • 4 comments

The issue has been reported as:

"/usr/bin/env: 'bash ': No such file or directory"

which is quite unusual since the error message implies that the root a/c doesn’t have bash in the PATH...

The problem appears to be confined to GCP Cloud run, since the container executes fine in other environments (docker, k8s, etc...)

garypen avatar Jul 31 '23 09:07 garypen

Google Cloud Run doesn't let you run from a non-GCP registry, but I was able to reproduce this relatively simply by:

  1. Setting up a Google Cloud Platform environment. My existing one happens to be called burner-gateway. (Don't ask. 🙉 )

  2. Running:

    gcloud auth configure-docker
    docker pull ghcr.io/apollographql/router:v1.26.0
    docker tag ghcr.io/apollographql/router:v1.26.0 gcr.io/burner-gateway/router:v1.26.0
    docker push  gcr.io/burner-gateway/router:v1.26.0
    gcloud run deploy router-run-jesse --image gcr.io/burner-gateway/router:v1.26.0
    
  3. Following the output until it fails and provides a link to the logs, which shows exactly this error.

abernix avatar Aug 01 '23 08:08 abernix

This is still a problem with Cloud Run. A workaround is to run gcloud run deploy with the --command=/dist/router.

jesse-apollo avatar Mar 01 '24 17:03 jesse-apollo

Any idea what's wrong, @jesse-apollo? This feels like it must be something silly something is doing.

abernix avatar Mar 01 '24 18:03 abernix

I'm not entirely sure. I'm guessing the gVisor runtime sandbox is executing the container in such a way that /usr/bin/env doesn't have the appropriate path to locate bash.

However, I see using a shebang of #!/usr/bin/env bash as unnecessary in this situation. This style of shell script shebang is really only used to increase cross-portability of shell scripts across various linux/*nix OSes which might have weird interpreter paths. In a container this is not the case. The filesystem is immutable and well defined. I suggest we change the entrypoint script to use a normal shebang of #!/bin/bash.

jesse-apollo avatar Mar 04 '24 20:03 jesse-apollo