Commit 7b46d2a4 authored by Nick's avatar Nick

fix: use companion agent for docker upgrade

parent 8f7fdab7
......@@ -27,7 +27,7 @@
v-list-item-subtitle {{ info.latestVersion }}
v-list-item-action
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.
v-spacer
v-btn.px-3(
......
......@@ -60,7 +60,6 @@
"dependency-graph": "0.8.0",
"diff": "4.0.1",
"diff2html": "2.11.3",
"dockerode": "2.5.8",
"dotize": "0.3.0",
"elasticsearch6": "npm:@elastic/elasticsearch@6",
"elasticsearch7": "npm:@elastic/elasticsearch@7",
......
......@@ -7,7 +7,7 @@ const path = require('path')
const fs = require('fs-extra')
const moment = require('moment')
const graphHelper = require('../../helpers/graph')
const Docker = require('dockerode')
const request = require('request-promise')
/* global WIKI */
......@@ -70,21 +70,16 @@ module.exports = {
},
async performUpgrade (obj, args, context) {
try {
const dockerEngine = new Docker({ socketPath: '/var/run/docker.sock' })
await dockerEngine.run('containrrr/watchtower', ['--cleanup', '--run-once', 'wiki'], process.stdout, {
HostConfig: {
AutoRemove: true,
Mounts: [
{
Target: '/var/run/docker.sock',
Source: '/var/run/docker.sock',
Type: 'bind'
}
]
if (process.env.UPGRADE_COMPANION) {
await request({
method: 'POST',
uri: 'http://wiki-update-companion/upgrade'
})
return {
responseResult: graphHelper.generateSuccess('Upgrade has started.')
}
})
return {
responseResult: graphHelper.generateSuccess('Upgrade has started.')
} else {
throw new Error('You must run the wiki-update-companion container and pass the UPGRADE_COMPANION env var in order to use this feature.')
}
} catch (err) {
return graphHelper.generateError(err)
......@@ -169,7 +164,7 @@ module.exports = {
return WIKI.config.telemetry.clientId
},
async upgradeCapable () {
return fs.pathExists('/var/run/docker.sock')
return !_.isNil(process.env.UPGRADE_COMPANION)
},
workingDirectory () {
return process.cwd()
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment