-
-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from Dokploy/canary
v0.7.0
- Loading branch information
Showing
53 changed files
with
7,638 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import type { Domain } from "@/server/api/services/domain"; | ||
import { createDomainLabels } from "@/server/utils/docker/domain"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("createDomainLabels", () => { | ||
const appName = "test-app"; | ||
const baseDomain: Domain = { | ||
host: "example.com", | ||
port: 8080, | ||
https: false, | ||
uniqueConfigKey: 1, | ||
certificateType: "none", | ||
applicationId: "", | ||
composeId: "", | ||
domainType: "compose", | ||
serviceName: "test-app", | ||
domainId: "", | ||
path: "/", | ||
createdAt: "", | ||
}; | ||
|
||
it("should create basic labels for web entrypoint", async () => { | ||
const labels = await createDomainLabels(appName, baseDomain, "web"); | ||
expect(labels).toEqual([ | ||
"traefik.http.routers.test-app-1-web.rule=Host(`example.com`)", | ||
"traefik.http.routers.test-app-1-web.entrypoints=web", | ||
"traefik.http.services.test-app-1-web.loadbalancer.server.port=8080", | ||
"traefik.http.routers.test-app-1-web.service=test-app-1-web", | ||
]); | ||
}); | ||
|
||
it("should create labels for websecure entrypoint", async () => { | ||
const labels = await createDomainLabels(appName, baseDomain, "websecure"); | ||
expect(labels).toEqual([ | ||
"traefik.http.routers.test-app-1-websecure.rule=Host(`example.com`)", | ||
"traefik.http.routers.test-app-1-websecure.entrypoints=websecure", | ||
"traefik.http.services.test-app-1-websecure.loadbalancer.server.port=8080", | ||
"traefik.http.routers.test-app-1-websecure.service=test-app-1-websecure", | ||
]); | ||
}); | ||
|
||
it("should add redirect middleware for https on web entrypoint", async () => { | ||
const httpsBaseDomain = { ...baseDomain, https: true }; | ||
const labels = await createDomainLabels(appName, httpsBaseDomain, "web"); | ||
expect(labels).toContain( | ||
"traefik.http.routers.test-app-1-web.middlewares=redirect-to-https@file", | ||
); | ||
}); | ||
|
||
it("should add Let's Encrypt configuration for websecure with letsencrypt certificate", async () => { | ||
const letsencryptDomain = { | ||
...baseDomain, | ||
https: true, | ||
certificateType: "letsencrypt" as const, | ||
}; | ||
const labels = await createDomainLabels( | ||
appName, | ||
letsencryptDomain, | ||
"websecure", | ||
); | ||
expect(labels).toContain( | ||
"traefik.http.routers.test-app-1-websecure.tls.certresolver=letsencrypt", | ||
); | ||
}); | ||
|
||
it("should not add Let's Encrypt configuration for non-letsencrypt certificate", async () => { | ||
const nonLetsencryptDomain = { | ||
...baseDomain, | ||
https: true, | ||
certificateType: "none" as const, | ||
}; | ||
const labels = await createDomainLabels( | ||
appName, | ||
nonLetsencryptDomain, | ||
"websecure", | ||
); | ||
expect(labels).not.toContain( | ||
"traefik.http.routers.test-app-1-websecure.tls.certresolver=letsencrypt", | ||
); | ||
}); | ||
|
||
it("should handle different ports correctly", async () => { | ||
const customPortDomain = { ...baseDomain, port: 3000 }; | ||
const labels = await createDomainLabels(appName, customPortDomain, "web"); | ||
expect(labels).toContain( | ||
"traefik.http.services.test-app-1-web.loadbalancer.server.port=3000", | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { addDokployNetworkToRoot } from "@/server/utils/docker/domain"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("addDokployNetworkToRoot", () => { | ||
it("should create network object if networks is undefined", () => { | ||
const result = addDokployNetworkToRoot(undefined); | ||
expect(result).toEqual({ "dokploy-network": { external: true } }); | ||
}); | ||
|
||
it("should add network to an empty object", () => { | ||
const result = addDokployNetworkToRoot({}); | ||
expect(result).toEqual({ "dokploy-network": { external: true } }); | ||
}); | ||
|
||
it("should not modify existing network configuration", () => { | ||
const existing = { "dokploy-network": { external: false } }; | ||
const result = addDokployNetworkToRoot(existing); | ||
expect(result).toEqual({ "dokploy-network": { external: true } }); | ||
}); | ||
|
||
it("should add network alongside existing networks", () => { | ||
const existing = { "other-network": { external: true } }; | ||
const result = addDokployNetworkToRoot(existing); | ||
expect(result).toEqual({ | ||
"other-network": { external: true }, | ||
"dokploy-network": { external: true }, | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
apps/dokploy/__test__/compose/domain/network-service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { addDokployNetworkToService } from "@/server/utils/docker/domain"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("addDokployNetworkToService", () => { | ||
it("should add network to an empty array", () => { | ||
const result = addDokployNetworkToService([]); | ||
expect(result).toEqual(["dokploy-network"]); | ||
}); | ||
|
||
it("should not add duplicate network to an array", () => { | ||
const result = addDokployNetworkToService(["dokploy-network"]); | ||
expect(result).toEqual(["dokploy-network"]); | ||
}); | ||
|
||
it("should add network to an existing array with other networks", () => { | ||
const result = addDokployNetworkToService(["other-network"]); | ||
expect(result).toEqual(["other-network", "dokploy-network"]); | ||
}); | ||
|
||
it("should add network to an object if networks is an object", () => { | ||
const result = addDokployNetworkToService({ "other-network": {} }); | ||
expect(result).toEqual({ "other-network": {}, "dokploy-network": {} }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.