mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-18 11:12:56 +00:00
Merge branch 'Dokploy:canary' into fix/chaining-canary
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const IO_UNIT_FACTORS: Record<string, number> = {
|
||||
B: 1 / 1e6,
|
||||
kB: 1e-3,
|
||||
KB: 1e-3,
|
||||
MB: 1,
|
||||
GB: 1e3,
|
||||
TB: 1e6,
|
||||
KiB: 1024 / 1e6,
|
||||
MiB: 1024 ** 2 / 1e6,
|
||||
GiB: 1024 ** 3 / 1e6,
|
||||
TiB: 1024 ** 4 / 1e6,
|
||||
};
|
||||
|
||||
export const toMb = (value: number | string | undefined): number => {
|
||||
if (typeof value === "number") {
|
||||
return value;
|
||||
}
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
const parsed = Number.parseFloat(value);
|
||||
if (Number.isNaN(parsed)) {
|
||||
return 0;
|
||||
}
|
||||
const unit = value.replace(/[0-9.\s]/g, "");
|
||||
return parsed * (IO_UNIT_FACTORS[unit] ?? 1);
|
||||
};
|
||||
|
||||
export const parseIoToMb = (raw: string | undefined): number =>
|
||||
Number(toMb(raw).toFixed(6));
|
||||
|
||||
export const formatMb = (value: number | string | undefined): string => {
|
||||
const mb = toMb(value);
|
||||
if (mb >= 1000) {
|
||||
return `${(mb / 1000).toFixed(2)} GB`;
|
||||
}
|
||||
if (mb < 0.01 && mb > 0) {
|
||||
return `${(mb * 1000).toFixed(2)} kB`;
|
||||
}
|
||||
return `${mb.toFixed(2)} MB`;
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import { promises } from "node:fs";
|
||||
import { OSUtils } from "node-os-utils";
|
||||
import { paths } from "../constants";
|
||||
import { parseIoToMb } from "./units";
|
||||
|
||||
export interface Container {
|
||||
BlockIO: string;
|
||||
@@ -28,13 +29,13 @@ export const recordAdvancedStats = async (
|
||||
});
|
||||
|
||||
await updateStatsFile(appName, "block", {
|
||||
readMb: stats.BlockIO.split(" ")[0],
|
||||
writeMb: stats.BlockIO.split(" ")[2],
|
||||
readMb: parseIoToMb(stats.BlockIO.split(" ")[0]),
|
||||
writeMb: parseIoToMb(stats.BlockIO.split(" ")[2]),
|
||||
});
|
||||
|
||||
await updateStatsFile(appName, "network", {
|
||||
inputMb: stats.NetIO.split(" ")[0],
|
||||
outputMb: stats.NetIO.split(" ")[2],
|
||||
inputMb: parseIoToMb(stats.NetIO.split(" ")[0]),
|
||||
outputMb: parseIoToMb(stats.NetIO.split(" ")[2]),
|
||||
});
|
||||
|
||||
if (appName === "dokploy") {
|
||||
|
||||
@@ -482,7 +482,7 @@ const installUtilities = () => `
|
||||
|
||||
case "$OS_TYPE" in
|
||||
arch)
|
||||
$SUDO_CMD pacman -Sy --noconfirm --needed curl wget git git-lfs jq openssl >/dev/null || true
|
||||
$SUDO_CMD pacman -Sy --noconfirm --needed unzip curl wget git git-lfs jq openssl >/dev/null || true
|
||||
;;
|
||||
alpine)
|
||||
$SUDO_CMD sed -i '/^#.*\/community/s/^#//' /etc/apk/repositories
|
||||
|
||||
@@ -220,6 +220,17 @@ export const addDomainToCompose = async (
|
||||
labels.unshift("traefik.swarm.network=dokploy-network");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const isolatedNetwork = compose.suffix || compose.appName;
|
||||
if (compose.composeType === "docker-compose") {
|
||||
if (!labels.includes(`traefik.docker.network=${isolatedNetwork}`)) {
|
||||
labels.unshift(`traefik.docker.network=${isolatedNetwork}`);
|
||||
}
|
||||
} else {
|
||||
if (!labels.includes(`traefik.swarm.network=${isolatedNetwork}`)) {
|
||||
labels.unshift(`traefik.swarm.network=${isolatedNetwork}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ export const runCommand = async (scheduleId: string) => {
|
||||
const { SCHEDULES_PATH } = paths(true);
|
||||
const fullPath = path.join(SCHEDULES_PATH, appName || "");
|
||||
const command = `
|
||||
set -e
|
||||
set -euo pipefail
|
||||
echo "Running script" >> ${deployment.logPath};
|
||||
bash -c ${fullPath}/script.sh 2>&1 | tee -a ${deployment.logPath} || {
|
||||
echo "❌ Command failed" >> ${deployment.logPath};
|
||||
|
||||
Reference in New Issue
Block a user