How to correctly for CLI args when deploying from GCP Cloud Deply via cloudbuild.yaml

118 views Asked by At

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

0

There are 0 answers