Commit 7b46d2a4 authored by Nick's avatar Nick

fix: use companion agent for docker upgrade

parent 8f7fdab7
...@@ -27,7 +27,7 @@ ...@@ -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 @@ ...@@ -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') ...@@ -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,22 +70,17 @@ module.exports = { ...@@ -70,22 +70,17 @@ 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: [
{
Target: '/var/run/docker.sock',
Source: '/var/run/docker.sock',
Type: 'bind'
}
]
}
}) })
return { return {
responseResult: graphHelper.generateSuccess('Upgrade has started.') 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) { } catch (err) {
return graphHelper.generateError(err) return graphHelper.generateError(err)
} }
...@@ -169,7 +164,7 @@ module.exports = { ...@@ -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()
......
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