From f3729c7c8bce8fddab3d458264b05a9fb7d4b896 Mon Sep 17 00:00:00 2001 From: Akiff Manji Date: Mon, 21 Oct 2024 13:38:36 -0700 Subject: [PATCH] chore: update env variables Signed-off-by: Akiff Manji --- scripts/.env-example | 2 ++ scripts/docker-compose.yml | 2 ++ scripts/manage | 7 ++++--- .../config/custom-environment-variables.json | 1 + services/tenant-ui/config/default.json | 5 +++-- services/tenant-ui/frontend/src/store/logStore.ts | 2 +- services/tenant-ui/frontend/vite.config.ts | 6 ++++++ services/tenant-ui/src/components/innkeeper.ts | 12 ++++++------ 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/.env-example b/scripts/.env-example index 11f8759a9..9629861ad 100644 --- a/scripts/.env-example +++ b/scripts/.env-example @@ -180,7 +180,9 @@ TENANT_UI_PORT=5101 # which traction api are we using? # naming convention follows what is used by the tenant ui config SERVER_TRACTION_URL=http://localhost:8032 +SERVER_LOKI_URL=ws://localhost:3100 FRONTEND_TENANT_PROXY_URL=http://localhost:8032 +FRONTEND_LOG_STREAM_URL=ws://localhost:5101/logStream IMAGE_BUILDTIME= IMAGE_TAG=scripts_tenant-ui:latest IMAGE_VERSION=latest diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml index 86b1cde91..31580281c 100755 --- a/scripts/docker-compose.yml +++ b/scripts/docker-compose.yml @@ -134,7 +134,9 @@ services: condition: service_started environment: - SERVER_TRACTION_URL=${SERVER_TRACTION_URL} + - SERVER_LOKI_URL=${SERVER_LOKI_URL} - FRONTEND_TENANT_PROXY_URL=${FRONTEND_TENANT_PROXY_URL} + - FRONTEND_LOG_STREAM_URL=${FRONTEND_LOG_STREAM_URL} - IMAGE_BUILDTIME=${IMAGE_BUILDTIME} - IMAGE_TAG=${IMAGE_TAG} - IMAGE_VERSION=${IMAGE_VERSION} diff --git a/scripts/manage b/scripts/manage index c53eed9bb..9f3de1a2d 100755 --- a/scripts/manage +++ b/scripts/manage @@ -24,13 +24,14 @@ generate_traction_ascii_art() { # Global variable to hold Docker Compose command compose_cmd="" +compose_files_opt="-f docker-compose.logs.yml -f docker-compose.yml" # Function to determine the correct Docker Compose command get_docker_compose_command() { if command -v "docker" > /dev/null && docker compose version > /dev/null 2>&1; then - compose_cmd="docker compose" + compose_cmd="docker compose $compose_files_opt" elif command -v docker-compose > /dev/null 2>&1; then - compose_cmd="docker-compose" + compose_cmd="docker-compose $compose_files_opt" else echo "Error: Neither 'docker compose' nor 'docker-compose' is installed." >&2 exit 1 @@ -65,7 +66,7 @@ build_docker_images() { fi built_services="traction-acapy-image-builder tenant-ui tenant-proxy endorser-api endorser-api-1" - pulled_services="ngrok-traction-agent traction-db endorser-db endorser-db-1 maildev endorser-agent endorser-agent-1" + pulled_services="loki promtail grafana ngrok-traction-agent traction-db endorser-db endorser-db-1 maildev endorser-agent endorser-agent-1" $compose_cmd build $built_services --no-cache --parallel $compose_cmd pull $pulled_services } diff --git a/services/tenant-ui/config/custom-environment-variables.json b/services/tenant-ui/config/custom-environment-variables.json index f4a686d84..4a1a63e5e 100644 --- a/services/tenant-ui/config/custom-environment-variables.json +++ b/services/tenant-ui/config/custom-environment-variables.json @@ -1,6 +1,7 @@ { "frontend": { "tenantProxyPath": "FRONTEND_TENANT_PROXY_URL", + "logStreamUrl": "FRONTEND_LOG_STREAM_URL", "showInnkeeperReservationPassword": "FRONTEND_INNKEEPER_SHOW_RESERVATION_PASSWORD", "showInnkeeperAdminLogin": "FRONTEND_INNKEEPER_SHOW_ADMIN", "showWritableComponents": "FRONTEND_TENANT_SHOW_WRITABLE_COMPONENTS", diff --git a/services/tenant-ui/config/default.json b/services/tenant-ui/config/default.json index ce1bd8ad3..dcb89a0cd 100644 --- a/services/tenant-ui/config/default.json +++ b/services/tenant-ui/config/default.json @@ -1,6 +1,7 @@ { "frontend": { "tenantProxyPath": "http://localhost:8032", + "logStreamUrl": "ws://localhost:5101/logStream", "apiPath": "api/", "basePath": "/", "showDeveloper": true, @@ -53,8 +54,8 @@ "logLevel": "http", "port": "8080", "staticFiles": "../../frontend/dist", - "tractionUrl": "http://localhost:5100", - "lokiUrl": "ws://localhost:3100", + "tractionUrl": "http://host.docker.internal:8032", + "lokiUrl": "ws://host.docker.internal:3100", "oidc": { "jwksUri": "https://dev.loginproxy.gov.bc.ca/auth/realms/digitaltrust-citz/protocol/openid-connect/certs", "realm": "digitaltrust-citz", diff --git a/services/tenant-ui/frontend/src/store/logStore.ts b/services/tenant-ui/frontend/src/store/logStore.ts index 04aeab9a1..e3652a7c4 100644 --- a/services/tenant-ui/frontend/src/store/logStore.ts +++ b/services/tenant-ui/frontend/src/store/logStore.ts @@ -43,7 +43,7 @@ export const useLogStore = defineStore('log', () => { } if (!logStream.value) { logStream.value = new WebSocket( - `${config.server.lokiUrl}?token=${token}` + `${config.frontend.logStreamUrl}?token=${token}` ); logStream.value.onopen = () => { logStreamState.value = LogStreamState.OPEN; diff --git a/services/tenant-ui/frontend/vite.config.ts b/services/tenant-ui/frontend/vite.config.ts index 682bb7495..26c7f8cea 100644 --- a/services/tenant-ui/frontend/vite.config.ts +++ b/services/tenant-ui/frontend/vite.config.ts @@ -28,6 +28,12 @@ export default defineConfig({ }, server: { proxy: { + '/logStream': { + target: 'ws://localhost:8080', + ws: true, + changeOrigin: true, + rewrite: (path) => path.replace(/^\/logStream/, ''), + }, '/api': proxyObject, '/config': proxyObject, }, diff --git a/services/tenant-ui/src/components/innkeeper.ts b/services/tenant-ui/src/components/innkeeper.ts index 56099ad62..003418a53 100644 --- a/services/tenant-ui/src/components/innkeeper.ts +++ b/services/tenant-ui/src/components/innkeeper.ts @@ -1,8 +1,8 @@ import axios from "axios"; import config from "config"; -const TRACURL: string = config.get("server.tractionUrl"); -const INN_USER = config.get("server.innkeeper.user"); -const INN_PW = config.get("server.innkeeper.key"); +const TRACTION_URL: string = config.get("server.tractionUrl"); +const INNKEEPER_USER = config.get("server.innkeeper.user"); +const INNKEEPER_KEY = config.get("server.innkeeper.key"); /** * @function login @@ -10,8 +10,8 @@ const INN_PW = config.get("server.innkeeper.key"); * @returns {string} The inkeeper token */ export const login = async () => { - const loginUrl = `${TRACURL}/multitenancy/tenant/${INN_USER}/token`; - const payload = { wallet_key: INN_PW }; + const loginUrl = `${TRACTION_URL}/multitenancy/tenant/${INNKEEPER_USER}/token`; + const payload = { wallet_key: INNKEEPER_KEY }; const res = await axios({ method: "post", url: loginUrl, @@ -29,7 +29,7 @@ export const login = async () => { export const createReservation = async (req: any, token: string) => { try { const auth = `Bearer ${token}`; - const reservationUrl = `${TRACURL}/innkeeper/reservations`; + const reservationUrl = `${TRACTION_URL}/innkeeper/reservations`; const payload = req.body; const res = await axios({