Skip to content

Commit f26fe29

Browse files
author
Tobias Stein
committed
Changes to make deployment path configureable with prefix by ENV
1 parent 1c3f34a commit f26fe29

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
9494
&& apt-get update \
9595
&& apt-get install -y yarn
9696

97+
ENV PREFIX_PATH = "APP"
98+
9799
# build frontend
98100
COPY web /src/web
99101
RUN cd /src/web \

image/etc/nginx/sites-enabled/default

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ server {
1313
root /usr/local/lib/web/frontend/;
1414
index index.html index.htm;
1515

16-
location ~ ^/api {
16+
location ~ ^/APP/api {
1717
try_files $uri @api;
1818
}
1919

20-
location = /websockify {
20+
location = /APP/websockify {
2121
proxy_http_version 1.1;
2222
proxy_set_header Upgrade $http_upgrade;
2323
proxy_set_header Connection "upgrade";

image/usr/local/lib/web/backend/run.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def run_server():
114114
)
115115
logging.getLogger("werkzeug").setLevel(logging.WARNING)
116116
log = logging.getLogger('novnc2')
117+
118+
app.config["APPLICATION_ROOT"] = os.getenv("PREFIX_PATH")
119+
117120
entrypoint()
118121

119122

web/config/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55
const path = require('path')
66
const BACKEND = process.env.BACKEND || 'http://127.0.0.1:6080'
77

8+
const PREFIX_PATH = process.env.PREFIX_PATH
9+
10+
const api_key = `${PREFIX_PATH}/api`
11+
const websockify_key = `${PREFIX_PATH}/websockfiy`
12+
813
module.exports = {
914
dev: {
1015

1116
// Paths
1217
assetsSubDirectory: 'static',
1318
assetsPublicPath: '/',
1419
proxyTable: {
15-
'/api': {
20+
[api_key]: {
1621
target: BACKEND,
1722
changeOrigin: true,
1823
secure: false
1924
},
20-
'/websockify': {
25+
[websockify_key]: {
2126
target: BACKEND,
2227
// logLevel: 'debug',
2328
ws: true,

web/src/components/Vnc.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default {
5656
'h': h
5757
}
5858
try {
59-
const response = await this.$http.get('api/state', {params: params})
59+
const response = await this.$http.get(process.env.PREFIX_PATH + '/api/state', {params: params})
6060
const body = response.data
6161
if (body.code !== 200) {
6262
this.stateErrorCount += 1
@@ -71,7 +71,7 @@ export default {
7171
7272
// adaptive resolution
7373
if (!body.data.config.fixedResolution && body.data.config.sizeChangedCount === 0) {
74-
const response = await this.$http.get('api/reset', {params: params})
74+
const response = await this.$http.get(process.env.PREFIX_PATH + '/api/reset', {params: params})
7575
const body = response.data
7676
if (body.code !== 200) {
7777
this.stateErrorCount += 1
@@ -136,6 +136,7 @@ export default {
136136
// console.trace()
137137
console.log(`connecting...`)
138138
this.errorMessage = ''
139+
let websockifyPath = process.env.PREFIX_PATH + '/websockify'
139140
if (force || this.vncState === 'stopped') {
140141
this.vncState = 'connecting'
141142
let hostname = window.location.hostname
@@ -146,7 +147,7 @@ export default {
146147
let url = 'static/vnc.html?'
147148
url += 'autoconnect=1&'
148149
url += `host=${hostname}&port=${port}&`
149-
url += `path=websockify&title=novnc2&`
150+
url += `path=${websockifyPath}&title=novnc2&`
150151
url += `logging=warn`
151152
this.$refs.vncFrame.setAttribute('src', url)
152153
}

web/src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Vnc from '@/components/Vnc'
55
Vue.use(Router)
66

77
export default new Router({
8+
mode: 'history',
9+
base: process.env.PREFIX_PATH,
810
routes: [
911
{
1012
path: '/',

0 commit comments

Comments
 (0)