From 03784223a0fda19ba834500d702016bad8f10a4e Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Tue, 16 Apr 2024 17:44:26 +0200 Subject: [PATCH 01/11] initial commit for the route changes --- 40-create-ghcred.sh | 21 +++++++++++++++++---- Dockerfile | 8 +++----- ngnix.conf | 4 ++-- src/components/OsdComponent.vue | 15 ++++++++++++++- src/store/index.js | 21 +++++++++++---------- vue.config.js | 5 ++--- 6 files changed, 49 insertions(+), 25 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index f045e4d..c5bad6e 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -1,8 +1,21 @@ -#/bin/sh -# create nginx config from evironment +#!/bin/sh + +# Set default value for VUE_APP_PUBLIC_PATH if not provided +# Get VUE_APP_PUBLIC_PATH from Docker endpoint +#VUE_APP_PUBLIC_PATH=$(cat /proc/1/environ | grep VUE_APP_PUBLIC_PATH | cut -d '=' -f2) + +# Copy files with the specified public path +#cp -r /usr/app/dist /usr/share/nginx/html/$VUE_APP_PUBLIC_PATH +echo $VUE_APP_PUBLIC_PATH +ln -s /usr/share/nginx/html /usr/share/nginx/html$VUE_APP_PUBLIC_PATH +#sed -e "//js/++mylocation/js" +sed -i "s+/js+$VUE_APP_PUBLIC_PATH/js+g" /usr/share/nginx/html/index.html +sed -i "s+/css+$VUE_APP_PUBLIC_PATH/css+g" /usr/share/nginx/html/index.html + +# Create nginx config from environment variables # *prevent envsubst from killing nginx vars with 'tr' and '@'* cat </GH_OAUTH_CLIENT.conf set @CLIENT_ID $CLIENT_ID; set @CLIENT_SECRET $CLIENT_SECRET; -set @CALL_BACK $CALL_BACK -EOT \ No newline at end of file +set @CALL_BACK $CALL_BACK; +EOT diff --git a/Dockerfile b/Dockerfile index a61c085..e98bf3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM node:latest as builder -ARG VUE_APP_PUBLIC_PATH="" -ENV VUE_APP_PUBLIC_PATH=$VUE_APP_PUBLIC_PATH + WORKDIR /usr/app COPY . . # RUN echo "VUE_APP_CLIENT_ID=$CLIENT_ID" >.env.development.local @@ -10,9 +9,8 @@ RUN npm install --legacy-peer-deps --force && npm run build FROM nginx:alpine -ARG VUE_APP_PUBLIC_PATH="" -ENV VUE_APP_PUBLIC_PATH=$VUE_APP_PUBLIC_PATH +ENV VUE_APP_PUBLIC_PATH="/" WORKDIR /etc/nginx COPY 40-create-ghcred.sh /docker-entrypoint.d COPY ngnix.conf /etc/nginx/nginx.d/default.conf -COPY --from=builder /usr/app/dist/ /usr/share/nginx/html/${VUE_APP_PUBLIC_PATH} \ No newline at end of file +COPY --from=builder /usr/app/dist/ /usr/share/nginx/html diff --git a/ngnix.conf b/ngnix.conf index 71ee049..689eff5 100644 --- a/ngnix.conf +++ b/ngnix.conf @@ -5,6 +5,7 @@ server { set $token ""; # if the request has args update token to "&" # request without args doesn't make sense in this case + if ($is_args) { set $token "&"; } @@ -18,7 +19,7 @@ server { proxy_set_header accept "application/json"; } - # Serve Vue.js application from VUE_APP_PUBLIC_PATH + # Serve Vue.js application from VUE_APP_PUBLIC_PATH # default rule to access app location / { @@ -31,4 +32,3 @@ server { return 301 $1; } } -s \ No newline at end of file diff --git a/src/components/OsdComponent.vue b/src/components/OsdComponent.vue index 2953902..bf92ea2 100644 --- a/src/components/OsdComponent.vue +++ b/src/components/OsdComponent.vue @@ -182,11 +182,20 @@ export default { // The users has selected an existing annotation // console.log('selected annotation') // console.log(annotation) - console.log("anno is clicked") + console.log("anno is clicked " , annotation) }) this.anno.on('createAnnotation', (annotation) => { + + + // const { x, y, width, height } = annotation.shapes[0].geometry; + + // Update the x and y coordinates of the rectangle + // const newX = x + width; // Example: Move the rectangle to the right of the selected area + // const newY = y + height; // Example: Move the rectangle below the selected area + console.log("this is x ", annotation) + // console.log("this is y " + newX) // The users has created a new annotation const newId = 'z' + uuid() annotation.id = newId @@ -194,6 +203,10 @@ export default { this.$store.dispatch('selectZone', null) this.anno.clearAnnotations() this.renderZones() + console.log("anno is clicked ", annotation.target.selector) + + + }) this.anno.on('updateAnnotation', (annotation) => { diff --git a/src/store/index.js b/src/store/index.js index a1415fa..5df9393 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1096,16 +1096,17 @@ export default createStore({ }, pages: state => { const arr = [] - state.pages.forEach(page => { - const obj = { - tileSource: page.uri, - width: page.width, - x: 0, - y: 0 - } - arr.push(obj) - }) - return arr + state.pages.forEach(page => { + const obj = { + tileSource: page.uri, + width: page.width * 0.9, // Doubling the width + height: page.height * 0.9, // Doubling the height + x: 0, + y: 0 + } + arr.push(obj) + }) + return arr }, pagesDetailed: state => { const arr = [] diff --git a/vue.config.js b/vue.config.js index 6f2dcd9..1f67736 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,6 +1,5 @@ module.exports = { - publicPath: process.env.NODE_ENV === 'production' - ? process.env.VUE_APP_PUBLIC_PATH - : '/' + publicPath: + process.env.VUE_APP_PUBLIC_PATH } \ No newline at end of file From 2170e5c9fb3ba7ecea0aae5dcb47b4d84d2965b2 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Tue, 16 Apr 2024 18:42:57 +0200 Subject: [PATCH 02/11] overwrite publicPath with an entrypoint script --- 40-create-ghcred.sh | 4 ++-- Dockerfile | 2 +- ngnix.conf | 21 +-------------------- src/public-path.js | 2 +- vue.config.js | 5 ++--- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index c5bad6e..70885a8 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -9,8 +9,8 @@ echo $VUE_APP_PUBLIC_PATH ln -s /usr/share/nginx/html /usr/share/nginx/html$VUE_APP_PUBLIC_PATH #sed -e "//js/++mylocation/js" -sed -i "s+/js+$VUE_APP_PUBLIC_PATH/js+g" /usr/share/nginx/html/index.html -sed -i "s+/css+$VUE_APP_PUBLIC_PATH/css+g" /usr/share/nginx/html/index.html +sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html +sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js # Create nginx config from environment variables # *prevent envsubst from killing nginx vars with 'tr' and '@'* diff --git a/Dockerfile b/Dockerfile index e98bf3c..304b56d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ FROM nginx:alpine ENV VUE_APP_PUBLIC_PATH="/" WORKDIR /etc/nginx COPY 40-create-ghcred.sh /docker-entrypoint.d -COPY ngnix.conf /etc/nginx/nginx.d/default.conf +COPY ngnix.conf /etc/nginx/conf.d/default.conf COPY --from=builder /usr/app/dist/ /usr/share/nginx/html diff --git a/ngnix.conf b/ngnix.conf index 689eff5..d625282 100644 --- a/ngnix.conf +++ b/ngnix.conf @@ -1,23 +1,6 @@ server { listen 80; - # declare token is "" (empty str) for original request without args,because $is_args concat any var will be `?` - set $token ""; - # if the request has args update token to "&" - # request without args doesn't make sense in this case - - if ($is_args) { - set $token "&"; - } - # file created on container start from env vars (40-create-ghcred.sh) - include "/GH_OAUTH_CLIENT.conf"; - # reverse proxy to github access_token - # set rule to /auth explicitly - location = /auth { - set $args "${args}${token}client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}"; - proxy_pass https://github.com/login/oauth/access_token$is_args$args; - proxy_set_header accept "application/json"; - } # Serve Vue.js application from VUE_APP_PUBLIC_PATH @@ -28,7 +11,5 @@ server { try_files $uri $uri/ /index.html; } # Redirect requests without trailing slash to include it - location ~ ^(.*)/$ { - return 301 $1; - } + } diff --git a/src/public-path.js b/src/public-path.js index dad6f00..f2cf9c2 100644 --- a/src/public-path.js +++ b/src/public-path.js @@ -1,3 +1,3 @@ /* global __webpack_public_path__:writable */ /* exported __webpack_public_path__ */ -__webpack_public_path__ = window.PUBLIC_PATH,process.env.PUBLIC_PATH; \ No newline at end of file +//__webpack_public_path__ = '/myapp'; diff --git a/vue.config.js b/vue.config.js index 1f67736..bbcbb2c 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,4 @@ module.exports = { - publicPath: - process.env.VUE_APP_PUBLIC_PATH - } \ No newline at end of file + publicPath: "/myAppPlaceholder" + } From 680f8bd96dcf65ac25ad1cd86e42e7607fcf2ba5 Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Wed, 8 May 2024 15:32:49 +0200 Subject: [PATCH 03/11] re assign the width and the height of facsimile --- src/store/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 5df9393..d6e61f7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1099,8 +1099,8 @@ export default createStore({ state.pages.forEach(page => { const obj = { tileSource: page.uri, - width: page.width * 0.9, // Doubling the width - height: page.height * 0.9, // Doubling the height + width: page.width, + height: page.height , x: 0, y: 0 } From 6b06470e14e3393445d0d14d9d22797e5d960027 Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Tue, 14 May 2024 15:08:43 +0200 Subject: [PATCH 04/11] add sub path option for deployment --- 40-create-ghcred.sh | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index 70885a8..0d6448c 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -6,16 +6,34 @@ # Copy files with the specified public path #cp -r /usr/app/dist /usr/share/nginx/html/$VUE_APP_PUBLIC_PATH +#!/bin/bash + +# Remove leading and trailing whitespace and slashes +# Remove leading and trailing whitespace and slashes + +VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | xargs | sed 's/^\///;s/\/$//') + + echo $VUE_APP_PUBLIC_PATH -ln -s /usr/share/nginx/html /usr/share/nginx/html$VUE_APP_PUBLIC_PATH -#sed -e "//js/++mylocation/js" + +# Add leading slash only if string is not empty +if [ "$VUE_APP_PUBLIC_PATH" != "/" ] && [ "$VUE_APP_PUBLIC_PATH" != "" ]; then + VUE_APP_PUBLIC_PATH=/$VUE_APP_PUBLIC_PATH +fi +echo $VUE_APP_PUBLIC_PATH + + +ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH" sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js +# echo "no path" +# sed -i "s+myAppPlaceholder" "/" +# fi # Create nginx config from environment variables -# *prevent envsubst from killing nginx vars with 'tr' and '@'* -cat </GH_OAUTH_CLIENT.conf -set @CLIENT_ID $CLIENT_ID; -set @CLIENT_SECRET $CLIENT_SECRET; -set @CALL_BACK $CALL_BACK; -EOT +# # *prevent envsubst from killing nginx vars with 'tr' and '@'* +# cat </GH_OAUTH_CLIENT.conf +# set @CLIENT_ID $CLIENT_ID; +# set @CLIENT_SECRET $CLIENT_SECRET; +# set @CALL_BACK $CALL_BACK; +# EOT From 5b83fff4f169c9e1b14159bae3a6cef6ace62c19 Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Tue, 14 May 2024 15:13:25 +0200 Subject: [PATCH 05/11] remove duplicated comments from 40-create-ghcred.sh --- 40-create-ghcred.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index 0d6448c..daa9d6d 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -2,33 +2,25 @@ # Set default value for VUE_APP_PUBLIC_PATH if not provided # Get VUE_APP_PUBLIC_PATH from Docker endpoint -#VUE_APP_PUBLIC_PATH=$(cat /proc/1/environ | grep VUE_APP_PUBLIC_PATH | cut -d '=' -f2) # Copy files with the specified public path #cp -r /usr/app/dist /usr/share/nginx/html/$VUE_APP_PUBLIC_PATH -#!/bin/bash -# Remove leading and trailing whitespace and slashes # Remove leading and trailing whitespace and slashes VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | xargs | sed 's/^\///;s/\/$//') -echo $VUE_APP_PUBLIC_PATH # Add leading slash only if string is not empty if [ "$VUE_APP_PUBLIC_PATH" != "/" ] && [ "$VUE_APP_PUBLIC_PATH" != "" ]; then VUE_APP_PUBLIC_PATH=/$VUE_APP_PUBLIC_PATH fi -echo $VUE_APP_PUBLIC_PATH ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH" sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js -# echo "no path" -# sed -i "s+myAppPlaceholder" "/" -# fi # Create nginx config from environment variables # # *prevent envsubst from killing nginx vars with 'tr' and '@'* From 2e41245472649c4ae228590604a58ce5ae196b08 Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Wed, 15 May 2024 13:10:54 +0200 Subject: [PATCH 06/11] add route to Github --- 40-create-ghcred.sh | 14 +++++++------- src/components/OsdComponent.vue | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index daa9d6d..5e67b12 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -22,10 +22,10 @@ ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH" sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js -# Create nginx config from environment variables -# # *prevent envsubst from killing nginx vars with 'tr' and '@'* -# cat </GH_OAUTH_CLIENT.conf -# set @CLIENT_ID $CLIENT_ID; -# set @CLIENT_SECRET $CLIENT_SECRET; -# set @CALL_BACK $CALL_BACK; -# EOT +Create nginx config from environment variables +# *prevent envsubst from killing nginx vars with 'tr' and '@'* +cat </GH_OAUTH_CLIENT.conf +set @CLIENT_ID $CLIENT_ID; +set @CLIENT_SECRET $CLIENT_SECRET; +set @CALL_BACK $CALL_BACK; +EOT diff --git a/src/components/OsdComponent.vue b/src/components/OsdComponent.vue index bf92ea2..c6aca3f 100644 --- a/src/components/OsdComponent.vue +++ b/src/components/OsdComponent.vue @@ -182,7 +182,6 @@ export default { // The users has selected an existing annotation // console.log('selected annotation') // console.log(annotation) - console.log("anno is clicked " , annotation) }) From 745fed4e3c9ccd8c5bc0b3663aeb2627cc0c11df Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Wed, 15 May 2024 13:34:40 +0200 Subject: [PATCH 07/11] remove last line from 40-create-ghcred.sh --- 40-create-ghcred.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index 5e67b12..bf61eec 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#/bin/sh # Set default value for VUE_APP_PUBLIC_PATH if not provided # Get VUE_APP_PUBLIC_PATH from Docker endpoint @@ -22,10 +22,9 @@ ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH" sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js -Create nginx config from environment variables -# *prevent envsubst from killing nginx vars with 'tr' and '@'* +# create nginx config from evironment# *prevent envsubst from killing nginx vars with 'tr' and '@'* cat </GH_OAUTH_CLIENT.conf set @CLIENT_ID $CLIENT_ID; set @CLIENT_SECRET $CLIENT_SECRET; set @CALL_BACK $CALL_BACK; -EOT + From 21950b141122a8fcd962330bf0005617f0568626 Mon Sep 17 00:00:00 2001 From: Hizkiel Alemayehu <44091398+hizclick@users.noreply.github.com> Date: Thu, 16 May 2024 09:38:13 +0200 Subject: [PATCH 08/11] Update 40-create-ghcred.sh Co-authored-by: Peter Stadler --- 40-create-ghcred.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index bf61eec..2855496 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # Set default value for VUE_APP_PUBLIC_PATH if not provided # Get VUE_APP_PUBLIC_PATH from Docker endpoint From 4e0f1dc1131968e11a6241bd0e2237b45dd7da21 Mon Sep 17 00:00:00 2001 From: Hizkiel Alemayehu <44091398+hizclick@users.noreply.github.com> Date: Thu, 16 May 2024 09:38:36 +0200 Subject: [PATCH 09/11] Update 40-create-ghcred.sh Co-authored-by: Peter Stadler --- 40-create-ghcred.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index 2855496..5a9ed58 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -8,7 +8,7 @@ # Remove leading and trailing whitespace and slashes -VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | xargs | sed 's/^\///;s/\/$//') +VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | sed 's/^\s*\///;s/\/\s*$//') From 6bcda4031fb334d69732e262d4f91ba08a28c821 Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Thu, 16 May 2024 10:25:50 +0200 Subject: [PATCH 10/11] Revert irrelevant changes from src/store/index.js --- src/store/index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index d6e61f7..a1415fa 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1096,17 +1096,16 @@ export default createStore({ }, pages: state => { const arr = [] - state.pages.forEach(page => { - const obj = { - tileSource: page.uri, - width: page.width, - height: page.height , - x: 0, - y: 0 - } - arr.push(obj) - }) - return arr + state.pages.forEach(page => { + const obj = { + tileSource: page.uri, + width: page.width, + x: 0, + y: 0 + } + arr.push(obj) + }) + return arr }, pagesDetailed: state => { const arr = [] From 6102b72a51a6e02a01f27047676c202cc793d25d Mon Sep 17 00:00:00 2001 From: Hizkiel Date: Mon, 23 Sep 2024 16:33:16 +0200 Subject: [PATCH 11/11] Reconfiguring ngnix.conf --- 40-create-ghcred.sh | 26 ++++++++++--------------- ngnix.conf | 47 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/40-create-ghcred.sh b/40-create-ghcred.sh index 5a9ed58..777f719 100755 --- a/40-create-ghcred.sh +++ b/40-create-ghcred.sh @@ -1,30 +1,24 @@ #!/bin/sh # Set default value for VUE_APP_PUBLIC_PATH if not provided -# Get VUE_APP_PUBLIC_PATH from Docker endpoint - -# Copy files with the specified public path -#cp -r /usr/app/dist /usr/share/nginx/html/$VUE_APP_PUBLIC_PATH - -# Remove leading and trailing whitespace and slashes - +# Remove leading and trailing whitespace and slashes from VUE_APP_PUBLIC_PATH VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | sed 's/^\s*\///;s/\/\s*$//') - - # Add leading slash only if string is not empty if [ "$VUE_APP_PUBLIC_PATH" != "/" ] && [ "$VUE_APP_PUBLIC_PATH" != "" ]; then - VUE_APP_PUBLIC_PATH=/$VUE_APP_PUBLIC_PATH + VUE_APP_PUBLIC_PATH="/$VUE_APP_PUBLIC_PATH" fi - +# Link the Vue.js app to the public path ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH" sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js -# create nginx config from evironment# *prevent envsubst from killing nginx vars with 'tr' and '@'* +# Create NGINX configuration from environment variables +# The @ character is used to prevent envsubst from interpreting NGINX variables cat </GH_OAUTH_CLIENT.conf -set @CLIENT_ID $CLIENT_ID; -set @CLIENT_SECRET $CLIENT_SECRET; -set @CALL_BACK $CALL_BACK; - +# Handle CLIENT_ID, CLIENT_SECRET, and CALL_BACK - they can be empty +set @CLIENT_ID "${CLIENT_ID:-}"; +set @CLIENT_SECRET "${CLIENT_SECRET:-}"; +set @CALL_BACK "${CALL_BACK:-}"; +EOT diff --git a/ngnix.conf b/ngnix.conf index d625282..35902d4 100644 --- a/ngnix.conf +++ b/ngnix.conf @@ -1,15 +1,44 @@ server { listen 80; + # Load environment variables from a file created on container start (it might be empty) + include "/GH_OAUTH_CLIENT.conf"; # This file may be empty or missing values - # Serve Vue.js application from VUE_APP_PUBLIC_PATH - - # default rule to access app - location / { - root /usr/share/nginx/html; - index index.html; - try_files $uri $uri/ /index.html; - } - # Redirect requests without trailing slash to include it + # Default to empty strings if CLIENT_ID or CLIENT_SECRET are not set + set $client_id ""; + set $client_secret ""; + # Check if environment variables were set, otherwise default to empty + if ($CLIENT_ID) { + set $client_id "client_id=${CLIENT_ID}"; + } + if ($CLIENT_SECRET) { + set $client_secret "client_secret=${CLIENT_SECRET}"; + } + + # Reverse proxy to GitHub OAuth access token + location = /auth { + # Handle query arguments + set $token ""; + if ($is_args) { + set $token "&"; + } + + # Concatenate the query arguments with client_id and client_secret, if set + set $args "${args}${token}${client_id}&${client_secret}"; + + # Proxy request to GitHub OAuth access token endpoint + proxy_pass https://github.com/login/oauth/access_token$is_args$args; + proxy_set_header Accept "application/json"; + } + + # Serve Vue.js application and handle optional URL rewrites + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + + # Optional: Redirect requests that lack a trailing slash to add one + rewrite ^([^.]*[^/])$ $1/ permanent; + } }