Explicitly mount all apps into the sftp container
This commit is contained in:
+15
-5
@@ -580,6 +580,9 @@ function install(app, args, progressCallback, callback) {
|
||||
|
||||
startApp.bind(null, app),
|
||||
|
||||
progressCallback.bind(null, { percent: 80, message: 'Configuring file manager' }),
|
||||
sftp.rebuild.bind(null, {}),
|
||||
|
||||
progressCallback.bind(null, { percent: 85, message: 'Waiting for DNS propagation' }),
|
||||
exports._waitForDnsPropagation.bind(null, app),
|
||||
|
||||
@@ -781,6 +784,9 @@ function configure(app, args, progressCallback, callback) {
|
||||
|
||||
startApp.bind(null, app),
|
||||
|
||||
progressCallback.bind(null, { percent: 80, message: 'Configuring file manager' }),
|
||||
sftp.rebuild.bind(null, {}),
|
||||
|
||||
progressCallback.bind(null, { percent: 90, message: 'Configuring reverse proxy' }),
|
||||
configureReverseProxy.bind(null, app),
|
||||
|
||||
@@ -791,7 +797,8 @@ function configure(app, args, progressCallback, callback) {
|
||||
debugApp(app, 'error reconfiguring : %s', error);
|
||||
return updateApp(app, { installationState: apps.ISTATE_ERROR, error: makeTaskError(error, app) }, callback.bind(null, error));
|
||||
}
|
||||
callback(null);
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -874,14 +881,17 @@ function update(app, args, progressCallback, callback) {
|
||||
progressCallback.bind(null, { percent: 45, message: 'Downloading icon' }),
|
||||
downloadIcon.bind(null, app),
|
||||
|
||||
progressCallback.bind(null, { percent: 70, message: 'Updating addons' }),
|
||||
progressCallback.bind(null, { percent: 60, message: 'Updating addons' }),
|
||||
addons.setupAddons.bind(null, app, updateConfig.manifest.addons),
|
||||
|
||||
progressCallback.bind(null, { percent: 80, message: 'Creating container' }),
|
||||
progressCallback.bind(null, { percent: 70, message: 'Creating container' }),
|
||||
createContainer.bind(null, app),
|
||||
|
||||
startApp.bind(null, app),
|
||||
|
||||
progressCallback.bind(null, { percent: 80, message: 'Configuring file manager' }),
|
||||
sftp.rebuild.bind(null, {}),
|
||||
|
||||
progressCallback.bind(null, { percent: 100, message: 'Done' }),
|
||||
updateApp.bind(null, app, { installationState: apps.ISTATE_INSTALLED, error: null, health: null, updateTime: new Date() })
|
||||
], function seriesDone(error) {
|
||||
@@ -984,10 +994,10 @@ function uninstall(app, args, progressCallback, callback) {
|
||||
progressCallback.bind(null, { percent: 30, message: 'Teardown addons' }),
|
||||
addons.teardownAddons.bind(null, app, app.manifest.addons),
|
||||
|
||||
progressCallback.bind(null, { percent: 40, message: 'Remove sftp addon binding' }),
|
||||
progressCallback.bind(null, { percent: 40, message: 'Cleanup file manager' }),
|
||||
function (callback) {
|
||||
if (!app.dataDir) return callback();
|
||||
sftp.rebuild({ ignoredDataDirs: [ app.dataDir ] }, callback);
|
||||
sftp.rebuild({ ignoredApps: [ app.id ] }, callback);
|
||||
},
|
||||
|
||||
progressCallback.bind(null, { percent: 50, message: 'Deleting app data directory' }),
|
||||
|
||||
+8
-8
@@ -10,6 +10,7 @@ var apps = require('./apps.js'),
|
||||
async = require('async'),
|
||||
debug = require('debug')('box:sftp'),
|
||||
infra = require('./infra_version.js'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
shell = require('./shell.js');
|
||||
|
||||
@@ -22,12 +23,12 @@ function startSftp(existingInfra, callback) {
|
||||
rebuild({}, callback);
|
||||
}
|
||||
|
||||
// options only supports ignoredDataDirs = [ pathString ]
|
||||
// options only supports ignoredApps = [ appId ]
|
||||
function rebuild(options, callback) {
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (options.ignoredDataDirs) assert(Array.isArray(options.ignoredDataDirs), 'Expecting ignoredDataDirs to be an array');
|
||||
if (options.ignoredApps) assert(Array.isArray(options.ignoredApps), 'Expecting ignoredApps to be an array');
|
||||
|
||||
debug('rebuilding container');
|
||||
|
||||
@@ -41,13 +42,13 @@ function rebuild(options, callback) {
|
||||
result.forEach(function (app) {
|
||||
if (!app.dataDir) return;
|
||||
|
||||
if (options.ignoredDataDirs && options.ignoredDataDirs.indexOf(app.dataDir) !== -1) {
|
||||
debug(`Ignoring dataDir ${app.dataDir}`);
|
||||
if (options.ignoredApps && options.ignoredApps.indexOf(app.id) !== -1) {
|
||||
debug(`Ignoring volume for ${app.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
dataDirs.push({
|
||||
hostDir: app.dataDir,
|
||||
hostDir: app.dataDir || path.join(paths.APPS_DATA_DIR, app.id, 'data'),
|
||||
// /data is required since this is where the localstorage data would be in APPS_DATA_DIR
|
||||
mountDir: `/app/data/${app.id}/data`
|
||||
});
|
||||
@@ -62,7 +63,7 @@ function rebuild(options, callback) {
|
||||
], function (error) {
|
||||
if (error) debug('Failed to stop sftp container. Possibly not running.');
|
||||
|
||||
const extraAppDataVolumes = dataDirs.map(function (v) { return `-v "${v.hostDir}:${v.mountDir}"`; }).join(' ');
|
||||
const appDataVolumes = dataDirs.map(function (v) { return `-v "${v.hostDir}:${v.mountDir}"`; }).join(' ');
|
||||
|
||||
const cmd = `docker run --restart=always -d --name="sftp" \
|
||||
--hostname sftp \
|
||||
@@ -77,8 +78,7 @@ function rebuild(options, callback) {
|
||||
--dns 172.18.0.1 \
|
||||
--dns-search=. \
|
||||
-p 222:22 \
|
||||
-v "${paths.APPS_DATA_DIR}:/app/data" \
|
||||
${extraAppDataVolumes} \
|
||||
${appDataVolumes} \
|
||||
-v "/etc/ssh:/etc/ssh:ro" \
|
||||
--label isCloudronManaged=true \
|
||||
--read-only -v /tmp -v /run "${tag}"`;
|
||||
|
||||
Reference in New Issue
Block a user