mirror of
https://github.com/imjasonh/terraform-playground
synced 2026-07-18 06:59:33 +00:00
it works
Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
parent
75e90692e2
commit
fe51a0aca7
4 changed files with 78 additions and 12 deletions
|
|
@ -1,3 +1,20 @@
|
|||
module github.com/imjasonh/terraform-playground/litestream
|
||||
|
||||
go 1.21.5
|
||||
|
||||
require (
|
||||
github.com/chainguard-dev/clog v1.3.1
|
||||
github.com/glebarez/go-sqlite v1.22.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/google/uuid v1.5.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
modernc.org/libc v1.37.6 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.7.2 // indirect
|
||||
modernc.org/sqlite v1.28.0 // indirect
|
||||
)
|
||||
|
|
|
|||
25
litestream/go.sum
Normal file
25
litestream/go.sum
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
github.com/chainguard-dev/clog v1.3.1 h1:CDNCty5WKQhJzoOPubk0GdXt+bPQyargmfClqebrpaQ=
|
||||
github.com/chainguard-dev/clog v1.3.1/go.mod h1:cV516KZWqYc/phZsCNwF36u/KMGS+Gj5Uqeb8Hlp95Y=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
|
||||
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
|
||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
||||
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw=
|
||||
modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
|
||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
||||
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
|
||||
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
|
||||
modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ=
|
||||
modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0=
|
||||
|
|
@ -1,13 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/chainguard-dev/clog"
|
||||
_ "github.com/chainguard-dev/clog/gcp/init"
|
||||
_ "github.com/glebarez/go-sqlite"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db, err := sql.Open("sqlite", "/data/db.sqlite")
|
||||
if err != nil {
|
||||
clog.Fatalf("failed to open database: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello, World!")
|
||||
row := db.QueryRow("select sqlite_version()")
|
||||
var version string
|
||||
if err := row.Scan(&version); err != nil {
|
||||
clog.Fatalf("failed to query database version: %v", err)
|
||||
}
|
||||
clog.Infof("sqlite version: %s", version)
|
||||
fmt.Fprintf(w, "sqlite version: %s", version)
|
||||
})
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,13 @@ resource "ko_build" "build" {
|
|||
}
|
||||
|
||||
resource "google_cloud_run_v2_service" "service" {
|
||||
name = "litestream"
|
||||
location = local.region
|
||||
ingress = "INGRESS_TRAFFIC_ALL"
|
||||
provider = google-beta // for empty_dir
|
||||
|
||||
|
||||
name = "litestream"
|
||||
location = local.region
|
||||
launch_stage = "BETA"
|
||||
ingress = "INGRESS_TRAFFIC_ALL"
|
||||
|
||||
template {
|
||||
containers {
|
||||
|
|
@ -54,23 +58,21 @@ resource "google_cloud_run_v2_service" "service" {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
TODO: Uncommenting this results in
|
||||
│ Error: Error waiting for Updating Service: Error code 13, message: Revision 'litestream-00009-gf9' is not ready and cannot serve traffic. Container import failed:
|
||||
|
||||
containers {
|
||||
image = oci_append.append.image_ref
|
||||
args = ["replicate", "/etc/litestream.yml"]
|
||||
args = ["replicate"]
|
||||
volume_mounts {
|
||||
name = "data"
|
||||
mount_path = "/data"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
volumes {
|
||||
name = "data"
|
||||
empty_dir {
|
||||
medium = "MEMORY"
|
||||
size_limit = "256Mi"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,8 +93,13 @@ resource "oci_append" "append" {
|
|||
base_image = "gcr.io/${local.project_id}/litestream:latest"
|
||||
layers = [{
|
||||
files = {
|
||||
"/etc/litestream.yml" = {
|
||||
"etc/litestream.yml" = {
|
||||
contents = <<EOY
|
||||
logging:
|
||||
level: debug
|
||||
type: json
|
||||
stderr: true
|
||||
|
||||
dbs:
|
||||
- path: /data/db.sqlite
|
||||
replicas:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue