Explicitly mount all apps into the sftp container

This commit is contained in:
Johannes Zellner
2020-07-29 19:47:37 +02:00
parent e1718c4e8d
commit 0a44d426fa
2 changed files with 23 additions and 13 deletions

View File

@@ -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}"`;