mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-15 19:05:28 +02:00
* feat: add builds concurrency management for servers - Introduced a new `BuildsConcurrency` component to manage the number of concurrent builds for both local and remote servers, gated by license validity. - Implemented backend logic to resolve effective builds concurrency based on server settings and organization licenses. - Added unit tests for concurrency resolution logic to ensure correct behavior under various licensing scenarios. - Updated database schema to include `buildsConcurrency` field for servers and web server settings. - Refactored deployment queue to support in-memory job processing with configurable concurrency limits. This feature enhances deployment flexibility and control for enterprise users. * refactor: enhance deployment cancellation logic and improve Railpack build isolation - Reintroduced the `initCancelDeployments` function in the server initialization sequence to ensure deployments can be canceled effectively. - Updated the Railpack build command to use a unique builder name for each build, preventing conflicts during concurrent deployments. - Enhanced the cancellation logic to reset application and compose statuses to "idle" after canceling running deployments, improving system reliability. * test: add buildsConcurrency setting to server configuration tests - Introduced a new `buildsConcurrency` property in the server configuration tests to ensure proper handling of concurrent builds in deployment scenarios. * feat: implement builds concurrency management and validation - Added `assertBuildsConcurrencyAllowed` function to validate concurrency settings based on license status. - Updated `resolveBuildsConcurrency` to reflect new concurrency limits for free and enterprise tiers. - Enhanced `BuildsConcurrency` component to manage concurrent builds for servers, with UI adjustments for better user experience. - Introduced a new settings page for managing concurrent builds across servers, ensuring proper handling of deployments. - Updated database schema to support increased maximum concurrency values for servers and web server settings.
140 lines
3.1 KiB
TypeScript
140 lines
3.1 KiB
TypeScript
import { fs, vol } from "memfs";
|
|
|
|
vi.mock("node:fs", () => ({
|
|
...fs,
|
|
default: fs,
|
|
}));
|
|
|
|
import type { FileConfig } from "@dokploy/server";
|
|
import {
|
|
createDefaultServerTraefikConfig,
|
|
loadOrCreateConfig,
|
|
updateServerTraefik,
|
|
} from "@dokploy/server";
|
|
import type { webServerSettings } from "@dokploy/server/db/schema";
|
|
import { beforeEach, expect, test, vi } from "vitest";
|
|
|
|
type WebServerSettings = typeof webServerSettings.$inferSelect;
|
|
|
|
const baseSettings: WebServerSettings = {
|
|
id: "",
|
|
https: false,
|
|
certificateType: "none",
|
|
host: null,
|
|
serverIp: null,
|
|
letsEncryptEmail: null,
|
|
sshPrivateKey: null,
|
|
enableDockerCleanup: false,
|
|
buildsConcurrency: 1,
|
|
logCleanupCron: null,
|
|
metricsConfig: {
|
|
containers: {
|
|
refreshRate: 20,
|
|
services: {
|
|
include: [],
|
|
exclude: [],
|
|
},
|
|
},
|
|
server: {
|
|
type: "Dokploy",
|
|
cronJob: "",
|
|
port: 4500,
|
|
refreshRate: 20,
|
|
retentionDays: 2,
|
|
token: "",
|
|
thresholds: {
|
|
cpu: 0,
|
|
memory: 0,
|
|
},
|
|
urlCallback: "",
|
|
},
|
|
},
|
|
whitelabelingConfig: {
|
|
appName: null,
|
|
appDescription: null,
|
|
logoUrl: null,
|
|
faviconUrl: null,
|
|
customCss: null,
|
|
loginLogoUrl: null,
|
|
supportUrl: null,
|
|
docsUrl: null,
|
|
errorPageTitle: null,
|
|
errorPageDescription: null,
|
|
metaTitle: null,
|
|
footerText: null,
|
|
},
|
|
cleanupCacheApplications: false,
|
|
cleanupCacheOnCompose: false,
|
|
cleanupCacheOnPreviews: false,
|
|
remoteServersOnly: false,
|
|
enforceSSO: false,
|
|
createdAt: null,
|
|
updatedAt: new Date(),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
vol.reset();
|
|
createDefaultServerTraefikConfig();
|
|
});
|
|
|
|
test("Should read the configuration file", () => {
|
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
|
expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe(
|
|
"dokploy-service-app",
|
|
);
|
|
});
|
|
|
|
test("Should apply redirect-to-https", () => {
|
|
updateServerTraefik(
|
|
{
|
|
...baseSettings,
|
|
https: true,
|
|
certificateType: "letsencrypt",
|
|
},
|
|
"example.com",
|
|
);
|
|
|
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
|
|
|
expect(config.http?.routers?.["dokploy-router-app"]?.middlewares).toContain(
|
|
"redirect-to-https",
|
|
);
|
|
});
|
|
|
|
test("Should change only host when no certificate", () => {
|
|
updateServerTraefik(baseSettings, "example.com");
|
|
|
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
|
|
|
expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined();
|
|
});
|
|
|
|
test("Should not touch config without host", () => {
|
|
const originalConfig: FileConfig = loadOrCreateConfig("dokploy");
|
|
|
|
updateServerTraefik(baseSettings, null);
|
|
|
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
|
|
|
expect(originalConfig).toEqual(config);
|
|
});
|
|
|
|
test("Should remove websecure if https rollback to http", () => {
|
|
updateServerTraefik(
|
|
{ ...baseSettings, certificateType: "letsencrypt" },
|
|
"example.com",
|
|
);
|
|
|
|
updateServerTraefik(
|
|
{ ...baseSettings, certificateType: "none" },
|
|
"example.com",
|
|
);
|
|
|
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
|
|
|
expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined();
|
|
expect(
|
|
config.http?.routers?.["dokploy-router-app"]?.middlewares,
|
|
).not.toContain("redirect-to-https");
|
|
});
|