From 1a904a6f72676fb89f87dd2da14c01d291371f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Rib=C3=B3?= Date: Mon, 25 Sep 2023 18:00:22 +0200 Subject: [PATCH] fix: Adding localhost environment variable in run.sh script for local development (#728) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Javier Ribó --- .github/workflows/e2e-tests.yml | 2 ++ infrastructure/local/run.sh | 9 ++++++++- infrastructure/shared/apisix/conf/apisix.yaml | 3 +++ infrastructure/shared/docker-compose-demo.yml | 2 +- infrastructure/shared/docker-compose.yml | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4067b56ad0..ff4f0829ea 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -69,6 +69,7 @@ jobs: DEFAULT_WALLET_ENABLED: "false" API_KEY_AUTO_PROVISIONING: "false" API_KEY_ENABLED: "true" + DOCKERHOST: "host.docker.internal" uses: isbang/compose-action@v1.4.1 with: compose-file: "./infrastructure/shared/docker-compose-demo.yml" @@ -85,6 +86,7 @@ jobs: DEFAULT_WALLET_AUTH_API_KEY: default API_KEY_AUTO_PROVISIONING: false API_KEY_ENABLED: true + DOCKERHOST: "host.docker.internal" uses: isbang/compose-action@v1.4.1 with: compose-file: "./infrastructure/shared/docker-compose-demo.yml" diff --git a/infrastructure/local/run.sh b/infrastructure/local/run.sh index d1d786040a..3bc5e6987f 100755 --- a/infrastructure/local/run.sh +++ b/infrastructure/local/run.sh @@ -45,6 +45,11 @@ while [[ $# -gt 0 ]]; do WAIT="--wait" shift # past argument ;; + -d | --dockerhost) + DOCKERHOST="$2" + shift # past argument + shift # past value + ;; -e | --env) ENV_FILE="$2" shift # past argument @@ -96,6 +101,7 @@ NAME="${NAME:=local}" PORT="${PORT:=80}" ENV_FILE="${ENV_FILE:=${SCRIPT_DIR}/.env}" NETWORK="${NETWORK:=${NAME}-prism}" +DOCKERHOST="${DOCKERHOST:=host.docker.internal}" echo "NAME = ${NAME}" echo "PORT = ${PORT}" @@ -103,6 +109,7 @@ echo "ENV_FILE = ${ENV_FILE}" echo "NETWORK = ${NETWORK}" echo "GLOBAL_WEBHOOK_URL = ${GLOBAL_WEBHOOK_URL}" echo "GLOBAL_WEBHOOK_API_KEY = ${GLOBAL_WEBHOOK_API_KEY}" +echo "DOCKERHOST = ${DOCKERHOST}" echo "--------------------------------------" echo "Starting stack using docker compose" @@ -116,7 +123,7 @@ if [ -n "$GLOBAL_WEBHOOK_API_KEY" ]; then export GLOBAL_WEBHOOK_API_KEY=${GLOBAL_WEBHOOK_API_KEY} fi -PORT=${PORT} NETWORK=${NETWORK} docker compose \ +PORT=${PORT} NETWORK=${NETWORK} DOCKERHOST=${DOCKERHOST} docker compose \ -p ${NAME} \ -f ${SCRIPT_DIR}/../shared/docker-compose.yml \ --env-file ${ENV_FILE} ${DEBUG} up ${BACKGROUND} ${WAIT} diff --git a/infrastructure/shared/apisix/conf/apisix.yaml b/infrastructure/shared/apisix/conf/apisix.yaml index ee7c57b8d0..670961739f 100644 --- a/infrastructure/shared/apisix/conf/apisix.yaml +++ b/infrastructure/shared/apisix/conf/apisix.yaml @@ -1,5 +1,6 @@ plugins: - name: proxy-rewrite + - name: cors routes: - uri: /prism-agent/* @@ -15,6 +16,8 @@ routes: - uri: /didcomm* upstream_id: 3 plugins: + cors: + allow_origins: "*" proxy-rewrite: regex_uri: ["^/didcomm(.*)", "/$1"] - uri: /apidocs/* diff --git a/infrastructure/shared/docker-compose-demo.yml b/infrastructure/shared/docker-compose-demo.yml index 8a35ef6b44..2021606da1 100644 --- a/infrastructure/shared/docker-compose-demo.yml +++ b/infrastructure/shared/docker-compose-demo.yml @@ -30,7 +30,7 @@ services: prism-agent: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - DIDCOMM_SERVICE_URL: http://host.docker.internal:${PORT}/didcomm + DIDCOMM_SERVICE_URL: http://${DOCKERHOST}:${PORT}/didcomm PRISM_NODE_HOST: prism-node PRISM_NODE_PORT: 50053 SECRET_STORAGE_BACKEND: postgres diff --git a/infrastructure/shared/docker-compose.yml b/infrastructure/shared/docker-compose.yml index 3694e0d51d..2f18e1082f 100644 --- a/infrastructure/shared/docker-compose.yml +++ b/infrastructure/shared/docker-compose.yml @@ -92,7 +92,7 @@ services: AGENT_DB_NAME: agent AGENT_DB_USER: postgres AGENT_DB_PASSWORD: postgres - DIDCOMM_SERVICE_URL: http://host.docker.internal:${PORT}/didcomm + DIDCOMM_SERVICE_URL: http://${DOCKERHOST}:${PORT}/didcomm PRISM_NODE_HOST: prism-node PRISM_NODE_PORT: 50053 VAULT_ADDR: ${VAULT_ADDR:-http://vault-server:8200}