Compare commits

...

7 Commits

Author SHA1 Message Date
Mauricio Siu
a6684af57e fix(templates): add null checks for template config properties
Prevent potential runtime errors by adding null checks for domains, env, and mounts in template processors
2025-03-10 03:25:04 -06:00
Mauricio Siu
8df2b20c3b Merge branch 'main' into canary 2025-03-10 02:41:10 -06:00
Mauricio Siu
f159dc11eb fix(traefik): increase service removal wait time to 15 seconds
Extend the timeout duration when removing Traefik service to ensure complete service removal and prevent potential initialization issues
2025-03-10 02:23:17 -06:00
Mauricio Siu
fce22ec1d0 fix(traefik): increase migration wait time for service removal
Adjust sleep/timeout duration in Traefik migration scripts to ensure proper service removal and container initialization
2025-03-10 01:54:25 -06:00
Mauricio Siu
e63eed57dd refactor: remove throw 2025-03-10 01:49:00 -06:00
Mauricio Siu
acc8ce80ad fix(backups): prevent error propagation in backup cleanup
Remove unnecessary error throwing in backup cleanup to allow partial success and logging
2025-03-10 01:48:28 -06:00
Mauricio Siu
e317772367 Merge pull request #1452 from Dokploy/canary
🚀 Release v0.20.0
2025-03-10 01:30:25 -06:00
5 changed files with 50 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "dokploy",
"version": "v0.20.0",
"version": "v0.20.1",
"private": true,
"license": "Apache-2.0",
"type": "module",

View File

@@ -546,7 +546,7 @@ export const createTraefikInstance = () => {
if docker service inspect dokploy-traefik > /dev/null 2>&1; then
echo "Migrating Traefik to Standalone..."
docker service rm dokploy-traefik
sleep 7
sleep 8
echo "Traefik migrated to Standalone ✅"
fi

View File

@@ -91,9 +91,26 @@ export const initializeTraefik = async ({
try {
const service = docker.getService("dokploy-traefik");
await service?.remove({ force: true });
await new Promise((resolve) => setTimeout(resolve, 5000));
} catch (_) {}
let attempts = 0;
const maxAttempts = 5;
while (attempts < maxAttempts) {
try {
await docker.listServices({
filters: { name: ["dokploy-traefik"] },
});
console.log("Waiting for service cleanup...");
await new Promise((resolve) => setTimeout(resolve, 5000));
attempts++;
} catch (e) {
break;
}
}
} catch (err) {
console.log("No existing service to remove");
}
// Then try to remove any existing container
const container = docker.getContainer(containerName);
try {
const inspect = await container.inspect();
@@ -103,15 +120,31 @@ export const initializeTraefik = async ({
}
await container.remove({ force: true });
await new Promise((resolve) => setTimeout(resolve, 5000));
} catch (error) {
console.log(error);
console.log("No existing container to remove");
}
await docker.createContainer(settings);
const newContainer = docker.getContainer(containerName);
await newContainer.start();
// Create and start the new container
try {
await docker.createContainer(settings);
const newContainer = docker.getContainer(containerName);
await newContainer.start();
console.log("Traefik container started successfully");
} catch (error: any) {
if (error?.json?.message?.includes("port is already allocated")) {
console.log("Ports still in use, waiting longer for cleanup...");
await new Promise((resolve) => setTimeout(resolve, 10000));
// Try one more time
await docker.createContainer(settings);
const newContainer = docker.getContainer(containerName);
await newContainer.start();
console.log("Traefik container started successfully after retry");
}
}
} catch (error) {
console.log(error);
console.error("Failed to initialize Traefik:", error);
throw error;
}
};

View File

@@ -175,7 +175,9 @@ export function processDomains(
variables: Record<string, string>,
schema: Schema,
): Template["domains"] {
return template.config.domains.map((domain: DomainConfig) => ({
if (!template?.config?.domains) return [];
return template?.config?.domains?.map((domain: DomainConfig) => ({
...domain,
host: domain.host
? processValue(domain.host, variables, schema)
@@ -191,7 +193,9 @@ export function processEnvVars(
variables: Record<string, string>,
schema: Schema,
): Template["envs"] {
return Object.entries(template.config.env).map(
if (!template?.config?.env) return [];
return Object.entries(template?.config?.env).map(
([key, value]: [string, string]) => {
const processedValue = processValue(value, variables, schema);
return `${key}=${processedValue}`;
@@ -207,9 +211,9 @@ export function processMounts(
variables: Record<string, string>,
schema: Schema,
): Template["mounts"] {
if (!template.config.mounts) return [];
if (!template?.config?.mounts) return [];
return template.config.mounts.map((mount: MountConfig) => ({
return template?.config?.mounts?.map((mount: MountConfig) => ({
filePath: processValue(mount.filePath, variables, schema),
content: processValue(mount.content, variables, schema),
}));

View File

@@ -212,6 +212,5 @@ export const keepLatestNBackups = async (
}
} catch (error) {
console.error(error);
throw error;
}
};