diff --git a/litestream/README.md b/litestream/README.md new file mode 100644 index 0000000..902528b --- /dev/null +++ b/litestream/README.md @@ -0,0 +1,7 @@ +# Litestream on Cloud Storage + Cloud Run + +This demonstrates running a Cloud Run service that uses [Litestream](https://litestream.io) to backup a SQLite database to a Cloud Storage bucket. + +It does this by running the Litestream image as a sidecar container in the same pod as the application container, with a shared volume mounted between them. + +The bucket configuration is written to a config file appended to the litestream image. diff --git a/litestream/main.tf b/litestream/main.tf index 3bb62af..1ab3a5f 100644 --- a/litestream/main.tf +++ b/litestream/main.tf @@ -77,12 +77,12 @@ resource "google_cloud_run_v2_service" "service" { } } +data "oci_ref" "litestream" { ref = "litestream/litestream" } + +// Copy the litestream image to GCR, if it's changed. // TODO: This should be an oci_copy resource. resource "null_resource" "crane-cp" { - triggers = { - bucket = google_storage_bucket.bucket.name - image = ko_build.build.image_ref - } + triggers = { digest = data.oci_ref.litestream.digest } provisioner "local-exec" { command = "crane cp --platform=linux/amd64 litestream/litestream gcr.io/${local.project_id}/litestream:latest"