Copy from main temporal repo

This commit is contained in:
Alex Shtin
2021-01-08 14:51:44 -08:00
parent 5fbb9786d2
commit fd48df8e73
16 changed files with 717 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.idea
docker-compose.tar.gz

8
Makefile Normal file
View File

@@ -0,0 +1,8 @@
release: update-tag tar
update-tag:
go run tools/tag-tool.go -server-tag=$(SERVER_TAG) -web-tag=$(WEB_TAG)
tar:
rm -f docker-compose.tar.gz
tar -zcvf docker-compose.tar.gz docker-compose*.yml dynamicconfig/* README.md

88
README.md Normal file
View File

@@ -0,0 +1,88 @@
# Temporal docker-compose files
With provided docker-compose files you can run a local version of Temporal server with dependencies.
Try our [Go](https://github.com/temporalio/samples-go) and [Java](https://github.com/temporalio/java-go) samples to see it in action.
## Installing prerequisites
Install:
* [docker](https://docs.docker.com/engine/installation/)
* [docker-compose](https://docs.docker.com/compose/install/)
## Default configuration
With every release of the Temporal server, there is also a corresponding
docker hub image .
The following step will bring up a docker container that is running the Temporal server
and its dependencies (cassandra). The Temporal gRPC frontend is exposed on port `7233`.
```bash
$ docker-compose up
```
View Temporal Web UI at [http://localhost:8088](http://localhost:8088).
Use preconfigured Temporal CLI tool (`tctl`) from `temporal-admin-tools`:
```bash
$ alias tctl="docker-compose exec temporal-admin-tools tctl"
```
For example to register new namespace `test-namespace` with 1 retention day:
```bash
$ tctl --ns test-namespace namespace register -rd 1
```
## Custom image configuration
Clone main Temporal repo: [https://github.com/temporalio/temporal](https://github.com/temporalio/temporal):
```bash
$ git clone https://github.com/temporalio/temporal.git
```
Replace **YOUR_TAG** and **YOUR_COMMIT** in the below command and build custom docker image of Temporal server:
```bash
$ git checkout YOUR_COMMIT
$ docker build . -t temporalio/auto-setup:YOUR_TAG --build-arg TARGET=auto-setup
```
Replace the tag of **image: temporalio/auto-setup** to **YOUR_TAG** in `docker-compose.yml`.
Then start the service using the below commands:
```bash
$ docker-compose up
```
## Other storage configurations
Default `docker-compose.yml` file runs Temporal server with Cassandra. There are other configuration files:
| File | Description |
|------------------------------|-------------|
| docker-compose.yml | Cassandra (default) |
| docker-compose-cas-es.yml | Cassandra and Elasticsearch |
| docker-compose-mysql.yml | MySQL |
| docker-compose-mysql-es.yml | MySQL and Elasticsearch |
| docker-compose-postgres.yml | PostgreSQL |
| docker-compose-cockroach.yml | CockroachDB |
Use one of the these files to run corresponding Temporal configuration. For example to run Temporal with MySQL
and Elasticsearch for enhance visibility queries run:
```bash
$ docker-compose -f docker-compose-mysql-es.yml up
```
## Quickstart for production
In a typical production setting, dependencies (such as `cassandra` or `elasticsearch`) are managed/started independently of the Temporal server.
To use the container in a production setting, use the following command:
```bash
$ docker run -e CASSANDRA_SEEDS=10.x.x.x -- csv of cassandra server ipaddrs
-e KEYSPACE=<keyspace> -- Cassandra keyspace
-e VISIBILITY_KEYSPACE=<visibility_keyspace> -- Cassandra visibility keyspace
-e SKIP_SCHEMA_SETUP=true -- do not setup cassandra schema during startup
-e RINGPOP_SEEDS=10.x.x.x,10.x.x.x \ -- csv of ipaddrs for gossip bootstrap
-e NUM_HISTORY_SHARDS=1024 \ -- Number of history shards
-e SERVICES=history,matching \ -- Spinup only the provided services
-e LOG_LEVEL=debug,info \ -- Logging level
-e DYNAMIC_CONFIG_FILE_PATH=config/foo.yaml -- Dynamic config file to be watched
temporalio/server:<tag>
```

14
RELEASE.md Normal file
View File

@@ -0,0 +1,14 @@
Create new release
==================
To update image tags in `docker-compose*.yml` files and create `docker-compose.tag.gz` run:
```bash
$ make release SERVER_TAG=<current_release_server_tag> WEB_TAG=<current_release_web_tag>
```
For example:
```bash
$ make release SERVER_TAG=1.5.1 WEB_TAG=1.4.1
```

86
docker-compose-cas-es.yml Normal file
View File

@@ -0,0 +1,86 @@
version: "3.5"
services:
cassandra:
container_name: temporal-cassandra
image: cassandra:3.11
ports:
- 9042:9042
networks:
- temporal-network
elasticsearch:
container_name: temporal-elasticsearch
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms100m -Xmx100m
image: elasticsearch:7.10.1
ports:
- 9200:9200
networks:
- temporal-network
kafka:
container_name: temporal-kafka
depends_on:
- zookeeper
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
image: wurstmeister/kafka:2.12-2.1.1
ports:
- 9092:9092
networks:
- temporal-network
temporal:
container_name: temporal
depends_on:
- cassandra
- kafka
- elasticsearch
environment:
- CASSANDRA_SEEDS=cassandra
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development_es.yaml
- ENABLE_ES=true
- ES_SEEDS=elasticsearch
- ES_VERSION=v7
- KAFKA_SEEDS=kafka
image: temporalio/auto-setup:1.5.1
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
- temporal-network
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
stdin_open: true
tty: true
networks:
- temporal-network
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
image: temporalio/web:1.4.1
ports:
- 8088:8088
networks:
- temporal-network
zookeeper:
container_name: temporal-zookeper
image: wurstmeister/zookeeper:3.4.6
ports:
- 2181:2181
networks:
- temporal-network
networks:
temporal-network:
driver: bridge
name: temporal-network

View File

@@ -0,0 +1,64 @@
version: "3.5"
services:
cockroach:
cap_drop:
- ALL
command:
- start-single-node
- --insecure
container_name: temporal-cockroach
hostname: cockroach
image: cockroachdb/cockroach
restart: on-failure:5
security_opt:
- no-new-privileges
tty: false
networks:
- temporal-network
temporal:
container_name: temporal
depends_on:
- cockroach
environment:
- DB=postgresql
- DB_PORT=26257
- POSTGRES_USER=root
- POSTGRES_PWD=
- POSTGRES_SEEDS=postgres
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
image: temporalio/auto-setup:1.5.1
links:
- cockroach:postgres
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
- temporal-network
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
stdin_open: true
tty: true
networks:
- temporal-network
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
image: temporalio/web:1.4.1
ports:
- 8088:8088
networks:
- temporal-network
networks:
temporal-network:
driver: bridge
name: temporal-network

View File

@@ -0,0 +1,90 @@
version: "3.5"
services:
elasticsearch:
container_name: temporal-elasticsearch
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms100m -Xmx100m
image: elasticsearch:7.10.1
ports:
- 9200:9200
networks:
- temporal-network
kafka:
container_name: temporal-kafka
depends_on:
- zookeeper
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
image: wurstmeister/kafka:2.12-2.1.1
ports:
- 9092:9092
networks:
- temporal-network
mysql:
container_name: temporal-mysql
environment:
- MYSQL_ROOT_PASSWORD=root
image: mysql:5.7
ports:
- 3306:3306
networks:
- temporal-network
temporal:
container_name: temporal
depends_on:
- mysql
- elasticsearch
- kafka
environment:
- DB=mysql
- MYSQL_USER=root
- MYSQL_PWD=root
- MYSQL_SEEDS=mysql
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development_es.yaml
- ENABLE_ES=true
- ES_SEEDS=elasticsearch
- ES_VERSION=v7
- KAFKA_SEEDS=kafka
image: temporalio/auto-setup:1.5.1
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
- temporal-network
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
stdin_open: true
tty: true
networks:
- temporal-network
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
image: temporalio/web:1.4.1
ports:
- 8088:8088
networks:
- temporal-network
zookeeper:
container_name: temporal-zookeeper
image: wurstmeister/zookeeper:3.4.6
ports:
- 2181:2181
networks:
- temporal-network
networks:
temporal-network:
driver: bridge
name: temporal-network

56
docker-compose-mysql.yml Normal file
View File

@@ -0,0 +1,56 @@
version: "3.5"
services:
mysql:
container_name: temporal-mysql
environment:
- MYSQL_ROOT_PASSWORD=root
image: mysql:5.7
ports:
- 3306:3306
networks:
- temporal-network
temporal:
container_name: temporal
depends_on:
- mysql
environment:
- DB=mysql
- DB_PORT=3306
- MYSQL_USER=root
- MYSQL_PWD=root
- MYSQL_SEEDS=mysql
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
image: temporalio/auto-setup:1.5.1
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
- temporal-network
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
stdin_open: true
tty: true
networks:
- temporal-network
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
image: temporalio/web:1.4.1
ports:
- 8088:8088
networks:
- temporal-network
networks:
temporal-network:
driver: bridge
name: temporal-network

View File

@@ -0,0 +1,57 @@
version: "3.5"
services:
postgresql:
container_name: temporal-postgresql
environment:
POSTGRES_PASSWORD: temporal
POSTGRES_USER: temporal
image: postgres:9.6
ports:
- 5432:5432
networks:
- temporal-network
temporal:
container_name: temporal
depends_on:
- postgresql
environment:
- DB=postgresql
- DB_PORT=5432
- POSTGRES_USER=temporal
- POSTGRES_PWD=temporal
- POSTGRES_SEEDS=postgresql
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
image: temporalio/auto-setup:1.5.1
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
- temporal-network
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
stdin_open: true
tty: true
networks:
- temporal-network
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
image: temporalio/web:1.4.1
ports:
- 8088:8088
networks:
- temporal-network
networks:
temporal-network:
driver: bridge
name: temporal-network

50
docker-compose.yml Normal file
View File

@@ -0,0 +1,50 @@
version: "3.5"
services:
cassandra:
container_name: temporal-cassandra
image: cassandra:3.11
networks:
- temporal-network
ports:
- 9042:9042
temporal:
container_name: temporal
depends_on:
- cassandra
environment:
- CASSANDRA_SEEDS=cassandra
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
image: temporalio/auto-setup:1.5.1
networks:
- temporal-network
ports:
- 7233:7233
volumes:
- ./dynamicconfig:/etc/temporal/config/dynamicconfig
temporal-admin-tools:
container_name: temporal-admin-tools
depends_on:
- temporal
environment:
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:1.5.1
networks:
- temporal-network
stdin_open: true
tty: true
temporal-web:
container_name: temporal-web
depends_on:
- temporal
environment:
- TEMPORAL_GRPC_ENDPOINT=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
image: temporalio/web:1.4.1
networks:
- temporal-network
ports:
- 8088:8088
networks:
temporal-network:
driver: bridge
name: temporal-network

39
dynamicconfig/README.md Normal file
View File

@@ -0,0 +1,39 @@
Use `development.yaml` file to override the default dynamic config value (they are specified
when creating the service config).
Each key can have zero or more values and each value can have zero or more
constraints. There are only three types of constraint:
1. `namespace`: `string`
2. `taskQueueName`: `string`
3. `taskType`: `int` (`1`:`Workflow`, `2`:`Activity`)
A value will be selected and returned if all its has exactly the same constraints
as the ones specified in query filters (including the number of constraints).
Please use the following format:
```
testGetBoolPropertyKey:
- value: false
- value: true
constraints:
namespace: "global-samples-namespace"
- value: false
constraints:
namespace: "samples-namespace"
testGetDurationPropertyKey:
- value: "1m"
constraints:
namespace: "samples-namespace"
taskQueueName: "longIdleTimeTaskqueue"
testGetFloat64PropertyKey:
- value: 12.0
constraints:
namespace: "samples-namespace"
testGetMapPropertyKey:
- value:
key1: 1
key2: "value 2"
key3:
- false
- key4: true
key5: 2.0
```

View File

@@ -0,0 +1,33 @@
frontend.enableClientVersionCheck:
- value: true
constraints: {}
history.persistenceMaxQPS:
- value: 3000
constraints: {}
frontend.persistenceMaxQPS:
- value: 3000
constraints: {}
frontend.historyMgrNumConns:
- value: 10
constraints: {}
frontend.throttledLogRPS:
- value: 20
constraints: {}
history.historyMgrNumConns:
- value: 50
constraints: {}
system.advancedVisibilityWritingMode:
- value: "off"
constraints: {}
history.defaultActivityRetryPolicy:
- value:
InitialIntervalInSeconds: 1
MaximumIntervalCoefficient: 100.0
BackoffCoefficient: 2.0
MaximumAttempts: 0
history.defaultWorkflowRetryPolicy:
- value:
InitialIntervalInSeconds: 1
MaximumIntervalCoefficient: 100.0
BackoffCoefficient: 2.0
MaximumAttempts: 0

View File

@@ -0,0 +1,31 @@
frontend.enableClientVersionCheck:
- value: true
system.advancedVisibilityWritingMode:
- value: "on"
system.enableReadVisibilityFromES:
- value: true
frontend.validSearchAttributes:
- value:
NamespaceId: "Keyword"
WorkflowId: "Keyword"
RunId: "Keyword"
WorkflowType: "Keyword"
StartTime: "Int"
ExecutionTime: "Int"
CloseTime: "Int"
ExecutionStatus: "Int"
HistoryLength: "Int"
TaskQueue: "Keyword"
KafkaKey: "Keyword"
Encoding: "Keyword"
CustomStringField: "String"
CustomKeywordField: "Keyword"
CustomIntField: "Int"
CustomDoubleField: "Double"
CustomBoolField: "Bool"
CustomDatetimeField: "Datetime"
TemporalChangeVersion: "Keyword"
BinaryChecksums: "Keyword"
CustomNamespace: "Keyword"
Operator: "Keyword"

5
tools/go.mod Normal file
View File

@@ -0,0 +1,5 @@
module tools
go 1.15
require gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b

4
tools/go.sum Normal file
View File

@@ -0,0 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

90
tools/tag-tool.go Normal file
View File

@@ -0,0 +1,90 @@
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v3"
)
func main() {
var root, fileRegex string
flag.StringVar(&root, "root", ".", "root to scan")
flag.StringVar(&fileRegex, "file-regex", `docker-compose.*\.(?:y|ya)ml`, "file prefix to process")
var serverTag, webTag string
flag.StringVar(&serverTag, "server-tag", "", "server images tag to set")
flag.StringVar(&webTag, "web-tag", "", "web image tag to set")
flag.Parse()
serviceTags := map[string]string{
"temporal": serverTag,
"temporal-admin-tools": serverTag,
"temporal-web": webTag,
}
fileRx,err := regexp.Compile(fileRegex)
if err != nil{
log.Fatal(err)
}
err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if fileRx.MatchString(info.Name()) {
composeFile, err := ioutil.ReadFile(path)
if err != nil {
return err
}
var composeStruct struct {
Version string
Services map[string]map[string]interface{}
Networks map[string]interface{}
}
err = yaml.Unmarshal(composeFile, &composeStruct)
services := composeStruct.Services
fileUpdated := false
for serviceName, serviceCfg := range services {
tag, ok := serviceTags[serviceName]
if !ok || tag == "" {
continue
}
imageValue := serviceCfg["image"].(string)
imageValues := strings.Split(imageValue, ":")
newImageValue := fmt.Sprintf("%s:%s", imageValues[0], tag)
if imageValue != newImageValue {
serviceCfg["image"] = newImageValue
fileUpdated = true
}
}
if !fileUpdated {
return nil
}
var newComposeFile bytes.Buffer
enc := yaml.NewEncoder(&newComposeFile)
enc.SetIndent(2)
err = enc.Encode(composeStruct)
if err != nil {
return err
}
err = enc.Close()
if err != nil {
return err
}
err = ioutil.WriteFile(path, newComposeFile.Bytes(), os.ModePerm)
if err != nil {
return err
}
}
return nil
})
if err != nil {
log.Fatal(err)
}
}