GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
986 stars 146 forks source link

Procfile parsing doesn't separate command from arguments #347

Open glasnt opened 1 year ago

glasnt commented 1 year ago

Describe the bug

If use a Procfile to declare a complex command, I would expect that the first token would be the command and the rest be arguments. This would allow me to define default behaviour, but then allow me to customise arguments in later invocations.

However, it appears that there is no tokenization of the commands in entrypoint parsing.

Example:

app.py (chmod +x):

#!/usr/bin/env python
import sys
print(f"Invocation: {', '.join(sys.argv)} (len = {len(sys.argv)})")

Testing a single command as the process definition:

web: ./app.py
$ pack build single --path .
...
$ docker run single
Invocation: ./app.py (len = 1)
$ docker run single more args
Invocation: ./app.py, more, args (len = 3)
$ pack inspect single

Processes:
  TYPE                 SHELL        COMMAND        ARGS
  web (default)        bash         ./app.py

But changing this process entrypoint to something more complex:

web: python app.py
$ pack build single --path .
...
$ docker run double
Invocation: app.py (len = 1)
python app.py: python app.py: command not found
$ pack inspect double
Processes:
  TYPE                 SHELL        COMMAND        ARGS
  web (default)        bash         python app.py

I know I can use the launcher entrypoint to define a completely new set of command and args, but I'd rather be able to just append args to my invocation.

(I'm currently encountering this using google cloud buildpack images in Cloud Build steps, but also (yet to confirm) Cloud Run jobs)

From current codebase:

https://github.com/GoogleCloudPlatform/buildpacks/blob/main/cmd/config/entrypoint/main_test.go#L90 implies the process is parsed into just a command

https://github.com/GoogleCloudPlatform/buildpacks/blob/main/pkg/gcpbuildpack/gcpbuildpack_test.go#L329 implies the process is separated into 1 command and N arguments

Additional context

How are you using GCP buildpacks?

What language is your project primarily written in?

Python

JanakaSandaruwan commented 6 months ago

Is there any update on this issue?