From caf33c3021c5b97d53100fcfee14162c20c896ec Mon Sep 17 00:00:00 2001 From: Yury Hrytsuk <50014626+YuryHrytsuk@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:26:41 +0200 Subject: [PATCH] Expose payments service (#385) * Expose payments service * Expose payments service --- scripts/common.Makefile | 23 ++++++++++++++++++++--- services/simcore/docker-compose.yml | 21 +++++++++++++++++++++ services/simcore/template.env | 1 + 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/scripts/common.Makefile b/scripts/common.Makefile index 8a95fa21..9ce31037 100644 --- a/scripts/common.Makefile +++ b/scripts/common.Makefile @@ -60,13 +60,13 @@ endif export DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL=$(shell set -o allexport; \ source $(REPO_CONFIG_LOCATION); \ if [ -z "$${DEPLOYMENT_FQDNS}" ]; then \ - DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="(Host(\`$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (Host(\`invitations.${MACHINE_FQDN}\`)) || (HostRegexp(\`services.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$MACHINE_FQDN\`) && PathPrefix(\`/\`))"; \ + DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="(Host(\`$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (Host(\`invitations.${MACHINE_FQDN}\`)) || (Host(\`payments.${MACHINE_FQDN}\`)) || (HostRegexp(\`services.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$MACHINE_FQDN\`) && PathPrefix(\`/\`))"; \ else \ IFS=', ' read -r -a hosts <<< "$${DEPLOYMENT_FQDNS}"; \ - DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="(Host(\`$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (Host(\`invitations.${MACHINE_FQDN}\`)) || (HostRegexp(\`services.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$MACHINE_FQDN\`) && PathPrefix(\`/\`))"; \ + DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="(Host(\`$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (Host(\`invitations.${MACHINE_FQDN}\`)) || (Host(\`payments.${MACHINE_FQDN}\`)) || (HostRegexp(\`services.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$MACHINE_FQDN\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$MACHINE_FQDN\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$MACHINE_FQDN\`) && PathPrefix(\`/\`))"; \ for element in "$${hosts[@]}"; \ do \ - DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="$$DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL || (Host(\`$$element\`) && PathPrefix(\`/\`)) || (Host(\`invitations.$$element\`)) || (HostRegexp(\`services.$$element\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$element\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$element\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$element\`) && PathPrefix(\`/\`))";\ + DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="$$DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL || (Host(\`$$element\`) && PathPrefix(\`/\`)) || (Host(\`invitations.$$element\`)) || (Host(\`payments.$$element\`)) || (HostRegexp(\`services.$$element\`,\`{subhost:[a-zA-Z0-9-]+}.services.$$element\`) && PathPrefix(\`/\`)) || (HostRegexp(\`services.testing.$$element\`,\`{subhost:[a-zA-Z0-9-]+}.services.testing.$$element\`) && PathPrefix(\`/\`))";\ done; \ DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL="$$DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL"; \ fi; \ @@ -89,6 +89,22 @@ export DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS=$(shell set -o allexport; \ echo $$DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS; \ set +o allexport; ) +export DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS=$(shell set -o allexport; \ + source $(REPO_CONFIG_LOCATION); \ + if [ -z "$${DEPLOYMENT_FQDNS}" ]; then \ + DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS="(Host(\`payments.${MACHINE_FQDN}\`))"; \ + else \ + IFS=', ' read -r -a hosts <<< "$${DEPLOYMENT_FQDNS}"; \ + DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS="(Host(\`payments.${MACHINE_FQDN}\`))"; \ + for element in "$${hosts[@]}"; \ + do \ + DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS="$$DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS || (Host(\`payments.$$element\`))";\ + done; \ + DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS="$$DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS"; \ + fi; \ + echo $$DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS; \ + set +o allexport; ) + export DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_MAINTENANCE_PAGE=$(shell set -o allexport; \ source $(REPO_CONFIG_LOCATION); \ if [ -z "$${DEPLOYMENT_FQDNS}" ]; then \ @@ -199,6 +215,7 @@ clean-default: .check_clean ## Cleans all outputs export DEPLOYMENT_FQDNS_TESTING_CAPTURE_TRAEFIK_RULE='${DEPLOYMENT_FQDNS_TESTING_CAPTURE_TRAEFIK_RULE}'; \ export DEPLOYMENT_API_DOMAIN_TESTING_CAPTURE_TRAEFIK_RULE='${DEPLOYMENT_API_DOMAIN_TESTING_CAPTURE_TRAEFIK_RULE}'; \ export DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS='${DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS}'; \ + export DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS='${DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS}'; \ export DOLLAR='$$'; \ set +o allexport; \ envsubst < $< > .env diff --git a/services/simcore/docker-compose.yml b/services/simcore/docker-compose.yml index 1889fc5d..f42489af 100644 --- a/services/simcore/docker-compose.yml +++ b/services/simcore/docker-compose.yml @@ -775,6 +775,27 @@ services: placement: constraints: - node.labels.ops==true + + payments: + deploy: + placement: + constraints: + - node.labels.simcore==true + labels: + - traefik.enable=true + - io.simcore.zone=${TRAEFIK_SIMCORE_ZONE} + - traefik.http.routers.${SWARM_STACK_NAME}_payments_api.service=${SWARM_STACK_NAME}_payments + - traefik.http.routers.${SWARM_STACK_NAME}_payments_api.rule=${DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS} && PathPrefix(`/v1`) + - traefik.http.routers.${SWARM_STACK_NAME}_payments_api.entrypoints=http + - traefik.http.routers.${SWARM_STACK_NAME}_payments_api.priority=5 + - traefik.http.services.${SWARM_STACK_NAME}_payments.loadbalancer.server.port=8000 + - traefik.http.routers.${SWARM_STACK_NAME}_payments.service=${SWARM_STACK_NAME}_payments + - traefik.http.routers.${SWARM_STACK_NAME}_payments.rule=(${DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS}) + - traefik.http.routers.${SWARM_STACK_NAME}_payments.entrypoints=http + - traefik.http.routers.${SWARM_STACK_NAME}_payments.priority=50 + - traefik.http.middlewares.${SWARM_STACK_NAME_NO_HYPHEN}_payments_auth.basicauth.users=${TRAEFIK_USER}:${TRAEFIK_PASSWORD} + - traefik.http.routers.${SWARM_STACK_NAME}_payments.middlewares=${SWARM_STACK_NAME_NO_HYPHEN}_payments_auth, ${SWARM_STACK_NAME_NO_HYPHEN}_sslheader + volumes: rabbit_data: name: ${SWARM_STACK_NAME}_rabbit_data diff --git a/services/simcore/template.env b/services/simcore/template.env index 6ba8f838..25a95bb7 100644 --- a/services/simcore/template.env +++ b/services/simcore/template.env @@ -54,6 +54,7 @@ DEPLOYMENT_FQDNS_CAPTURE_TRAEFIK_RULE_CATCHALL='${DEPLOYMENT_FQDNS_CAPTURE_TRAEF DEPLOYMENT_FQDNS_TESTING_CAPTURE_TRAEFIK_RULE='${DEPLOYMENT_FQDNS_TESTING_CAPTURE_TRAEFIK_RULE}' DEPLOYMENT_API_DOMAIN_TESTING_CAPTURE_TRAEFIK_RULE='${DEPLOYMENT_API_DOMAIN_TESTING_CAPTURE_TRAEFIK_RULE}' DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS='${DEPLOYMENT_FQDNS_CAPTURE_INVITATIONS}' +DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS='${DEPLOYMENT_FQDNS_CAPTURE_PAYMENTS}' EC2_ACCESS_KEY_ID=${AUTOSCALING_EC2_ACCESS_KEY_ID} EC2_SECRET_ACCESS_KEY=${AUTOSCALING_EC2_SECRET_ACCESS_KEY}