commit df1034cb47929870478c35006f168ed08bf4cd08 Author: Christian Galo Date: Thu Oct 16 08:17:14 2025 +0000 Initial working config! diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..faa700b --- /dev/null +++ b/README @@ -0,0 +1,24 @@ +# Temporal + +Wiki Cafe's configuration for a Temporal deployment. + + +## Deploying the app with Docker Swarm + +Set the environment variables from the .env file during the shell session. + +``` +set -a && source .env && set +a +``` + +Set the secrets. + +``` +printf "SECRET_HERE" | docker secret create SECRET_NAME - +``` + +Deploy using the `-c` flag to specify one or multiple compose files. + +``` +docker stack deploy temporal --detach=true -c compose.yaml +``` diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..ba42cd5 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,96 @@ +services: + db: + image: postgres:18.0 + environment: + - POSTGRES_HOST_AUTH_METHOD=trust + - POSTGRES_USER=temporal + - POSTGRES_PASSWORD_FILE=/run/secrets/db_password + - POSTGRES_DB=temporal + networks: + - internal + volumes: + - 'postgresql_data:/var/lib/postgresql/data' + secrets: + - db_password + + temporal: + image: temporalio/auto-setup:1.29.0 + depends_on: + - db + configs: + - source: entrypoint + target: /entrypoint.sh + mode: 0555 + - source: dynamicconfig # This might be better as a volume + target: /etc/temporal/config/dynamicconfig/development-sql.yaml + entrypoint: /entrypoint.sh + command: "autosetup" + environment: + - DB=postgres12 + - DB_PORT=5432 + - POSTGRES_USER=temporal + - POSTGRES_PWD_FILE=/run/secrets/db_password # entrypoint.sh exports POSTGRES_PWD + - POSTGRES_SEEDS=db + - DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development-sql.yaml # What is this + networks: + - internal + secrets: + - db_password + + admin-tools: + image: temporalio/admin-tools:1.29 + depends_on: + - temporal + networks: + - internal + environment: + - TEMPORAL_ADDRESS=temporal:7233 + - TEMPORAL_CLI_ADDRESS=temporal:7233 + + ui: + image: temporalio/ui:2.41.0 + depends_on: + - temporal + networks: + - internal + - proxy + # entrypoint: ["tail"] + # command: ["-f", "/dev/null"] + environment: + - TEMPORAL_ADDRESS=temporal:7233 + - TEMPORAL_CORS_ORIGINS=https://${DOMAIN} + - TEMPORAL_AUTH_ENABLED + - TEMPORAL_AUTH_PROVIDER_URL + - TEMPORAL_AUTH_ISSUER_URL + - TEMPORAL_AUTH_CLIENT_ID + - TEMPORAL_AUTH_CLIENT_SECRET + - TEMPORAL_AUTH_CALLBACK_URL + - TEMPORAL_AUTH_SCOPES + - LOG_LEVEL=debug + deploy: + update_config: + failure_action: rollback + order: start-first + labels: + - "caddy=${DOMAIN}" + - "caddy.reverse_proxy={{upstreams 8080}}" + - "caddy.tls.on_demand=" + +secrets: + db_password: + external: true + name: ${STACK_NAME}_db_password + +volumes: + postgresql_data: + +networks: + proxy: + external: true + internal: + +configs: + entrypoint: + file: entrypoint.sh + dynamicconfig: + file: dynamicconfig/development-sql.yaml \ No newline at end of file diff --git a/dynamicconfig/README.md b/dynamicconfig/README.md new file mode 100644 index 0000000..85a37c0 --- /dev/null +++ b/dynamicconfig/README.md @@ -0,0 +1,39 @@ +Use `docker.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 +``` diff --git a/dynamicconfig/development-cass.yaml b/dynamicconfig/development-cass.yaml new file mode 100644 index 0000000..4b91616 --- /dev/null +++ b/dynamicconfig/development-cass.yaml @@ -0,0 +1,3 @@ +system.forceSearchAttributesCacheRefreshOnRead: + - value: true # Dev setup only. Please don't turn this on in production. + constraints: {} diff --git a/dynamicconfig/development-sql.yaml b/dynamicconfig/development-sql.yaml new file mode 100644 index 0000000..8862dfa --- /dev/null +++ b/dynamicconfig/development-sql.yaml @@ -0,0 +1,6 @@ +limit.maxIDLength: + - value: 255 + constraints: {} +system.forceSearchAttributesCacheRefreshOnRead: + - value: true # Dev setup only. Please don't turn this on in production. + constraints: {} diff --git a/dynamicconfig/docker.yaml b/dynamicconfig/docker.yaml new file mode 100644 index 0000000..e69de29 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..586ba5a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +file_env() { + local var="$1" + local fileVar="${var}_FILE" + + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + + if [ "${!var:-}" ]; then + export "$var"="${!var}" + elif [ "${!fileVar:-}" ]; then + export "$var"="$(< "${!fileVar}")" + else + echo >&2 "error: neither $var nor $fileVar is set" + exit 1 + fi + + unset "$fileVar" +} + +file_env POSTGRES_PWD + +exec /etc/temporal/entrypoint.sh $@