volumes: check provider instead of hostPath

This commit is contained in:
Girish Ramakrishnan
2024-08-08 14:12:06 +02:00
parent 69f48ed11a
commit c03da3be54
2 changed files with 5 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ const apps = require('./apps.js'),
docker = require('./docker.js'),
hat = require('./hat.js'),
infra = require('./infra_version.js'),
mounts = require('./mounts.js'),
path = require('path'),
paths = require('./paths.js'),
safe = require('safetydance'),
@@ -82,7 +83,7 @@ async function start(existingInfra) {
dataDirs.push({ hostDir: '/mnt/volumes', mountDir: '/mnt/volumes' }); // managed volumes
const allVolumes = await volumes.list();
for (const volume of allVolumes) {
if (volume.hostPath.startsWith('/mnt/volumes/')) continue; // skip managed volume
if (mounts.isManagedProvider(volume.mountType)) continue; // skip managed volume. these are acessed via /mnt/volumes mount above
if (!safe.fs.existsSync(volume.hostPath)) {
debug(`Ignoring volume host path ${volume.hostPath} since it does not exist`);
@@ -100,7 +101,7 @@ async function start(existingInfra) {
const readOnly = !serviceConfig.recoveryMode ? '--read-only' : '';
const cmd = serviceConfig.recoveryMode ? '/bin/bash -c \'echo "Debug mode. Sleeping" && sleep infinity\'' : '';
const mounts = dataDirs.map(v => `-v "${v.hostDir}:${v.mountDir}"`).join(' ');
const volumeMounts = dataDirs.map(v => `-v "${v.hostDir}:${v.mountDir}"`).join(' ');
const runCmd = `docker run --restart=always -d --name=sftp \
--hostname sftp \
--net cloudron \
@@ -112,7 +113,7 @@ async function start(existingInfra) {
-m ${memoryLimit} \
--memory-swap -1 \
-p 222:22 \
${mounts} \
${volumeMounts} \
-e CLOUDRON_SFTP_TOKEN=${cloudronToken} \
-v ${paths.SFTP_KEYS_DIR}:/etc/ssh:ro \
--label isCloudronManaged=true \