File tree Expand file tree Collapse file tree 12 files changed +131
-32
lines changed
aifindr-evaluations-runner
deployment/docker-compose Expand file tree Collapse file tree 12 files changed +131
-32
lines changed Original file line number Diff line number Diff line change 1+ AUTH_DOMAIN =
2+ AUTH_CLIENT_ID =
3+ AUTH_AUDIENCE =
4+ AIFINDR_DOMAIN = http://host.docker.internal:3000
5+ AUTH_ENABLED = false
6+ AUTH_IS_AUTH0 = false
7+ AUTH_API_KEY_RESOLUTION_CACHE_TTL_IN_SEC = 300
8+ EXPERIMENT_RUNNER_URL = http://aifindr-evaluations-runner:8001/evaluations/run
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # In order to use this file, you need to install direnv and run `direnv allow`
4+ # direnv will automatically load the environment variables from the .env file
5+ # and make them available to the shell.
6+
7+ # to install direnv: `brew install direnv`
8+
9+ dotenv
10+ set -a
11+ source_env .env
12+ set +a
Original file line number Diff line number Diff line change 1+ # environment variables
2+ .env
3+
14# Mac
25.DS_Store
36
Original file line number Diff line number Diff line change 22from functools import lru_cache
33
44from pydantic_settings import BaseSettings , SettingsConfigDict
5- from pydantic import field_validator
65
76
87class Settings (BaseSettings ):
@@ -12,12 +11,6 @@ class Settings(BaseSettings):
1211 ELLMENTAL_API_URL : str = ""
1312 ELLMENTAL_API_KEY : str = ""
1413
15- @field_validator ("*" )
16- def no_empty_strings (cls , v ):
17- if isinstance (v , str ) and not v :
18- raise ValueError ("Field cannot be empty" )
19- return v
20-
2114
2215class EnvSettings (BaseSettings ):
2316 settings : Settings = Settings ()
Original file line number Diff line number Diff line change @@ -11,17 +11,9 @@ RUN npm install
1111COPY . .
1212
1313ARG OPIK_VERSION
14- ARG AUTH_DOMAIN
15- ARG AUTH_CLIENT_ID
16- ARG AUTH_AUDIENCE
17- ARG AIFINDR_DOMAIN
1814
1915ENV VITE_APP_VERSION=${OPIK_VERSION}
20- ENV VITE_AUTH_DOMAIN=${AUTH_DOMAIN}
21- ENV VITE_AUTH_CLIENT_ID=${AUTH_CLIENT_ID}
22- ENV VITE_AUTH_AUDIENCE=${AUTH_AUDIENCE}
2316ENV VITE_PLUGINS_SCOPE=aifindr
24- ENV VITE_AIFINDR_DOMAIN=${AIFINDR_DOMAIN}
2517
2618ENV NODE_OPTIONS="--max-old-space-size=8192"
2719
@@ -34,9 +26,15 @@ FROM nginx:1.27.3-alpine3.20
3426# Copy the built files from the builder stage
3527COPY --from=builder /opt/frontend/dist /usr/share/nginx/html
3628
29+ COPY docker-entrypoint.sh /docker-entrypoint.sh
30+ RUN chmod +x /docker-entrypoint.sh
31+
32+ # Override the default nginx configuration
33+ COPY default.template.conf /etc/nginx/conf.d/default.template.conf
34+
3735RUN sed -i '/access_log.*main/d' /etc/nginx/nginx.conf
3836
3937EXPOSE 5173
4038
4139# Start Nginx
42- CMD ["nginx" , "-g" , "daemon off; " ]
40+ ENTRYPOINT ["/docker-entrypoint.sh " ]
Original file line number Diff line number Diff line change 1+ server {
2+ listen 5173;
3+ server_name localhost;
4+ root /usr/share/nginx/html;
5+ index index.html;
6+
7+ location /api/ {
8+ rewrite /api/(.*) /$1 break;
9+ proxy_pass ${BACKEND_URL};
10+ proxy_set_header Host $host;
11+ proxy_set_header X-Real-IP $remote_addr;
12+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+ proxy_set_header X-Forwarded-Proto $scheme;
14+
15+ proxy_read_timeout 90;
16+ proxy_connect_timeout 90;
17+ proxy_send_timeout 90;
18+
19+ proxy_http_version 1.1;
20+ client_max_body_size 500M;
21+ proxy_set_header Upgrade $http_upgrade;
22+ proxy_set_header Connection "upgrade";
23+ }
24+
25+ location / {
26+ try_files $uri $uri/ /index.html;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ APP_DIR=/usr/share/nginx/html
5+
6+ BACKEND_URL=${BACKEND_URL:- http:// localhost: 8080}
7+
8+ cat /etc/nginx/conf.d/default.template.conf | sed " s|\$ {BACKEND_URL}|${BACKEND_URL} |g" > /etc/nginx/conf.d/default.conf
9+
10+ rm -f /etc/nginx/conf.d/default.template.conf
11+
12+ # Generate configuration file with environment variables
13+ cat << EOF > ${APP_DIR} /config.js
14+ window.RUNTIME_CONFIG = {
15+ AUTH_DOMAIN: "${AUTH_DOMAIN:- } ",
16+ AUTH_CLIENT_ID: "${AUTH_CLIENT_ID:- } ",
17+ AUTH_AUDIENCE: "${AUTH_AUDIENCE:- } ",
18+ AIFINDR_DOMAIN: "${AIFINDR_DOMAIN:- } "
19+ };
20+ EOF
21+
22+ echo " Configuration generated"
23+
24+ # Iniciar Nginx
25+ exec nginx -g " daemon off;"
Original file line number Diff line number Diff line change 55 < link rel ="icon " type ="image/svg+xml " href ="/favicon.ico " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > Comet Opik</ title >
8+ < script src ="/config.js "> </ script >
89 </ head >
910 < body class ="size-full ">
1011 < div class ="size-full " id ="root "> </ div >
Original file line number Diff line number Diff line change @@ -16,15 +16,27 @@ const queryClient = new QueryClient({
1616 } ,
1717} ) ;
1818
19+ // Declaración para TypeScript
20+ declare global {
21+ interface Window {
22+ RUNTIME_CONFIG : {
23+ AUTH_DOMAIN : string ;
24+ AUTH_CLIENT_ID : string ;
25+ AUTH_AUDIENCE : string ;
26+ AIFINDR_DOMAIN : string ;
27+ } ;
28+ }
29+ }
30+
1931function App ( ) {
2032 useCustomScrollbarClass ( ) ;
2133
2234 const auth0Config = {
23- domain : import . meta. env . VITE_AUTH_DOMAIN || '' ,
24- clientId : import . meta. env . VITE_AUTH_CLIENT_ID || '' ,
35+ domain : window . RUNTIME_CONFIG ?. AUTH_DOMAIN || import . meta. env . VITE_AUTH_DOMAIN || '' ,
36+ clientId : window . RUNTIME_CONFIG ?. AUTH_CLIENT_ID || import . meta. env . VITE_AUTH_CLIENT_ID || '' ,
2537 authorizationParams : {
2638 redirect_uri : window . location . origin ,
27- audience : import . meta. env . VITE_AUTH_AUDIENCE ,
39+ audience : window . RUNTIME_CONFIG ?. AUTH_AUDIENCE || import . meta. env . VITE_AUTH_AUDIENCE ,
2840 } ,
2941 } ;
3042
Original file line number Diff line number Diff line change @@ -2,8 +2,16 @@ import { ACCESS_TOKEN_KEY } from "@/constants/user";
22import { UseQueryOptions } from "@tanstack/react-query" ;
33import axios from "axios" ;
44
5+ // Obtain the base URL from the runtime config
6+ const getBaseURL = ( ) => {
7+ if ( ! window . RUNTIME_CONFIG && ! import . meta. env . VITE_AIFINDR_DOMAIN ) {
8+ console . error ( 'AIFINDR_DOMAIN is not set neither in runtime nor in environment variables' ) ;
9+ }
10+ return window . RUNTIME_CONFIG ?. AIFINDR_DOMAIN || import . meta. env . VITE_AIFINDR_DOMAIN || '' ;
11+ } ;
12+
513const axiosInstance = axios . create ( {
6- baseURL : import . meta . env . VITE_AIFINDR_DOMAIN ,
14+ baseURL : getBaseURL ( ) ,
715} ) ;
816axiosInstance . interceptors . request . use ( ( config ) => {
917 const token = localStorage . getItem ( ACCESS_TOKEN_KEY ) ;
You can’t perform that action at this time.
0 commit comments