fix: use companion agent for docker upgrade
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
v-list-item-subtitle {{ info.latestVersion }}
|
v-list-item-subtitle {{ info.latestVersion }}
|
||||||
v-list-item-action
|
v-list-item-action
|
||||||
v-list-item-action-text {{ $t('admin:system.published') }} {{ info.latestVersionReleaseDate | moment('from') }}
|
v-list-item-action-text {{ $t('admin:system.published') }} {{ info.latestVersionReleaseDate | moment('from') }}
|
||||||
v-card-actions(v-if='upgradeCapable && !isLatestVersion && info.platform === `docker`', :class='$vuetify.theme.dark ? `grey darken-3-d5` : `indigo lighten-5`')
|
v-card-actions(v-if='info.upgradeCapable && !isLatestVersion && info.platform === `docker`', :class='$vuetify.theme.dark ? `grey darken-3-d5` : `indigo lighten-5`')
|
||||||
.caption.indigo--text.pl-3(:class='$vuetify.theme.dark ? `text--lighten-4` : ``') Wiki.js can perform the upgrade to the latest version for you.
|
.caption.indigo--text.pl-3(:class='$vuetify.theme.dark ? `text--lighten-4` : ``') Wiki.js can perform the upgrade to the latest version for you.
|
||||||
v-spacer
|
v-spacer
|
||||||
v-btn.px-3(
|
v-btn.px-3(
|
||||||
|
|||||||
@@ -60,7 +60,6 @@
|
|||||||
"dependency-graph": "0.8.0",
|
"dependency-graph": "0.8.0",
|
||||||
"diff": "4.0.1",
|
"diff": "4.0.1",
|
||||||
"diff2html": "2.11.3",
|
"diff2html": "2.11.3",
|
||||||
"dockerode": "2.5.8",
|
|
||||||
"dotize": "0.3.0",
|
"dotize": "0.3.0",
|
||||||
"elasticsearch6": "npm:@elastic/elasticsearch@6",
|
"elasticsearch6": "npm:@elastic/elasticsearch@6",
|
||||||
"elasticsearch7": "npm:@elastic/elasticsearch@7",
|
"elasticsearch7": "npm:@elastic/elasticsearch@7",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const path = require('path')
|
|||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
const graphHelper = require('../../helpers/graph')
|
const graphHelper = require('../../helpers/graph')
|
||||||
const Docker = require('dockerode')
|
const request = require('request-promise')
|
||||||
|
|
||||||
/* global WIKI */
|
/* global WIKI */
|
||||||
|
|
||||||
@@ -70,21 +70,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
async performUpgrade (obj, args, context) {
|
async performUpgrade (obj, args, context) {
|
||||||
try {
|
try {
|
||||||
const dockerEngine = new Docker({ socketPath: '/var/run/docker.sock' })
|
if (process.env.UPGRADE_COMPANION) {
|
||||||
await dockerEngine.run('containrrr/watchtower', ['--cleanup', '--run-once', 'wiki'], process.stdout, {
|
await request({
|
||||||
HostConfig: {
|
method: 'POST',
|
||||||
AutoRemove: true,
|
uri: 'http://wiki-update-companion/upgrade'
|
||||||
Mounts: [
|
})
|
||||||
{
|
return {
|
||||||
Target: '/var/run/docker.sock',
|
responseResult: graphHelper.generateSuccess('Upgrade has started.')
|
||||||
Source: '/var/run/docker.sock',
|
|
||||||
Type: 'bind'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})
|
} else {
|
||||||
return {
|
throw new Error('You must run the wiki-update-companion container and pass the UPGRADE_COMPANION env var in order to use this feature.')
|
||||||
responseResult: graphHelper.generateSuccess('Upgrade has started.')
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return graphHelper.generateError(err)
|
return graphHelper.generateError(err)
|
||||||
@@ -169,7 +164,7 @@ module.exports = {
|
|||||||
return WIKI.config.telemetry.clientId
|
return WIKI.config.telemetry.clientId
|
||||||
},
|
},
|
||||||
async upgradeCapable () {
|
async upgradeCapable () {
|
||||||
return fs.pathExists('/var/run/docker.sock')
|
return !_.isNil(process.env.UPGRADE_COMPANION)
|
||||||
},
|
},
|
||||||
workingDirectory () {
|
workingDirectory () {
|
||||||
return process.cwd()
|
return process.cwd()
|
||||||
|
|||||||
Reference in New Issue
Block a user