Skip to content

Commit

Permalink
Consolidate env variables
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com>
  • Loading branch information
ao508 committed Aug 28, 2024
1 parent d0306e1 commit a0ceb9b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ By default, `node-oracledb` runs in [Thin mode (vs. Thick mode)](https://node-or

The backend for the dashboard is under `./graphql-server`.

Set up your [./graphql-server/dist/env/application.properties.EXAMPLE](./graphql-server/dist/env/application.properties.EXAMPLE) with all of the application properties needed for running the dashboard backend.
Set up your [./graphql-server/src/env/application.properties.EXAMPLE](./graphql-server/src/env/application.properties.EXAMPLE) with all of the application properties needed for running the dashboard backend.

Build and launch the node app from the project root directory with:

Expand Down Expand Up @@ -119,33 +119,53 @@ services:
restart: unless-stopped
environment:
- SMILE_CONFIG_HOME=${SMILE_CONFIG_HOME}
- NODE_TLS_REJECT_UNAUTHORIZED=${NODE_TLS_REJECT_UNAUTHORIZED}
- LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
- REACT_SERVER_ORIGIN=${REACT_SERVER_ORIGIN}
- EXPRESS_SERVER_ORIGIN=${EXPRESS_SERVER_ORIGIN}
- SMILE_DATA_HOME=${SMILE_DATA_HOME}
volumes:
- type: bind
source: ${SMILE_CONFIG_HOME}/resources/smile-dashboard
target: /server/graphql-server/dist/env
- type: bind
source: ${SMILE_CONFIG_HOME}/nats
target: /server/nats
- type: bind
source: ${SMILE_DATA_HOME}/logs/smile-dashboard
target: ${SMILE_DATA_HOME}/logs/smile-dashboard
- type: bind
source: ${LD_LIBRARY_PATH}
target: ${LD_LIBRARY_PATH}
external_links:
- nats-jetstream
links:
- neo4j
depends_on:
neo4j:
condition: service_healthy
keycloak:
condition: service_started
ports:
- 4000:4000
healthcheck:
test: ["CMD", "curl", "-s", "https://localhost:4000"]
interval: 30s
timeout: 10s
retries: 5
test: ["CMD-SHELL", "wget --no-check-certificate --no-verbose --spider https://localhost:4000 || exit 1"]
interval: 30s
timeout: 10s
retries: 5
smile-dashboard:
container_name: smile-dashboard
image: cmometadb/smile-dashboard:[build version]
restart: unless-stopped
environment:
- REACT_APP_GRAPHQL_CLIENT_URI=${REACT_APP_GRAPHQL_CLIENT_URI}
- SMILE_CONFIG_HOME=${SMILE_CONFIG_HOME}
- REACT_APP_EXPRESS_SERVER_ORIGIN=${REACT_APP_EXPRESS_SERVER_ORIGIN}
- REACT_APP_REACT_SERVER_ORIGIN=${REACT_APP_REACT_SERVER_ORIGIN}
volumes:
- type: bind
source: ${SMILE_CONFIG_HOME}/resources/smile-dashboard
target: ${SMILE_CONFIG_HOME}/resources/smile-dashboard
links:
- graphql-client
ports:
Expand Down
4 changes: 2 additions & 2 deletions graphql-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express, { Express } from "express";
import { EXPRESS_SERVER_ORIGIN } from "./utils/constants";
import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "./utils/constants";
import { initializeApolloServer, initializeHttpsServer } from "./utils/servers";
import { configureApp } from "./middlewares/configureApp";
import { configureSession } from "./middlewares/configureSession";
Expand All @@ -22,7 +22,7 @@ async function main() {
);

console.log(
`🚀 Server ready at ${EXPRESS_SERVER_ORIGIN}${apolloServer.graphqlPath}`
`🚀 Server ready at ${REACT_APP_EXPRESS_SERVER_ORIGIN}${apolloServer.graphqlPath}`
);
}

Expand Down
4 changes: 2 additions & 2 deletions graphql-server/src/routes/auth/callback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REACT_SERVER_ORIGIN } from "../../utils/constants";
import { REACT_APP_REACT_SERVER_ORIGIN } from "../../utils/constants";
const passport = require("passport");

/**
Expand All @@ -8,7 +8,7 @@ const passport = require("passport");
*/
export function callbackRoute(req: any, res: any, next: any) {
passport.authenticate("oidc", {
successRedirect: `${REACT_SERVER_ORIGIN}/auth/login-success`,
successRedirect: `${REACT_APP_REACT_SERVER_ORIGIN}/auth/login-success`,
failureRedirect: "/",
})(req, res, next);
}
14 changes: 7 additions & 7 deletions graphql-server/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export const props = {
oncotree_api: properties.get("oncotree.oncotree_api"),
};

export const EXPRESS_SERVER_ORIGIN =
process.env.EXPRESS_SERVER_ORIGIN === undefined
export const REACT_APP_EXPRESS_SERVER_ORIGIN =
process.env.REACT_APP_EXPRESS_SERVER_ORIGIN === undefined
? "https://localhost:4000"
: process.env.EXPRESS_SERVER_ORIGIN;
: process.env.REACT_APP_EXPRESS_SERVER_ORIGIN;

export const REACT_SERVER_ORIGIN =
process.env.REACT_SERVER_ORIGIN === undefined
export const REACT_APP_REACT_SERVER_ORIGIN =
process.env.REACT_APP_REACT_SERVER_ORIGIN === undefined
? "https://localhost:3006"
: process.env.REACT_SERVER_ORIGIN;
: process.env.REACT_APP_REACT_SERVER_ORIGIN;

export const corsOptions = {
origin: REACT_SERVER_ORIGIN,
origin: REACT_APP_REACT_SERVER_ORIGIN,
credentials: true,
};
4 changes: 2 additions & 2 deletions graphql-server/src/utils/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Issuer } from "openid-client";
import { props } from "../utils/constants";
import { EXPRESS_SERVER_ORIGIN } from "./constants";
import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "./constants";
import { logOutRoute } from "../routes/auth/logout";

export async function getKeycloakClient() {
Expand All @@ -9,7 +9,7 @@ export async function getKeycloakClient() {
return new keycloakIssuer.Client({
client_id: props.keycloak_client_id,
client_secret: props.keycloak_client_secret,
redirect_uris: [`${EXPRESS_SERVER_ORIGIN}/auth/callback`],
redirect_uris: [`${REACT_APP_EXPRESS_SERVER_ORIGIN}/auth/callback`],
response_types: ["code"],
});
}
Expand Down

0 comments on commit a0ceb9b

Please sign in to comment.