Skip to content

Commit 57f3596

Browse files
authored
Merge pull request #165 from mcode/dev
Dev
2 parents 32cd3c7 + c901b0e commit 57f3596

18 files changed

Lines changed: 168 additions & 58 deletions

.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ USE_HTTPS = false
1111
VSAC_API_KEY = changeMe
1212
WHITELIST = http://localhost, http://localhost:3005
1313
SERVER_NAME = CodeX REMS Administrator Prototype
14+
FULL_RESOURCE_IN_APP_CONTEXT = false
15+
16+
#Frontend Vars
17+
FRONTEND_PORT=9090
18+
VITE_REALM = ClientFhirServer
19+
VITE_AUTH = http://localhost:8180
20+
VITE_CLIENT = app-login
21+
VITE_SCOPE_ID = rems-admin

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ WORKDIR /rems-admin
44
ARG PORT=8090
55
ENV PORT=${PORT}
66

7+
ARG FRONTEND_PORT=9090
8+
ENV FRONTEND_PORT=${FRONTEND_PORT}
9+
710
COPY --chown=node:node . .
811
RUN npm install
9-
EXPOSE 8090
1012

11-
HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT} || exit 1
13+
WORKDIR /rems-admin/frontend
14+
RUN npm install
15+
16+
WORKDIR /rems-admin
17+
18+
EXPOSE 8090
1219
EXPOSE 8095
13-
CMD npm run start
20+
EXPOSE 9090
21+
EXPOSE 9095
22+
23+
HEALTHCHECK --interval=45s --start-period=60s --timeout=10m --retries=10 CMD (wget --no-verbose --tries=1 --spider http://localhost:${PORT} && wget --no-verbose --tries=1 --spider http://localhost:${FRONTEND_PORT}) || exit 1
24+
CMD ./dockerRunnerProd.sh

Dockerfile.dev

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,31 @@ WORKDIR /rems-admin
44
ARG PORT=8090
55
ENV PORT=${PORT}
66

7+
ARG FRONTEND_PORT=9090
8+
ENV FRONTEND_PORT=${FRONTEND_PORT}
9+
710
COPY --chown=node:node . .
811
RUN npm install
12+
13+
WORKDIR /rems-admin/frontend
14+
RUN npm install
15+
16+
WORKDIR /rems-admin
17+
18+
919
EXPOSE 8090
1020
EXPOSE 8091
1121

12-
HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT} || exit 1
13-
1422
EXPOSE 8095
1523
EXPOSE 8096
24+
25+
EXPOSE 9090
26+
EXPOSE 9091
27+
28+
EXPOSE 9095
29+
EXPOSE 9096
30+
31+
HEALTHCHECK --interval=45s --start-period=60s --timeout=10m --retries=10 CMD (wget --no-verbose --tries=1 --spider http://localhost:${PORT} && wget --no-verbose --tries=1 --spider http://localhost:${FRONTEND_PORT}) || exit 1
32+
33+
1634
CMD ./dockerRunnerDev.sh

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Next, start the frontend with the following:
4444

4545
### `npm start`
4646

47-
Go to the UI running on http://localhost:5173/ (or whichever port it was run on)
47+
Go to the UI running on http://localhost:9090/ (or whichever port it was run on)
4848

4949
Still need to update docker to start the UI automatically.
5050

@@ -117,3 +117,5 @@ Following are a list of modifiable paths:
117117
| VSAC_API_KEY | `changeMe` | Replace with VSAC API key for pulling down ValueSets. Request an API Key from the [VSAC website](https://vsac.nlm.nih.gov/) |
118118
| WHITELIST | `http://localhost, http://localhost:3005` | List of valid URLs for CORS. Should include any URLs the server accesses for resources. |
119119
| SERVER_NAME | `CodeX REMS Administrator Prototype` | Name of the server that is returned in the card source. |
120+
| FULL_RESOURCE_IN_APP_CONTEXT | 'false' | If true, the entire order resource will be included in the appContext, otherwise only a reference will be. |
121+
| FRONTEND_PORT | `9080` | Port that the frontend server should run on, change if there are conflicts with port usage. |

dockerRunnerDev.sh

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,71 @@
11
#!/bin/sh
22

33
# Handle closing application on signal interrupt (ctrl + c)
4-
trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID; gradle --stop; exit' INT
4+
trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID $BACKEND_SERVER_PID; exit' INT
55

66
mkdir logs
7+
touch ./logs/frontend_installer.log
8+
touch ./logs/frontend_runner.log
9+
touch ./logs/backend_installer.log
10+
touch ./logs/backend_runner.log
11+
712
# Reset log file content for new application boot
8-
echo "*** Logs for continuous installer ***" > ./logs/installer.log
9-
echo "*** Logs for 'npm run start' ***" > ./logs/runner.log
13+
echo "*** Logs for continuous frontend installer ***" > ./logs/frontend_installer.log
14+
echo "*** Logs for frontend 'npm run start' ***" > ./logs/frontend_runner.log
15+
16+
echo "*** Logs for continuous backend installer ***" > ./logs/backend_installer.log
17+
echo "*** Logs for backend 'npm run start' ***" > ./logs/backend_runner.log
1018

1119
# Print that the application is starting in watch mode
1220
echo "starting application in watch mode..."
1321

1422
# Start the continious build listener process
15-
echo "starting continuous installer..."
16-
npm install
23+
echo "starting continuous installers..."
24+
25+
cd frontend
26+
npm install | tee ./logs/frontend_installer.log
27+
cd ..
28+
npm install | tee ./logs/backend_installer.log
1729

18-
( package_modify_time=$(stat -c %Y package.json)
19-
package_lock_modify_time=$(stat -c %Y package-lock.json)
30+
( package_modify_time=$(stat -c %Y frontend/package.json)
31+
package_lock_modify_time=$(stat -c %Y frontend/package-lock.json)
32+
backend_modify_time=$(stat -c %Y package.json)
33+
backend_lock_modify_time=$(stat -c %Y package-lock.json)
2034
while sleep 1
2135
do
22-
new_package_modify_time=$(stat -c %Y package.json)
23-
new_package_lock_modify_time=$(stat -c %Y package-lock.json)
36+
new_package_modify_time=$(stat -c %Y frontend/package.json)
37+
new_package_lock_modify_time=$(stat -c %Y frontend/package-lock.json)
38+
new_backend_modify_time=$(stat -c %Y package.json)
39+
new_backend_lock_modify_time=$(stat -c %Y package-lock.json)
2440

25-
if [[ "$package_modify_time" != "$new_package_modify_time" ]] || [[ "$package_lock_modify_time" != "$new_package_lock_modify_time" ]]
41+
if [[ "$package_modify_time" != "$new_package_modify_time" ]] || [[ "$package_lock_modify_time" != "$new_package_lock_modify_time" ]] || [[ "$backend_lock_modify_time" != "$new_backend_lock_modify_time" ]]|| [[ "$backend_modify_time" != "$new_backend_modify_time" ]]
2642
then
27-
echo "running npm install..."
28-
npm install | tee ./logs/installer.log
43+
echo "running frontent npm install..."
44+
cd frontend
45+
npm install | tee ./logs/frontend_installer.log
46+
cd ..
47+
elif [[ "$backend_lock_modify_time" != "$new_backend_lock_modify_time" ]]|| [[ "$backend_modify_time" != "$new_backend_modify_time" ]]
48+
then
49+
echo "running backend npm install..."
50+
npm install | tee ./logs/backend_installer.log
2951
fi
3052

3153
package_modify_time=$new_package_modify_time
3254
package_lock_modify_time=$new_package_lock_modify_time
55+
backend_modify_time=$new_backend_modify_time
56+
backend_lock_modify_time=$new_backend_lock_modify_time
3357

3458
done ) & CONTINUOUS_INSTALL_PID=$!
3559

3660
# Start server process once initial build finishes
37-
( npm run start | tee ./logs/runner.log ) & SERVER_PID=$!
61+
cd frontend
62+
( npm run start | tee ./logs/frontend_runner.log ) & SERVER_PID=$!
63+
64+
cd ..
65+
( npm run start | tee ./logs/backend_runner.log ) & BACKEND_SERVER_PID=$!
3866

3967
# Handle application background process exiting
40-
wait $CONTINUOUS_INSTALL_PID $SERVER_PID
68+
wait $CONTINUOUS_INSTALL_PID $SERVER_PID $BACKEND_SERVER_PID
4169
EXIT_CODE=$?
4270
echo "application exited with exit code $EXIT_CODE..."
4371

44-

dockerRunnerProd.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
cd frontend
4+
( npm run start ) & SERVER_PID=$!
5+
6+
cd ..
7+
( npm run start ) & BACKEND_SERVER_PID=$!
8+
9+
# Handle application background process exiting
10+
wait $SERVER_PID $BACKEND_SERVER_PID
11+
EXIT_CODE=$?
12+
echo "application exited with exit code $EXIT_CODE..."

frontend/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@mui/icons-material": "^6.1.0",
1616
"@mui/material": "^6.1.0",
1717
"axios": "^1.7.7",
18+
"dotenv": "^16.4.5",
1819
"react": "^18.3.1",
1920
"react-dom": "^18.3.1",
2021
"react-router-dom": "^6.26.2"

frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function App() {
2929
const resetDB = async () => {
3030
setOpen(false);
3131
await axios
32-
.post('http://localhost:8090/etasu/reset')
32+
.post(process.env.RESOURCE_SERVER + '/etasu/reset')
3333
.then(function (response: any) {
3434
console.log(response);
3535
setForceRefresh(true);

frontend/src/views/DataViews/CaseCollection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const CaseCollection = (props: { refresh: boolean }) => {
5656
}, []);
5757

5858
const getAllRemsCase = async () => {
59-
const url = 'http://localhost:8090/api/all/remscase';
59+
const url = process.env.RESOURCE_SERVER + '/api/all/remscase';
6060
await axios
6161
.get(url)
6262
.then(function (response: { data: SetStateAction<RemsCase[]> }) {
@@ -70,7 +70,7 @@ const CaseCollection = (props: { refresh: boolean }) => {
7070
};
7171

7272
const deleteSingleRow = async (event: any, row: RemsCase) => {
73-
const url = 'http://localhost:8090/api/remsCase/deleteOne';
73+
const url = process.env.RESOURCE_SERVER + '/api/remsCase/deleteOne';
7474
await axios
7575
.post(url, { data: { params: row } })
7676
.then(function (response: { data: any; status: number }) {

0 commit comments

Comments
 (0)