Add timeout option to Cloudrun build (#1717)

* Add timeout option for build phase
* Make the --timeout setting optional
* Add test for --timeout setting

Thanks, @wragge
This commit is contained in:
Tim Sherratt 2022-04-25 00:03:08 +10:00 committed by GitHub
commit 3001e1e394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 13 deletions

View file

@ -41,6 +41,10 @@ def publish_subcommand(publish):
type=click.Choice(["1", "2", "4"]),
help="Number of vCPUs to allocate in Cloud Run",
)
@click.option(
"--timeout",
help="Build timeout in seconds",
)
@click.option(
"--apt-get-install",
"apt_get_extras",
@ -72,6 +76,7 @@ def publish_subcommand(publish):
show_files,
memory,
cpu,
timeout,
apt_get_extras,
):
"Publish databases to Datasette running on Cloud Run"
@ -156,7 +161,12 @@ def publish_subcommand(publish):
print("\n====================\n")
image_id = f"gcr.io/{project}/{name}"
check_call(f"gcloud builds submit --tag {image_id}", shell=True)
check_call(
"gcloud builds submit --tag {}{}".format(
image_id, " --timeout {}".format(timeout) if timeout else ""
),
shell=True,
)
check_call(
"gcloud run deploy --allow-unauthenticated --platform=managed --image {} {}{}{}".format(
image_id,