buildpacks icon indicating copy to clipboard operation
buildpacks copied to clipboard

Procfile parsing doesn't separate command from arguments

Open glasnt opened this issue 2 years ago • 1 comments

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?

  • [x] pack and the gcr.io/buildpacks/builder
  • [ ] Cloud Functions
  • [x] Cloud Run + Cloud Run Jobs
  • [x] Cloud Build (replicated, but requires pack build --workspace /app (additional bug))
  • [ ] App Engine Standard
  • [ ] App Engine Flex

What language is your project primarily written in?

Python

glasnt avatar Oct 02 '23 22:10 glasnt

Is there any update on this issue?

JanakaSandaruwan avatar May 04 '24 02:05 JanakaSandaruwan