Skip to content

Commit

Permalink
Merge branch 'develop' into feature/CDE-54
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiga115 committed Feb 29, 2024
2 parents edf4038 + 305de05 commit 30ea4e3
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ARG PARENT=ubuntu/nginx
ARG NODE_PARENT=node:18.12.1

FROM ${NODE_PARENT} as build
ARG VITE_API_KEY
ENV VITE_API_KEY=$VITE_API_KEY
ENV APP_DIR=/app

WORKDIR ${APP_DIR}
Expand All @@ -13,10 +15,16 @@ RUN npm install

# user node
ADD --chown=node:node . ${APP_DIR}
COPY replace_env_vars.sh /usr/local/bin/replace_env_vars.sh
RUN chmod +x /usr/local/bin/replace_env_vars.sh
RUN /usr/local/bin/replace_env_vars.sh
RUN npm run build

FROM ${PARENT}
ENV PORT=80

# Copy the custom NGINX configuration file
COPY default.conf /etc/nginx/sites-available/default

COPY --from=build /app/demo/* /var/www/html
EXPOSE ${PORT}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,17 @@ run
docker run --name cde-mapper -e TZ=UTC -p 8000:80 cde-mapper
```

## docker-compose

run
```bash
docker-compose up --build
```

stop:
```bash
docker-compose down
```

open the url http://localhost:8000/

15 changes: 15 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
listen 80;

location / {
root /var/www/html;
index index.html index.htm;
try_files $uri $uri/ =404;
}

location /api/ {
proxy_pass https://scicrunch.org;
proxy_set_header Host scicrunch.org;
proxy_pass_request_headers on;
}
}
11 changes: 9 additions & 2 deletions demo/integration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {init, mapElasticSearchHitsToOptions} from '../lib/main.tsx';
import {init, mapElasticSearchHitsToOptions} from './cde-mapper.js';
import {getQueryObject} from "./query.js";

export function mapAndInit(datasetMappingFile, additionalDatasetMappingsFiles, datasetFile) {
Expand Down Expand Up @@ -111,7 +111,14 @@ function getCollections() {

async function fetchElasticSearchData(queryString) {
const query = getQueryObject(queryString)
const response = await fetch('/api', {
const apiKey = import.meta.env.VITE_API_KEY;
const baseUrl = '/api/1/elastic/Interlex_pr/_search';

const queryParameters = new URLSearchParams({
key: apiKey,
}).toString();

const response = await fetch(`${baseUrl}?${queryParameters}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2.4"
services:
cde-demo:
build: .
ports:
- "8080:80"
3 changes: 3 additions & 0 deletions k8s/codefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ steps:
tag: "${{CF_SHORT_REVISION}}"
dockerfile: Dockerfile
registry: ${{REGISTRY}}
build_arguments:
- VITE_API_KEY=${{VITE_API_KEY}}
deploy-to-kubernetes:
image: codefresh/cf-deploy-kubernetes
tag: latest
Expand All @@ -31,3 +33,4 @@ steps:
environment:
- KUBECONTEXT=${{CLUSTER}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- VITE_API_KEY=${{VITE_API_KEY}}
2 changes: 1 addition & 1 deletion lib/components/common/HoveredOptionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Stack, Typography, Box} from '@mui/material';
import {vars} from '../../theme/variables';
import {Option} from "./CustomMappingDropdown.tsx";
import {Option} from "../../models.ts";

const {
gray400,
Expand Down
6 changes: 3 additions & 3 deletions lib/components/steps/mapping/MappingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const MappingTab = ({defaultCollection}: MappingProps) => {

const handleFiltering = () => {
// TODO: to implement
console.log("To be implemented " + visibleRows)
void visibleRows
setVisibleRows([])
}

Expand Down Expand Up @@ -214,13 +214,13 @@ const MappingTab = ({defaultCollection}: MappingProps) => {
);
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const getPairingSuggestions = (key: string) => {
void key
return []
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const hasPairingSuggestions = (key: string) => {
void key
return false
};

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"dotenv": "^16.4.5",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
Expand Down
6 changes: 6 additions & 0 deletions replace_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# replace_env_vars.sh

for var in $(printenv | grep VITE_ | awk -F= '{print $1}'); do
sed -i 's|import.meta.env.'$var'|"'$(printenv $var)'"|g' ./demo/*.js
done
4 changes: 0 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {resolve} from 'path'

import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import dotenv from 'dotenv';

dotenv.config();

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
Expand All @@ -31,7 +28,6 @@ export default defineConfig(({ mode }) => ({
'/api': {
target: 'https://scicrunch.org',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, `/api/1/elastic/Interlex_pr/_search?key=${process.env.VITE_API_KEY}`),
},
},
},
Expand Down

0 comments on commit 30ea4e3

Please sign in to comment.