From 3c1aff96af5f431d0693e289ba4b182cd86bae06 Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Thu, 10 Aug 2023 14:12:01 +0200 Subject: [PATCH] new env config --- Dockerfile | 15 +++-- client/.gitignore | 1 + client/env.js | 2 + client/env.sh | 6 ++ client/index.html | 3 +- client/package.json | 2 +- .../src/components/layout/ContainerLayout.vue | 7 +- .../src/components/views/GalleryViewPage.vue | 4 +- client/src/config/envConfig.ts | 15 +++++ client/src/plugins/index.ts | 11 +-- .../src/services/api-services/apiService.ts | 67 ++++++++++--------- .../api-services/authenticationService.ts | 5 +- .../src/services/api-services/groupService.ts | 4 -- .../services/api-services/sessionService.ts | 2 - env.sh | 4 ++ server/src/app.ts | 17 +++-- server/src/config/envConfig.ts | 23 +++++++ .../admin-proctor-group.controller.ts | 6 +- .../admin-proctor-session.controller.ts | 4 +- .../controllers/authorization.controller.ts | 4 +- .../services/admin-proctor-group.service.ts | 10 +-- .../services/admin-proctor-session.service.ts | 9 +-- server/src/services/authorization.service.ts | 13 ++-- 23 files changed, 149 insertions(+), 85 deletions(-) create mode 100644 client/env.js create mode 100755 client/env.sh create mode 100644 client/src/config/envConfig.ts create mode 100644 env.sh create mode 100644 server/src/config/envConfig.ts diff --git a/Dockerfile b/Dockerfile index 9a47784..c473d22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Stage 1: Build the Vue app FROM node:18 as client-builder -ENV VITE_SERVER_URL "http://localhost" -ENV VITE_SERVER_PORT "3000" +# ENV VITE_SERVER_URL "http://localhost" +# ENV VITE_SERVER_PORT "3000" WORKDIR /app/client COPY client/package*.json ./ RUN npm install @@ -16,7 +16,6 @@ RUN npm install COPY server/ . RUN npm run build - # Stage 3: Create the final image FROM node:20-alpine WORKDIR /app @@ -25,7 +24,15 @@ COPY --from=client-builder /app/client/dist ./server/dist/views COPY server/package*.json ./ RUN npm install --production +# Stage 4: Copy env-var bash script +COPY env.sh /app/env.sh +RUN chmod +x /app/env.sh + +RUN ls +RUN cd /app +RUN ls + EXPOSE 3000 # Start the server -CMD ["node", "./server/dist/app.js"] \ No newline at end of file +CMD ["/bin/sh", "-c", "./env.sh && node ./server/dist/app.js"] \ No newline at end of file diff --git a/client/.gitignore b/client/.gitignore index 942b6e7..f7ee63a 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -4,6 +4,7 @@ node_modules # local env files +.env .env.* .env.local .env.*.local diff --git a/client/env.js b/client/env.js new file mode 100644 index 0000000..9453c74 --- /dev/null +++ b/client/env.js @@ -0,0 +1,2 @@ +window.VITE_SERVER_URL = 'http://localhost'; +window.VITE_SERVER_PORT = '3000'; diff --git a/client/env.sh b/client/env.sh new file mode 100755 index 0000000..ba94176 --- /dev/null +++ b/client/env.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +. ./.env + +echo "window.VITE_SERVER_URL = '${VITE_SERVER_URL}';" > env.js +echo "window.VITE_SERVER_PORT = '${VITE_SERVER_PORT}';" >> env.js \ No newline at end of file diff --git a/client/index.html b/client/index.html index e448c23..7f64542 100644 --- a/client/index.html +++ b/client/index.html @@ -5,7 +5,8 @@ - Vuetify 3 + + SEB Screen Proctoring diff --git a/client/package.json b/client/package.json index b10732a..da31a1e 100644 --- a/client/package.json +++ b/client/package.json @@ -2,7 +2,7 @@ "name": "client", "version": "0.0.0", "scripts": { - "dev": "vite", + "dev": "./env.sh && vite", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", "lint": "eslint . --fix --ignore-path .gitignore" diff --git a/client/src/components/layout/ContainerLayout.vue b/client/src/components/layout/ContainerLayout.vue index e82e4b3..e9296c1 100644 --- a/client/src/components/layout/ContainerLayout.vue +++ b/client/src/components/layout/ContainerLayout.vue @@ -3,7 +3,7 @@ -
SEB Screen Proctoring
+
SEB Screen Proctoring
@@ -95,6 +95,11 @@