From 3286993d321c33ee88a0fc7fede0526188ffda70 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Mon, 17 Mar 2025 12:38:36 +0100 Subject: [PATCH 1/6] testing nginx proxy --- src/api/endpoints/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index cf250c3c..1957434b 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -134,7 +134,7 @@ export const getMatchTerms = async (term, filters = {}) => { }); }; -const fetchData = async (url, method = "GET", data = null) => { +const fetchData = async (url, method = "GET", data: object | null = null) => { try { const response = await axios({ url, @@ -153,7 +153,7 @@ const fetchData = async (url, method = "GET", data = null) => { }; export const elasticSearch = async (query) => { - const url = API_CONFIG.BASE_SCICRUNCH_URL + import.meta.env.VITE_SCICRUNCH_API_KEY + const url = API_CONFIG.BASE_SCICRUNCH_URL + "tvVqyYwrQqolqVfMo45cu31t5uEGx6RZ" try { const result = await fetchData(url, "POST", { query: { @@ -411,4 +411,4 @@ export const handleRecoverUser = async (email: string) => { console.error("Recover user failed:", error); throw error; } -}; \ No newline at end of file +}; From f5e98287a238933c756e0f682dd21d9cbbfe0dbc Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Mon, 17 Mar 2025 16:24:04 +0100 Subject: [PATCH 2/6] nginx config update --- nginx/default.conf | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/nginx/default.conf b/nginx/default.conf index e2cbeb4a..fa7f0ed2 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -1,28 +1,13 @@ -upstream interlex { - server interlex:8000; -} - server { listen 80; - location / { - root /usr/share/nginx/html/; - try_files $uri /index.html; - } + error_log /var/log/nginx/error.log debug; # todo testing remove me not for production use - location /interlex/ { + location / { root /usr/share/nginx/html/; try_files $uri /index.html; } - location ~* ^/(admin|api|logged-out|login|interlex|complete|disconnect|__debug__)/.*$ { - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - proxy_redirect off; - proxy_pass http://interlex; - } - # Proxy for Elasticsearch API requests location /api/elasticsearch { proxy_pass https://scicrunch.org/api/1/elastic/Interlex_pr/_search; From c026992841c9e7cfcf79e7fcb4295413be92ac17 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 18 Mar 2025 14:55:19 +0100 Subject: [PATCH 3/6] fixing deployment --- Dockerfile | 8 +++++++- src/api/endpoints/index.ts | 6 ++---- src/components/GraphViewer/GraphStructure.jsx | 7 ++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe8e093c..a1b63678 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,12 @@ WORKDIR ${BUILDDIR} COPY package.json ${BUILDDIR} COPY yarn.lock ${BUILDDIR} COPY nginx/default.conf ${BUILDDIR} +ARG VITE_SCICRUNCH_API_KEY +ENV VITE_SCICRUNCH_API_KEY=$VITE_SCICRUNCH_API_KEY +ARG VITE_SCICRUNCH_API_URL +ENV VITE_API_URL=$VITE_API_URL +RUN echo "VITE_SCICRUNCH_API_KEY=$VITE_SCICRUNCH_API_KEY" > .env +RUN echo "VITE_SCICRUNCH_API_URL=$VITE_API_URL" >> .env RUN yarn install COPY . ${BUILDDIR} @@ -23,4 +29,4 @@ COPY --from=frontend /app/default.conf /etc/nginx/conf.d/default.conf COPY --from=frontend /app/dist /usr/share/nginx/html/ -EXPOSE 80 \ No newline at end of file +EXPOSE 80 diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index 1957434b..b41ac363 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -4,10 +4,8 @@ import * as api from "./../../api/endpoints/interLexURIStructureAPI"; import { TERM, ONTOLOGY, ORGANIZATION } from '../../model/frontend/types' import curieParser from '../../parsers/curieParser'; import termParser, { elasticSearhParser, getTerm } from '../../parsers/termParser'; -import { Curies } from '../../model/frontend/curies'; import axios from 'axios'; import { API_CONFIG } from '../../config'; -import { config } from 'dotenv'; const useMockApi = () => mockApi; const useApi = () => api; @@ -153,7 +151,7 @@ const fetchData = async (url, method = "GET", data: object | null = null) => { }; export const elasticSearch = async (query) => { - const url = API_CONFIG.BASE_SCICRUNCH_URL + "tvVqyYwrQqolqVfMo45cu31t5uEGx6RZ" + const url = API_CONFIG.BASE_SCICRUNCH_URL + import.meta.env.VITE_SCICRUNCH_ELASTIC_KEY; try { const result = await fetchData(url, "POST", { query: { @@ -173,7 +171,7 @@ export const searchAll = async (term, filters = {}) => { /** Call Endpoint */ return searchAll("base", term, filters).then((data) => { - let terms = termParser(data.terms, term, filters); + let terms = termParser((data as any).terms, term, filters); terms?.results?.forEach( result => { result.type = TERM; }) diff --git a/src/components/GraphViewer/GraphStructure.jsx b/src/components/GraphViewer/GraphStructure.jsx index 65427c24..3e682467 100644 --- a/src/components/GraphViewer/GraphStructure.jsx +++ b/src/components/GraphViewer/GraphStructure.jsx @@ -17,7 +17,6 @@ const getName = (nodeName) => { export const getGraphStructure = (pred) => { let data = { - type : "node", name : pred.title, id : pred.title, type : ROOT, @@ -38,7 +37,6 @@ export const getGraphStructure = (pred) => { } } else { let newPredicate = { - type : "node", name : getName(child.predicate), id : child.predicate, type : PREDICATE, @@ -46,7 +44,6 @@ export const getGraphStructure = (pred) => { } let newObject = { - type : "node", name : getName(child.object), id : child.object, type : OBJECT, @@ -64,5 +61,5 @@ export const getGraphStructure = (pred) => { data.type = ROOT; } - return data; -} \ No newline at end of file + return data; +} From 3d3e79bdd7998edfd40589228c3466780845e3d8 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 18 Mar 2025 14:57:13 +0100 Subject: [PATCH 4/6] codefresh yaml updated --- deploy/codefresh/codefresh.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy/codefresh/codefresh.yml b/deploy/codefresh/codefresh.yml index 43cdacb6..a0e03fa1 100644 --- a/deploy/codefresh/codefresh.yml +++ b/deploy/codefresh/codefresh.yml @@ -18,8 +18,11 @@ steps: tag: "${{CF_BUILD_ID}}" dockerfile: Dockerfile working_directory: ./interlex - buildkit: true + buildkit: true registry: "${{CODEFRESH_REGISTRY}}" + build_arguments: + - VITE_API_URL=${{VITE_API_URL}} + - VITE_SCICRUNCH_API_KEY=${{VITE_SCICRUNCH_API_KEY}} deploy: stage: "deploy" title: "Deploying Interlex" @@ -32,4 +35,4 @@ steps: - export REGISTRY="${{REGISTRY}}/" - export DOMAIN="${{DOMAIN}}" - chmod +x ./deploy.sh - - ./deploy.sh \ No newline at end of file + - ./deploy.sh From 7068ba6a4541ec86490cc4b55f39c6caf6c0966a Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 18 Mar 2025 14:59:15 +0100 Subject: [PATCH 5/6] codefresh yaml updated 2 --- deploy/k8s/codefresh.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deploy/k8s/codefresh.yaml b/deploy/k8s/codefresh.yaml index 0344a8b7..6b0208fa 100644 --- a/deploy/k8s/codefresh.yaml +++ b/deploy/k8s/codefresh.yaml @@ -20,6 +20,9 @@ steps: working_directory: ./interlex buildkit: true registry: "${{CODEFRESH_REGISTRY}}" + build_arguments: + - VITE_API_URL=${{VITE_API_URL}} + - VITE_SCICRUNCH_API_KEY=${{VITE_SCICRUNCH_API_KEY}} deploy: stage: "deploy" title: "Deploying interlex" From cbfc4ada88b933d4d9d5cff151e9484a4dcf228c Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 18 Mar 2025 16:18:59 +0100 Subject: [PATCH 6/6] fixing deployment --- deploy/codefresh/codefresh.yml | 23 ++++++++++---------- deploy/k8s/codefresh.yaml | 37 -------------------------------- src/api/endpoints/index.ts | 2 +- src/components/Header/Search.jsx | 8 +++---- src/config.js | 3 ++- 5 files changed, 18 insertions(+), 55 deletions(-) delete mode 100644 deploy/k8s/codefresh.yaml diff --git a/deploy/codefresh/codefresh.yml b/deploy/codefresh/codefresh.yml index a0e03fa1..6b0208fa 100644 --- a/deploy/codefresh/codefresh.yml +++ b/deploy/codefresh/codefresh.yml @@ -6,16 +6,16 @@ stages: steps: clone: stage: "clone" - title: "Cloning Interlex" + title: "Cloning interlex" type: "git-clone" repo: "metacell/interlex" revision: "${{CF_BRANCH}}" build: stage: "build" - title: "Building Interlex" + title: "Building interlex" type: "build" image_name: "interlex" - tag: "${{CF_BUILD_ID}}" + tag: "${{CF_SHORT_REVISION}}" dockerfile: Dockerfile working_directory: ./interlex buildkit: true @@ -25,14 +25,13 @@ steps: - VITE_SCICRUNCH_API_KEY=${{VITE_SCICRUNCH_API_KEY}} deploy: stage: "deploy" - title: "Deploying Interlex" - image: codefresh/kubectl + title: "Deploying interlex" + image: codefresh/cf-deploy-kubernetes + tag: latest working_directory: ./interlex/deploy/k8s commands: - - export CLUSTER_NAME="${{CLUSTER_NAME}}" - - export NAMESPACE="${{NAMESPACE}}" - - export CF_BUILD_ID - - export REGISTRY="${{REGISTRY}}/" - - export DOMAIN="${{DOMAIN}}" - - chmod +x ./deploy.sh - - ./deploy.sh + - /cf-deploy-kubernetes interlex.yaml + - /cf-deploy-kubernetes ingress.yaml + environment: + - KUBECONTEXT=${{CLUSTER_NAME}} + - KUBERNETES_NAMESPACE=${{NAMESPACE}} diff --git a/deploy/k8s/codefresh.yaml b/deploy/k8s/codefresh.yaml deleted file mode 100644 index 6b0208fa..00000000 --- a/deploy/k8s/codefresh.yaml +++ /dev/null @@ -1,37 +0,0 @@ -version: "1.0" -stages: - - "clone" - - "build" - - "deploy" -steps: - clone: - stage: "clone" - title: "Cloning interlex" - type: "git-clone" - repo: "metacell/interlex" - revision: "${{CF_BRANCH}}" - build: - stage: "build" - title: "Building interlex" - type: "build" - image_name: "interlex" - tag: "${{CF_SHORT_REVISION}}" - dockerfile: Dockerfile - working_directory: ./interlex - buildkit: true - registry: "${{CODEFRESH_REGISTRY}}" - build_arguments: - - VITE_API_URL=${{VITE_API_URL}} - - VITE_SCICRUNCH_API_KEY=${{VITE_SCICRUNCH_API_KEY}} - deploy: - stage: "deploy" - title: "Deploying interlex" - image: codefresh/cf-deploy-kubernetes - tag: latest - working_directory: ./interlex/deploy/k8s - commands: - - /cf-deploy-kubernetes interlex.yaml - - /cf-deploy-kubernetes ingress.yaml - environment: - - KUBECONTEXT=${{CLUSTER_NAME}} - - KUBERNETES_NAMESPACE=${{NAMESPACE}} diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index b41ac363..1155e7f3 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -151,7 +151,7 @@ const fetchData = async (url, method = "GET", data: object | null = null) => { }; export const elasticSearch = async (query) => { - const url = API_CONFIG.BASE_SCICRUNCH_URL + import.meta.env.VITE_SCICRUNCH_ELASTIC_KEY; + const url = API_CONFIG.BASE_SCICRUNCH_URL + API_CONFIG.SCICRUNCH_KEY; try { const result = await fetchData(url, "POST", { query: { diff --git a/src/components/Header/Search.jsx b/src/components/Header/Search.jsx index 86823666..5f6cec88 100644 --- a/src/components/Header/Search.jsx +++ b/src/components/Header/Search.jsx @@ -134,9 +134,9 @@ const Search = () => { const fetchTerms = useCallback(debounce(async (searchTerm) => { const data = await elasticSearch(searchTerm); - const dataTerms = data?.results.filter(result => result.type === SEARCH_TYPES.TERM); - const dataOrganizations = data?.results.filter(result => result.type === SEARCH_TYPES.ORGANIZATION); - const dataOntologies = data?.results.filter(result => result.type === SEARCH_TYPES.ONTOLOGY); + const dataTerms = data?.results?.filter(result => result.type === SEARCH_TYPES.TERM); + const dataOrganizations = data?.results?.filter(result => result.type === SEARCH_TYPES.ORGANIZATION); + const dataOntologies = data?.results?.filter(result => result.type === SEARCH_TYPES.ONTOLOGY); setTerms(dataTerms); setOrganizations(dataOrganizations); setOntologies(dataOntologies); @@ -356,4 +356,4 @@ const Search = () => { ); }; -export default Search; \ No newline at end of file +export default Search; diff --git a/src/config.js b/src/config.js index 1997d73d..963c8c10 100644 --- a/src/config.js +++ b/src/config.js @@ -26,4 +26,5 @@ export const API_CONFIG = { }, OLYMPIAN_GODS : "https://uri.olympiangods.org", BASE_SCICRUNCH_URL: "/api/elasticsearch?key=", -}; \ No newline at end of file + SCICRUNCH_KEY: import.meta.env.VITE_SCICRUNCH_API_KEY, +};