Skip to content

Commit

Permalink
pkg/recipe: add spanner recipe
Browse files Browse the repository at this point in the history
Change-Id: Iff940d1ac77c88786751fabdc8b609dad444bb43
  • Loading branch information
dlamarmorgan authored and Storj Robot committed Sep 12, 2024
1 parent 93c9037 commit cf396e7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/files/docker/spanner.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM img.dev.storj.io/storjup/base:20240509-1 AS binaries

FROM google/cloud-sdk:492.0.0-slim AS final
RUN apt-get install -y google-cloud-cli-spanner-emulator

ADD pkg/recipe/startspanner.sh /var/lib/storj/startspanner.sh
COPY --from=binaries /var/lib/storj/go/bin /var/lib/storj/go/bin

ENTRYPOINT ["/var/lib/storj/startspanner.sh"]
ENV PATH=$PATH:/var/lib/storj/go/bin
4 changes: 4 additions & 0 deletions pkg/recipe/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var db []byte
//go:embed postgres.yaml
var postgres []byte

//go:embed spanner.yaml
var spanner []byte

//go:embed edge.yaml
var edge []byte

Expand Down Expand Up @@ -56,6 +59,7 @@ var Defaults = map[string][]byte{
"satellite-admin": satelliteAdmin,
"db": db,
"postgres": postgres,
"spanner": spanner,
"edge": edge,
"tracing": tracing,
"billing": billing,
Expand Down
22 changes: 22 additions & 0 deletions pkg/recipe/spanner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: spanner
description: spanner DB.
add:
- name: spanner
image: img.dev.storj.io/storjup/spanner:492.0.0
port:
- name: gRPC
description: Spanner gRPC port
target: 9010
- name: REST
description: Spanner REST port
target: 9020
environment:
PROJECT_ID: test-project
INSTANCE_NAME: test-instance
SPANNER_EMULATOR_URL: http://localhost:9020/
modify:
- match:
name: satellite-api,satellite-core,satellite-admin
config:
SPANNER_EMULATOR_HOST: 'spanner:9010'
STORJ_METAINFO_DATABASE_URL: "spanner://projects/test-project/instances/test-instance/databases/metainfo"
17 changes: 17 additions & 0 deletions pkg/recipe/startspanner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -xem
echo "Starting Spanner dev container"

gcloud emulators spanner start --host-port=0.0.0.0:9010&
gcloud config set disable_prompts true
gcloud config configurations create emulator
gcloud config set auth/disable_credentials true
gcloud config set project "${PROJECT_ID}"
gcloud config set api_endpoint_overrides/spanner "${SPANNER_EMULATOR_URL}"
gcloud spanner instances create "${INSTANCE_NAME}" --config=emulator-config --description=Emulator --nodes=1

#TODO: find a more flexible way to create the databases
gcloud spanner databases create master --instance="${INSTANCE_NAME}"
gcloud spanner databases create metainfo --instance="${INSTANCE_NAME}"

fg %1

0 comments on commit cf396e7

Please sign in to comment.