Changes to make deployment path configureable with prefix by ENV

This commit is contained in:
Tobias Stein 2019-06-24 11:00:44 +02:00
parent 1c3f34aa6e
commit f26fe29012
6 changed files with 20 additions and 7 deletions

View file

@ -94,6 +94,8 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& apt-get update \
&& apt-get install -y yarn
ENV PREFIX_PATH = "APP"
# build frontend
COPY web /src/web
RUN cd /src/web \

View file

@ -13,11 +13,11 @@ server {
root /usr/local/lib/web/frontend/;
index index.html index.htm;
location ~ ^/api {
location ~ ^/APP/api {
try_files $uri @api;
}
location = /websockify {
location = /APP/websockify {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

View file

@ -114,6 +114,9 @@ def main():
)
logging.getLogger("werkzeug").setLevel(logging.WARNING)
log = logging.getLogger('novnc2')
app.config["APPLICATION_ROOT"] = os.getenv("PREFIX_PATH")
entrypoint()

View file

@ -5,6 +5,11 @@
const path = require('path')
const BACKEND = process.env.BACKEND || 'http://127.0.0.1:6080'
const PREFIX_PATH = process.env.PREFIX_PATH
const api_key = `${PREFIX_PATH}/api`
const websockify_key = `${PREFIX_PATH}/websockfiy`
module.exports = {
dev: {
@ -12,12 +17,12 @@ module.exports = {
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
[api_key]: {
target: BACKEND,
changeOrigin: true,
secure: false
},
'/websockify': {
[websockify_key]: {
target: BACKEND,
// logLevel: 'debug',
ws: true,

View file

@ -56,7 +56,7 @@ export default {
'h': h
}
try {
const response = await this.$http.get('api/state', {params: params})
const response = await this.$http.get(process.env.PREFIX_PATH + '/api/state', {params: params})
const body = response.data
if (body.code !== 200) {
this.stateErrorCount += 1
@ -71,7 +71,7 @@ export default {
// adaptive resolution
if (!body.data.config.fixedResolution && body.data.config.sizeChangedCount === 0) {
const response = await this.$http.get('api/reset', {params: params})
const response = await this.$http.get(process.env.PREFIX_PATH + '/api/reset', {params: params})
const body = response.data
if (body.code !== 200) {
this.stateErrorCount += 1
@ -136,6 +136,7 @@ export default {
// console.trace()
console.log(`connecting...`)
this.errorMessage = ''
let websockifyPath = process.env.PREFIX_PATH + '/websockify'
if (force || this.vncState === 'stopped') {
this.vncState = 'connecting'
let hostname = window.location.hostname
@ -146,7 +147,7 @@ export default {
let url = 'static/vnc.html?'
url += 'autoconnect=1&'
url += `host=${hostname}&port=${port}&`
url += `path=websockify&title=novnc2&`
url += `path=${websockifyPath}&title=novnc2&`
url += `logging=warn`
this.$refs.vncFrame.setAttribute('src', url)
}

View file

@ -5,6 +5,8 @@ import Vnc from '@/components/Vnc'
Vue.use(Router)
export default new Router({
mode: 'history',
base: process.env.PREFIX_PATH,
routes: [
{
path: '/',