-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yaml
75 lines (70 loc) · 2.53 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
version: '3'
services:
# Spanner
# https://cloud.google.com/spanner/docs/emulator
spanner:
image: gcr.io/cloud-spanner-emulator/emulator:1.4.1
ports:
- "9010:9010"
- "9020:9020"
# Init (Create Instance)
gcloud-spanner-init:
image: gcr.io/google.com/cloudsdktool/cloud-sdk:332.0.0-slim
# See. https://cloud.google.com/spanner/docs/emulator#using_the_gcloud_cli_with_the_emulator
command: >
bash -eu -c '
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 config set auth/disable_credentials true
gcloud spanner instances create $${INSTANCE_NAME} --config=emulator-config --description=Emulator --nodes=1
'
depends_on:
- spanner
environment:
PROJECT_ID: "test-project"
SPANNER_EMULATOR_URL: "http://spanner:9020/"
INSTANCE_NAME: "test-instance"
DATABASE_NAME: "test-database"
restart: on-failure
# DB Migration (Create Table)
# https://github.com/cloudspannerecosystem/wrench
wrench-create:
image: mercari/wrench:1.0.4
command: "create --directory /ddl"
environment:
SPANNER_PROJECT_ID: "test-project"
SPANNER_INSTANCE_ID: "test-instance"
SPANNER_DATABASE_ID: "test-database"
SPANNER_EMULATOR_HOST: "spanner:9010"
SPANNER_EMULATOR_URL: "http://spanner:9020/"
depends_on:
- gcloud-spanner-init
volumes:
- ./example/ddl:/ddl
restart: on-failure
# DB Migration (Insert data)
# https://github.com/cloudspannerecosystem/wrench
wrench-apply:
image: mercari/wrench:1.0.4
command: "apply --dml /dml/dml.sql"
environment:
SPANNER_PROJECT_ID: "test-project"
SPANNER_INSTANCE_ID: "test-instance"
SPANNER_DATABASE_ID: "test-database"
SPANNER_EMULATOR_HOST: "spanner:9010"
SPANNER_EMULATOR_URL: "http://spanner:9020/"
volumes:
- ./example/dml:/dml
depends_on:
- wrench-create
restart: on-failure
# CLI
# https://github.com/cloudspannerecosystem/spanner-cli
spanner-cli:
build:
context: ./docker/spanner-cli
environment:
SPANNER_EMULATOR_HOST: "spanner:9010"
command: ['echo', 'Run "docker-compose run --rm spanner-cli spanner-cli -p test-project -i test-instance -d test-database"']