mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: rename builders to server
This commit is contained in:
47
packages/server/src/setup/setup.ts
Normal file
47
packages/server/src/setup/setup.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { docker } from "../constants";
|
||||
|
||||
export const initializeSwarm = async () => {
|
||||
const swarmInitialized = await dockerSwarmInitialized();
|
||||
if (swarmInitialized) {
|
||||
console.log("Swarm is already initilized");
|
||||
} else {
|
||||
await docker.swarmInit({
|
||||
AdvertiseAddr: "127.0.0.1",
|
||||
ListenAddr: "0.0.0.0",
|
||||
});
|
||||
console.log("Swarm was initilized");
|
||||
}
|
||||
};
|
||||
|
||||
export const dockerSwarmInitialized = async () => {
|
||||
try {
|
||||
await docker.swarmInspect();
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const initializeNetwork = async () => {
|
||||
const networkInitialized = await dockerNetworkInitialized();
|
||||
if (networkInitialized) {
|
||||
console.log("Network is already initilized");
|
||||
} else {
|
||||
docker.createNetwork({
|
||||
Attachable: true,
|
||||
Name: "dokploy-network",
|
||||
Driver: "overlay",
|
||||
});
|
||||
console.log("Network was initilized");
|
||||
}
|
||||
};
|
||||
|
||||
export const dockerNetworkInitialized = async () => {
|
||||
try {
|
||||
await docker.getNetwork("dokploy-network").inspect();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user