Unify NAS operations on tracked docker-compose.yaml
This commit is contained in:
@@ -23,7 +23,9 @@ try {
|
||||
mkdirSync(resolve(folder, 'bin'));
|
||||
for (const name of ['configure-nas.sh', 'prepare-nas-storage.sh'])
|
||||
cpSync(resolve(root, 'scripts', name), resolve(folder, 'scripts', name));
|
||||
cpSync(resolve(root, 'compose.yaml'), resolve(folder, 'compose.yaml'));
|
||||
const composeFile = resolve(folder, 'docker-compose.yaml');
|
||||
cpSync(resolve(root, 'docker-compose.yaml'), composeFile);
|
||||
const originalCompose = readFileSync(composeFile, 'utf8');
|
||||
const envFile = resolve(folder, '.env');
|
||||
writeFileSync(
|
||||
envFile,
|
||||
@@ -74,16 +76,20 @@ esac
|
||||
assert(updated.includes('SESSION_SECRET=keep-test-session-value-1234567890'));
|
||||
assert(updated.includes('DISCOVERY_SECRET=keep-test-discovery-value-1234567890'));
|
||||
assert.equal(statSync(envFile).mode & 0o777, 0o600);
|
||||
const yaml = readFileSync(resolve(folder, 'compose.nas.yaml'), 'utf8');
|
||||
const yaml = readFileSync(composeFile, 'utf8');
|
||||
assert.equal(yaml, originalCompose, 'NAS setup must not overwrite the tracked Compose file');
|
||||
assert(!yaml.includes('keep-test-session-value'));
|
||||
const config = JSON.parse(
|
||||
execFileSync(
|
||||
realDocker,
|
||||
['compose', '-f', 'compose.nas.yaml', 'config', '--no-env-resolution', '--format', 'json'],
|
||||
['compose', '-f', 'docker-compose.yaml', 'config', '--no-env-resolution', '--format', 'json'],
|
||||
{ cwd: folder, encoding: 'utf8' },
|
||||
),
|
||||
);
|
||||
assert.equal(config.services.hop.user, '12001:12002');
|
||||
assert.equal(config.name, 'hop');
|
||||
assert.equal(config.services.hop.container_name, 'hop');
|
||||
assert.equal(config.networks.hop_network.name, 'hop_hop_network');
|
||||
const files = config.services.hop.volumes.find((mount) => mount.target === '/data/uploads');
|
||||
assert.equal(files.type, 'bind');
|
||||
assert.equal(files.source, realpathSync(resolve(folder, 'uploads')));
|
||||
@@ -178,7 +184,7 @@ esac
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
'PASS: NAS UID/GID, secret preservation, private env file, absolute uploads bind path, no DB copy-up, stopped-container guard, no implicit data deletion, uploads excluded from Git/build. Compose parsed with real Docker; storage mutations isolated through a test shim.',
|
||||
'PASS: single tracked Compose unchanged by setup, existing project/container/network/database identities, NAS UID/GID, secret preservation, private env file, resolved uploads bind path, no DB copy-up, stopped-container guard, no implicit data deletion, uploads excluded from Git/build. Compose parsed with real Docker; storage mutations isolated through a test shim.',
|
||||
);
|
||||
} finally {
|
||||
if (checkedContainer) {
|
||||
|
||||
Reference in New Issue
Block a user