Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
EXPOSE 80
28 changes: 15 additions & 13 deletions deploy/codefresh/codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@ 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
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/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}}
34 changes: 0 additions & 34 deletions deploy/k8s/codefresh.yaml

This file was deleted.

19 changes: 2 additions & 17 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 4 additions & 6 deletions src/api/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -134,7 +132,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,
Expand All @@ -153,7 +151,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 + API_CONFIG.SCICRUNCH_KEY;
try {
const result = await fetchData(url, "POST", {
query: {
Expand All @@ -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;
})
Expand Down Expand Up @@ -411,4 +409,4 @@ export const handleRecoverUser = async (email: string) => {
console.error("Recover user failed:", error);
throw error;
}
};
};
8 changes: 3 additions & 5 deletions src/components/Header/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ const Search = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
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);
Expand Down Expand Up @@ -360,8 +360,6 @@ const Search = () => {
);
};



Search.propTypes = {
open: PropTypes.bool,
handleClose: PropTypes.func,
Expand Down
3 changes: 2 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export const API_CONFIG = {
},
OLYMPIAN_GODS : "https://uri.olympiangods.org",
BASE_SCICRUNCH_URL: "/api/elasticsearch?key=",
};
SCICRUNCH_KEY: import.meta.env.VITE_SCICRUNCH_API_KEY,
};