GoogleCloudPlatform / cloud-run-button

Let anyone deploy your GitHub repos to Google Cloud Run with a single click
https://cloud.run
Apache License 2.0
523 stars 91 forks source link

support for settings instances to 1 #227

Closed matti closed 2 years ago

matti commented 2 years ago

how to set the number of instances to only 1 for apps that don't work when scaled, eg: https://github.com/matti/http-doom/

https://github.com/matti/http-doom/issues/6

glasnt commented 2 years ago

The work-around is to adjust the service after first deployment:

gcloud run services update http-doom --max-instances 1

The ongoing fix would be to add max-instances as an option. But, there are a number of other configuration updates in Cloud Run that should be assessed if they are useful to add to Cloud Run Button.

glasnt commented 2 years ago

FYI @matti I tried to update your repo to Caddy 2, but encountered issues trying to update the cgi settings your app relies on.

I ended up using a custom app.json in my testing where I skip building, and instead pulling the image you prepared earlier. Using the executable built from #228, this deployed successfully.

https://github.com/glasnt/crb-appjson-test/blob/a9327af1fe39905910a562ce9606e116389e15bf/app.json#L10-14

...
  "hooks": {
    "prebuild": {
      "commands": [
        "./build.sh"
      ]
    }
  }
...

https://github.com/glasnt/crb-appjson-test/blob/a9327af1fe39905910a562ce9606e116389e15bf/build.sh#L1

DOOM_IMAGE=mattipaksula/http-doom

echo "Copying $DOOM_IMAGE to local project as $IMAGE_URL"
docker pull $DOOM_IMAGE
docker tag $DOOM_IMAGE $IMAGE_URL
Screen Shot 2022-02-28 at 4 47 49 pm
jamesward commented 2 years ago

Nice work @glasnt! You could probably use a postcreate hook to set the additional config. Use the GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_REGION, and K_SERVICE env vars.

glasnt commented 2 years ago

@jamesward just so.

@matti You'd want to add a postcreate script as James mentioned that runs: gcloud run services update $K_SERVICE --region $GOOGLE_CLOUD_REGION --platform managed --max-instances 1 as a temporary workaround.

matti commented 2 years ago

nah, this http-doom is a joke anyway. BUT, it is a valid usecase to deploy apps with 1 instance with the button