move cloudron network creation to platform code

this gives us more control on re-creating the network with different
arguments/options when needed.
This commit is contained in:
Girish Ramakrishnan
2022-02-09 17:28:46 -08:00
parent f0f9ade972
commit 852eebac4d
4 changed files with 12 additions and 7 deletions

View File

@@ -53,6 +53,7 @@ async function start(options) {
try {
if (existingInfra.version !== infra.version) await removeAllContainers();
if (existingInfra.version === 'none') await volumes.mountAll(); // when restoring, mount all volumes
await createDockerNetwork();
await markApps(existingInfra, options); // mark app state before we start addons. this gives the db import logic a chance to mark an app as errored
await services.startServices(existingInfra);
await fs.promises.writeFile(paths.INFRA_VERSION_FILE, JSON.stringify(infra, null, 4));
@@ -111,6 +112,13 @@ async function pruneInfraImages() {
}
}
async function createDockerNetwork() {
debug('createDockerNetwork: recreating docker network');
await shell.promises.exec('createDockerNetwork', 'docker network rm cloudron');
await shell.promises.exec('createDockerNetwork', 'docker network create --subnet=172.18.0.0/16 --ip-range=172.18.0.0/20 --gateway 172.18.0.1 cloudron');
}
async function removeAllContainers() {
debug('removeAllContainers: removing all containers for infra upgrade');