-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdocker-compose.temporal.yml
More file actions
151 lines (146 loc) · 5.77 KB
/
Copy pathdocker-compose.temporal.yml
File metadata and controls
151 lines (146 loc) · 5.77 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Persistent Temporal fallback at localhost:7233 (UI :8233); prefer `npm run temporal:dev`.
# Usage: `docker compose -f docker-compose.temporal.yml up`; full stack: `docker compose --profile scheduled up --build`.
services:
temporal-postgres:
image: postgres:16
environment:
POSTGRES_USER: temporal
POSTGRES_PASSWORD: temporal
POSTGRES_DB: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U temporal -d postgres"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
volumes:
- temporal-dev-postgres-data:/var/lib/postgresql/data
temporal-schema:
image: temporalio/admin-tools:1.31.2
user: "0:0"
depends_on:
temporal-postgres:
condition: service_healthy
environment:
DB: postgres12
DB_PORT: 5432
POSTGRES_USER: temporal
POSTGRES_PWD: temporal
POSTGRES_SEEDS: temporal-postgres
volumes:
- temporal-dev-dynamic-config:/etc/temporal/config/dynamicconfig
entrypoint: ["/bin/sh", "-eu", "-c"]
command:
- |
export SQL_PLUGIN="$$DB"
export SQL_HOST="$$POSTGRES_SEEDS"
export SQL_PORT="$$DB_PORT"
export SQL_USER="$$POSTGRES_USER"
export SQL_PASSWORD="$$POSTGRES_PWD"
ensure_database() {
database="$$1"
if output=$$(temporal-sql-tool --db "$$database" create 2>&1); then
printf '%s\n' "$$output"
return 0
fi
if printf '%s\n' "$$output" | grep -qi 'already exists'; then
printf 'Database %s already exists; applying versioned updates.\n' "$$database"
return 10
fi
printf '%s\n' "$$output" >&2
return 1
}
if ensure_database temporal; then
temporal-sql-tool --db temporal setup-schema -v 0.0
elif [ "$$?" -ne 10 ]; then
exit 1
fi
temporal-sql-tool --db temporal update-schema -d /etc/temporal/schema/postgresql/v12/temporal/versioned
if ensure_database temporal_visibility; then
temporal-sql-tool --db temporal_visibility setup-schema -v 0.0
elif [ "$$?" -ne 10 ]; then
exit 1
fi
temporal-sql-tool --db temporal_visibility update-schema -d /etc/temporal/schema/postgresql/v12/visibility/versioned
printf '{}\n' > /etc/temporal/config/dynamicconfig/docker.yaml
temporal:
image: temporalio/server:1.31.2
depends_on:
temporal-schema:
condition: service_completed_successfully
environment:
BIND_ON_IP: 0.0.0.0
DB: postgres12
DB_PORT: 5432
POSTGRES_USER: temporal
POSTGRES_PWD: temporal
POSTGRES_SEEDS: temporal-postgres
DBNAME: temporal
VISIBILITY_DBNAME: temporal_visibility
NUM_HISTORY_SHARDS: "4"
DYNAMIC_CONFIG_FILE_PATH: /etc/temporal/config/dynamicconfig/docker.yaml
volumes:
- temporal-dev-dynamic-config:/etc/temporal/config/dynamicconfig:ro
ports:
- "127.0.0.1:7233:7233"
temporal-namespace:
image: temporalio/admin-tools:1.31.2
depends_on:
- temporal
entrypoint: ["/bin/sh", "-eu", "-c"]
command:
- |
timeout 300 sh -c 'until temporal operator cluster health --address temporal:7233 | grep -q SERVING; do echo "Waiting for the Temporal frontend..."; sleep 2; done'
if temporal operator namespace describe --address temporal:7233 --namespace default >/dev/null 2>&1; then
temporal operator namespace update --address temporal:7233 --namespace default --retention 24h
else
temporal operator namespace create --address temporal:7233 --namespace default --retention 24h --description "bisibility development namespace"
fi
timeout 120 sh -c 'until temporal operator namespace describe --address temporal:7233 --namespace default >/dev/null 2>&1; do echo "Waiting for the namespace cache..."; sleep 2; done'
list_search_attributes() {
deadline=$$(( $$(date +%s) + 120 ))
until current=$$(temporal operator search-attribute list --address temporal:7233 --namespace default --output json 2>/dev/null); do
if [ "$$(date +%s)" -ge "$$deadline" ]; then
echo "Timed out waiting for Temporal search-attribute namespace visibility." >&2
return 1
fi
echo "Waiting for Temporal search-attribute namespace visibility..." >&2
sleep 2
done
printf '%s' "$$current" | tr -d '[:space:]'
}
ensure_search_attribute() {
attribute="$$1"
current=$$(list_search_attributes)
if printf '%s' "$$current" | grep -Fq "\"$$attribute\":\"INDEXED_VALUE_TYPE_KEYWORD\""; then
echo "Temporal search attribute $$attribute already exists as Keyword."
return 0
fi
if output=$$(temporal operator search-attribute create --address temporal:7233 --namespace default --name "$$attribute" --type Keyword 2>&1); then
printf '%s\n' "$$output"
return 0
fi
current=$$(list_search_attributes)
if printf '%s' "$$current" | grep -Fq "\"$$attribute\":\"INDEXED_VALUE_TYPE_KEYWORD\""; then
echo "Temporal search attribute $$attribute was created concurrently."
return 0
fi
printf '%s\n' "$$output" >&2
return 1
}
for attribute in keywordId projectId provider; do
ensure_search_attribute "$$attribute"
done
temporal-ui:
image: temporalio/ui:2.49.1
depends_on:
temporal-namespace:
condition: service_completed_successfully
environment:
TEMPORAL_ADDRESS: temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:8233
ports:
- "127.0.0.1:8233:8080"
volumes:
temporal-dev-postgres-data:
temporal-dev-dynamic-config: