diff --git a/gui/.dockerignore b/gui/.dockerignore index 9414382..ae89e39 100644 --- a/gui/.dockerignore +++ b/gui/.dockerignore @@ -1 +1,6 @@ -Dockerfile +**/node_modules +**/dist +/gerrit +/licenses +.env* +!.env.docker diff --git a/gui/.env.development b/gui/.env.development deleted file mode 100644 index 8edc2f8..0000000 --- a/gui/.env.development +++ /dev/null @@ -1,3 +0,0 @@ -NODE_ENV=development -VITE_API_URL=http://localhost:3000 -VITE_API_URL=https://exz-nebulous-backend-staging-2003f98f736b.herokuapp.com diff --git a/gui/.env.docker b/gui/.env.docker new file mode 100644 index 0000000..6529b96 --- /dev/null +++ b/gui/.env.docker @@ -0,0 +1,2 @@ +VITE_API_URL=VITE_API_URL_PLACEHOLDER +CFSB_API_URL=CFSB_API_URL_PLACEHOLDER \ No newline at end of file diff --git a/gui/.gitignore b/gui/.gitignore index e0c3de1..6dc0973 100644 --- a/gui/.gitignore +++ b/gui/.gitignore @@ -6,7 +6,7 @@ yarn-debug.log* yarn-error.log* pnpm-debug.log* lerna-debug.log* - +/*.env.* node_modules dist dist-ssr @@ -24,4 +24,7 @@ dist-ssr # we are using pnpm-lock.yaml package-lock.json -yarn.lock \ No newline at end of file +yarn.lock +/gerrit + +!.env.docker diff --git a/gui/.nvmrc b/gui/.nvmrc new file mode 100644 index 0000000..67d2ffe --- /dev/null +++ b/gui/.nvmrc @@ -0,0 +1 @@ +v20.13.1 \ No newline at end of file diff --git a/gui/Dockerfile b/gui/Dockerfile index b0365c2..5dd7ece 100644 --- a/gui/Dockerfile +++ b/gui/Dockerfile @@ -1,4 +1,19 @@ -FROM docker.io/library/node:21.4.0-bookworm -COPY . /app +# Build the Vue app +FROM node:20 as build-stage WORKDIR /app -RUN corepack enable pnpm && pnpm install && npx vue-tsc +COPY package*.json ./ +COPY .env.docker ./.env + +RUN npm install +COPY ./ . +RUN npm run build + +# Copy the compiled app in an NGINX contaier +FROM nginx:alpine as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /usr/share/nginx/html + +# Executing the script at container runtime +COPY set_env.sh /docker-entrypoint.d/ +RUN chmod +x /docker-entrypoint.d/set_env.sh + diff --git a/gui/package.json b/gui/package.json index 14435b1..4ecec78 100644 --- a/gui/package.json +++ b/gui/package.json @@ -3,7 +3,7 @@ "private": true, "version": "0.0.0", "engines": { - "node": "v21.4.0" + "node": "v20.9.0" }, "scripts": { "serve": "vite", diff --git a/gui/set_env.sh b/gui/set_env.sh new file mode 100644 index 0000000..a36f127 --- /dev/null +++ b/gui/set_env.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +ROOT_DIR=/usr/share/nginx/html + +# Replace env vars in files served by NGINX +for file in $ROOT_DIR/assets/*.js* $ROOT_DIR/index.html; +do + echo "Setting VITE_API_URL_PLACEHOlDER environment variables ${VITE_API_URL}" + sed -i 's|VITE_API_URL_PLACEHOLDER|'${VITE_API_URL}'|g' $file + + echo "Setting CFSB_API_URL_PLACEHOLDER environment variables ${CFSB_API_URL}" + sed -i 's|CFSB_API_URL_PLACEHOLDER|'${CFSB_API_URL}'|g' $file + # Your other variables here... +done + + +exec "$@" \ No newline at end of file diff --git a/gui/src/components/Application/Details.vue b/gui/src/components/Application/Details.vue index d9fcd88..1d0e777 100644 --- a/gui/src/components/Application/Details.vue +++ b/gui/src/components/Application/Details.vue @@ -129,7 +129,7 @@ v-model="env.name" type="text" :class="{ - 'input--invalid': v.name?.$error || hasBackendError(`env[${index}].name`) + 'input--invalid': v.name?.$error || hasBackendError(`environmentVariables[${index}].name`) }" /> @@ -142,7 +142,7 @@ v-model="env.value" :type="env.secret ==true ? 'password' : 'text' " :class="{ - 'input--invalid': v.value?.$error || hasBackendError(`env[${index}].value`) + 'input--invalid': v.value?.$error || hasBackendError(`environmentVariables[${index}].value`) }" /> @@ -150,7 +150,11 @@