diff --git a/Makefile b/Makefile index 371815e..597fe19 100644 --- a/Makefile +++ b/Makefile @@ -146,24 +146,31 @@ helm-example: @echo "Example written to charts/s2s-proxy/example.yaml" # Local development environment -DEVELOP_ENV_FILE = develop/docker-compose/develop.env -DOCKER_COMPOSE_FILE ?= ./develop/docker-compose/develop.docker-compose.yaml -DOCKER_COMPOSE = docker compose --file $(DOCKER_COMPOSE_FILE) --env-file $(DEVELOP_ENV_FILE) - -PROXY_A_CONFIG_TMPL = develop/docker-compose/develop.proxy-a.tmpl.yaml -PROXY_B_CONFIG_TMPL = develop/docker-compose/develop.proxy-b.tmpl.yaml -PROMETHEUS_CONFIG_TMPL = develop/docker-compose/develop.prometheus.tmpl.yaml -PROXY_A_CONFIG = develop/docker-compose/tmp/develop.proxy-a.yaml -PROXY_B_CONFIG = develop/docker-compose/tmp/develop.proxy-b.yaml -PROMETHEUS_CONFIG = develop/docker-compose/tmp/develop.prometheus.yaml +DEVELOP_ENV_FILE = develop/docker-compose/develop.env +CORE_COMPOSE_FILE = develop/docker-compose/core.docker-compose.yaml +TEMPORAL_A_COMPOSE = develop/docker-compose/temporal-a.docker-compose.yaml +TEMPORAL_B_COMPOSE = develop/docker-compose/temporal-b.docker-compose.yaml + +DOCKER_COMPOSE = docker compose \ + --file $(CORE_COMPOSE_FILE) \ + --file $(TEMPORAL_A_COMPOSE) \ + --file $(TEMPORAL_B_COMPOSE) \ + --env-file $(DEVELOP_ENV_FILE) + +PROXY_A_CONFIG_TMPL = develop/docker-compose/develop.proxy-a.tmpl.yaml +PROXY_B_CONFIG_TMPL = develop/docker-compose/develop.proxy-b.tmpl.yaml +PROMETHEUS_CONFIG_TMPL = develop/docker-compose/develop.prometheus.tmpl.yaml +PROXY_A_CONFIG = develop/docker-compose/tmp/develop.proxy-a.yaml +PROXY_B_CONFIG = develop/docker-compose/tmp/develop.proxy-b.yaml +PROMETHEUS_CONFIG = develop/docker-compose/tmp/develop.prometheus.yaml .PHONY: generate-configs generate-configs: mkdir -p develop/docker-compose/tmp set -a && . $(DEVELOP_ENV_FILE) && set +a && \ envsubst < $(PROXY_A_CONFIG_TMPL) > $(PROXY_A_CONFIG) && \ - envsubst < $(PROXY_B_CONFIG_TMPL) > $(PROXY_B_CONFIG) && \ - envsubst < $(PROMETHEUS_CONFIG_TMPL) > $(PROMETHEUS_CONFIG) + envsubst < $(PROXY_B_CONFIG_TMPL) > $(PROXY_B_CONFIG) && \ + envsubst < $(PROMETHEUS_CONFIG_TMPL) > $(PROMETHEUS_CONFIG) .PHONY: show-dependencies-ports show-dependencies-ports: @@ -176,10 +183,23 @@ show-dependencies-ports: printf " %-34s http://localhost:%s\n", tolower(name), $$2; \ }' +.PHONY: show-server-configuration +show-server-configuration: + @echo 'Temporal server versions:' + @printf ' %-16s' 'temporal-a:' && \ + $(DOCKER_COMPOSE) exec -T temporal-a \ + sh -c 'temporal operator cluster describe --address $$(hostname -i):7233 -o json 2>/dev/null | awk -F\" "/(serverVersion|server_version)/{print \$$4}"' \ + 2>/dev/null || printf '(not running)\n' + @printf ' %-16s' 'temporal-b:' && \ + $(DOCKER_COMPOSE) exec -T temporal-b \ + sh -c 'temporal operator cluster describe --address $$(hostname -i):7233 -o json 2>/dev/null | awk -F\" "/(serverVersion|server_version)/{print \$$4}"' \ + 2>/dev/null || printf '(not running)\n' + .PHONY: start-dependencies start-dependencies: generate-configs - $(DOCKER_COMPOSE) up --detach --build --wait --wait-timeout 120 + $(DOCKER_COMPOSE) up --detach --build --wait --wait-timeout 300 @echo >&2 'Dependencies ready!' + @$(MAKE) --no-print-directory show-server-configuration @$(MAKE) --no-print-directory show-dependencies-ports .PHONY: stop-dependencies diff --git a/develop/docker-compose/develop.docker-compose.yaml b/develop/docker-compose/core.docker-compose.yaml similarity index 62% rename from develop/docker-compose/develop.docker-compose.yaml rename to develop/docker-compose/core.docker-compose.yaml index ecd96d2..ad7b059 100644 --- a/develop/docker-compose/develop.docker-compose.yaml +++ b/develop/docker-compose/core.docker-compose.yaml @@ -2,74 +2,6 @@ x-volumes: &x-volumes - ./..:/etc/develop:ro services: - temporal-a: - image: temporalio/temporal:1.5.0 - command: - - server - - start-dev - - --port - - "${TEMPORAL_INTERNAL_PORT}" - - --ip - - "0.0.0.0" - - --ui-port - - "${TEMPORAL_UI_INTERNAL_PORT}" - - --namespace - - default - - --log-level - - warn - ports: - - "${TEMPORAL_A_EXTERNAL_PORT}:${TEMPORAL_INTERNAL_PORT}" - - "${TEMPORAL_A_UI_EXTERNAL_PORT}:${TEMPORAL_UI_INTERNAL_PORT}" - networks: - - develop - healthcheck: - test: - - CMD - - temporal - - operator - - cluster - - health - - --address - - "localhost:${TEMPORAL_INTERNAL_PORT}" - interval: 5s - timeout: 5s - retries: 30 - start_period: 5s - - temporal-b: - image: temporalio/temporal:1.5.0 - command: - - server - - start-dev - - --port - - "${TEMPORAL_INTERNAL_PORT}" - - --ip - - "0.0.0.0" - - --ui-port - - "${TEMPORAL_UI_INTERNAL_PORT}" - - --namespace - - default - - --log-level - - warn - ports: - - "${TEMPORAL_B_EXTERNAL_PORT}:${TEMPORAL_INTERNAL_PORT}" - - "${TEMPORAL_B_UI_EXTERNAL_PORT}:${TEMPORAL_UI_INTERNAL_PORT}" - networks: - - develop - healthcheck: - test: - - CMD - - temporal - - operator - - cluster - - health - - --address - - "localhost:${TEMPORAL_INTERNAL_PORT}" - interval: 5s - timeout: 5s - retries: 30 - start_period: 5s - proxy-b: build: context: ../.. @@ -136,7 +68,7 @@ services: condition: service_healthy smoke-test: - image: temporalio/temporal:1.5.0 + image: temporalio/admin-tools:${TEMPORAL_CLI_VERSION} entrypoint: /bin/sh networks: - develop diff --git a/develop/docker-compose/develop.env b/develop/docker-compose/develop.env index f6d45e6..c3356a2 100644 --- a/develop/docker-compose/develop.env +++ b/develop/docker-compose/develop.env @@ -1,3 +1,16 @@ +# Use temporalio/auto-setup tags: https://hub.docker.com/r/temporalio/auto-setup/tags +TEMPORAL_A_VERSION=1.29.4 +TEMPORAL_B_VERSION=1.22.7 + +# Use temporalio/admin-tools tags: https://hub.docker.com/r/temporalio/admin-tools/tags +# In general : use max(TEMPORAL_A_VERSION, TEMPORAL_B_VERSION) +TEMPORAL_CLI_VERSION=1.29.4 + +# Infrastructure versions +# TODO: currently shared by both servers, this could be independent. +POSTGRESQL_VERSION=16 +ELASTICSEARCH_VERSION=7.17.27 + # External Ports (exposed via localhost) TEMPORAL_A_EXTERNAL_PORT=4000 TEMPORAL_B_EXTERNAL_PORT=5000 diff --git a/develop/docker-compose/temporal-a.docker-compose.yaml b/develop/docker-compose/temporal-a.docker-compose.yaml new file mode 100644 index 0000000..103b232 --- /dev/null +++ b/develop/docker-compose/temporal-a.docker-compose.yaml @@ -0,0 +1,61 @@ +services: + postgres-a: + image: postgres:${POSTGRESQL_VERSION} + environment: + POSTGRES_USER: temporal + POSTGRES_PASSWORD: temporal + networks: + - develop + healthcheck: + test: [CMD, pg_isready, -U, temporal] + interval: 5s + timeout: 5s + retries: 10 + + elasticsearch-a: + image: elasticsearch:${ELASTICSEARCH_VERSION} + environment: + discovery.type: single-node + xpack.security.enabled: "false" + ES_JAVA_OPTS: "-Xms256m -Xmx256m" + networks: + - develop + healthcheck: + test: + - CMD-SHELL + - "curl -s http://localhost:9200/_cluster/health | grep -qv '\"status\":\"red\"'" + interval: 10s + timeout: 5s + retries: 12 + + temporal-a: + image: temporalio/auto-setup:${TEMPORAL_A_VERSION} + environment: + DB: postgres12 + DB_PORT: 5432 + POSTGRES_SEEDS: postgres-a + POSTGRES_USER: temporal + POSTGRES_PWD: temporal + ENABLE_ES: "true" + ES_SEEDS: elasticsearch-a + ES_PORT: 9200 + ES_VERSION: v7 + VISIBILITY_TYPE: elasticsearch + ports: + - "${TEMPORAL_A_EXTERNAL_PORT}:${TEMPORAL_INTERNAL_PORT}" + - "${TEMPORAL_A_UI_EXTERNAL_PORT}:${TEMPORAL_UI_INTERNAL_PORT}" + networks: + - develop + depends_on: + postgres-a: + condition: service_healthy + elasticsearch-a: + condition: service_healthy + healthcheck: + test: + - CMD-SHELL + - "temporal operator cluster health --address $(hostname -i):${TEMPORAL_INTERNAL_PORT}" + interval: 5s + timeout: 5s + retries: 30 + start_period: 30s diff --git a/develop/docker-compose/temporal-b.docker-compose.yaml b/develop/docker-compose/temporal-b.docker-compose.yaml new file mode 100644 index 0000000..9ba48f0 --- /dev/null +++ b/develop/docker-compose/temporal-b.docker-compose.yaml @@ -0,0 +1,61 @@ +services: + postgres-b: + image: postgres:${POSTGRESQL_VERSION} + environment: + POSTGRES_USER: temporal + POSTGRES_PASSWORD: temporal + networks: + - develop + healthcheck: + test: [CMD, pg_isready, -U, temporal] + interval: 5s + timeout: 5s + retries: 10 + + elasticsearch-b: + image: elasticsearch:${ELASTICSEARCH_VERSION} + environment: + discovery.type: single-node + xpack.security.enabled: "false" + ES_JAVA_OPTS: "-Xms256m -Xmx256m" + networks: + - develop + healthcheck: + test: + - CMD-SHELL + - "curl -s http://localhost:9200/_cluster/health | grep -qv '\"status\":\"red\"'" + interval: 10s + timeout: 5s + retries: 12 + + temporal-b: + image: temporalio/auto-setup:${TEMPORAL_B_VERSION} + environment: + DB: postgres12 + DB_PORT: 5432 + POSTGRES_SEEDS: postgres-b + POSTGRES_USER: temporal + POSTGRES_PWD: temporal + ENABLE_ES: "true" + ES_SEEDS: elasticsearch-b + ES_PORT: 9200 + ES_VERSION: v7 + VISIBILITY_TYPE: elasticsearch + ports: + - "${TEMPORAL_B_EXTERNAL_PORT}:${TEMPORAL_INTERNAL_PORT}" + - "${TEMPORAL_B_UI_EXTERNAL_PORT}:${TEMPORAL_UI_INTERNAL_PORT}" + networks: + - develop + depends_on: + postgres-b: + condition: service_healthy + elasticsearch-b: + condition: service_healthy + healthcheck: + test: + - CMD-SHELL + - "temporal operator cluster health --address $(hostname -i):${TEMPORAL_INTERNAL_PORT}" + interval: 5s + timeout: 5s + retries: 30 + start_period: 30s