0

I have a docker file

FROM golang:1.20-alpine

WORKDIR /app

COPY . .

RUN go build quivrApi/cmd/quivr

EXPOSE $PORT

ENTRYPOINT ["./quivr"]

and my cloudbuild.yaml

steps:
  # Build the container image
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-f', 'dev.Dockerfile', '-t', 'gcr.io/quivr-test/quivr-api', '.']
  # Push the container image to Container Registry
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/quivr-test/quivr-api']
  # Deploy container image to Cloud Run
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: gcloud
    args: ['run', 'deploy', 'quivr-api', '--image', 'gcr.io/quivr-test/quivr-api', '--region', 'us-central1', '--platform', 'managed', '--args', '-c dev_config api']
images:
  - 'gcr.io/quivr-test/quivr-api'

When running this I get this error:

terminated: Application failed to start: kernel init: cannot resolve init executable: error finding executable "quivr -c dev_config api" in PATH [/go/bin /usr/local/go/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin]: no such file or directory

Locally, I can successfully run the container via:

docker run -p 8000:8000 --name quivr quivr -c dev_config api

How can I correctly replicate this in my cloudbuild.yaml?

If I just include the args in my entrypoint like so:

ENTRYPOINT ["./quivr", "-c", "dev_config", "api"]

Everything works as expected, but I need to be able to run different cli options

Z. Fralish
  • 438
  • 4
  • 9
  • Where are you deploying this container? How will you invoke it? Do you want to change the parameter when you start the container? – guillaume blaquiere May 07 '23 at 19:01
  • I am deploying it to cloud run, I would like to be able to use the same docker file to deploy a cloud run service as well as a cloud run job. – Z. Fralish May 07 '23 at 19:06
  • Currently it seems like I am just not passing in the `--args` command correctly. Currently I am trying like this ` args: ['run', 'deploy', 'quivr-api', '--image', 'gcr.io/quivr-test/quivr-api', '--region', 'us-central1', '--platform', 'managed', '--command=./quivr', '--args="-c","dev_config","api"']` It works correctly via the CLI: `gcloud run deploy --image gcr.io/quivr-test/quivr-api --project quivr-test --region us-central1 --platform managed --command='./quivr' --args="-c","dev_config","api"` – Z. Fralish May 07 '23 at 19:08
  • You can't run the same container on Cloud Run jobs and on Cloud Run. One run batches (script that exit at the end) and the other HTTP server (infinite loop process that wait for an HTTP request. Never exit). – guillaume blaquiere May 08 '23 at 10:38

0 Answers0