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 update \
&& apt-get install -y yarn && apt-get install -y yarn
ENV PREFIX_PATH = "APP"
# build frontend # build frontend
COPY web /src/web COPY web /src/web
RUN cd /src/web \ RUN cd /src/web \

View file

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

View file

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

View file

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

View file

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

View file

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