diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0b849afc0..d45c3dac0 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,9 +6,9 @@ Please describe in a short paragraph what this PR is about. Before submitting this PR, please make sure that: -- [] You created a dedicated branch based on the `canary` branch. -- [] You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request -- [] You have tested this PR in your local instance. +- [ ] You created a dedicated branch based on the `canary` branch. +- [ ] You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request +- [ ] You have tested this PR in your local instance. ## Issues related (if applicable) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6c74dbc02..31dbc48fb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,6 +20,32 @@ jobs: with: node-version: 20.16.0 cache: "pnpm" + + - name: Install Nixpacks + if: matrix.job == 'test' + run: | + export NIXPACKS_VERSION=1.39.0 + curl -sSL https://nixpacks.com/install.sh | bash + echo "Nixpacks installed $NIXPACKS_VERSION" + + - name: Install Railpack + if: matrix.job == 'test' + run: | + export RAILPACK_VERSION=0.15.0 + curl -sSL https://railpack.com/install.sh | bash + echo "Railpack installed $RAILPACK_VERSION" + + - name: Add build tools to PATH + if: matrix.job == 'test' + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Initialize Docker Swarm + if: matrix.job == 'test' + run: | + docker swarm init + docker network create --driver overlay dokploy-network || true + echo "✅ Docker Swarm initialized" + - run: pnpm install --frozen-lockfile - run: pnpm server:build - run: pnpm ${{ matrix.job }} diff --git a/.github/workflows/sync-openapi-docs.yml b/.github/workflows/sync-openapi-docs.yml new file mode 100644 index 000000000..ddc51355a --- /dev/null +++ b/.github/workflows/sync-openapi-docs.yml @@ -0,0 +1,70 @@ +name: Generate and Sync OpenAPI + +on: + push: + branches: + - canary + - main + paths: + - 'apps/dokploy/server/api/routers/**' + - 'packages/server/src/services/**' + - 'packages/server/src/db/schema/**' + + workflow_dispatch: + +jobs: + generate-and-commit: + name: Generate OpenAPI and commit to Dokploy repo + runs-on: ubuntu-latest + steps: + - name: Checkout Dokploy repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20.16.0 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Generate OpenAPI specification + run: | + pnpm generate:openapi + + # Verifica que se generó correctamente + if [ ! -f openapi.json ]; then + echo "❌ openapi.json not found" + exit 1 + fi + + echo "✅ OpenAPI specification generated successfully" + + - name: Sync to website repository + run: | + # Clona el repositorio de website + git clone https://x-access-token:${{ secrets.DOCS_SYNC_TOKEN }}@github.com/dokploy/website.git website-repo + + cd website-repo + + # Copia el openapi.json al website (sobrescribe) + mkdir -p apps/docs/public + cp -f ../openapi.json apps/docs/public/openapi.json + + # Configura git + git config user.name "Dokploy Bot" + git config user.email "bot@dokploy.com" + + # Agrega y commitea siempre + git add apps/docs/public/openapi.json + git commit -m "chore: sync OpenAPI specification [skip ci]" \ + -m "Source: ${{ github.repository }}@${{ github.sha }}" \ + -m "Updated: $(date -u +'%Y-%m-%d %H:%M:%S UTC')" \ + --allow-empty + + git push + + echo "✅ OpenAPI synced to website successfully" + diff --git a/.gitignore b/.gitignore index 5e6e4eb3c..d531bab01 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ node_modules .env.test.local .env.production.local +openapi.json + # Testing coverage diff --git a/Dockerfile b/Dockerfile index 11310b18e..ae8c997f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ COPY --from=build /prod/dokploy/node_modules ./node_modules # Install docker -RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh && rm get-docker.sh && curl https://rclone.org/install.sh | bash +RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh --version 28.5.2 && rm get-docker.sh && curl https://rclone.org/install.sh | bash # Install Nixpacks and tsx # | VERBOSE=1 VERSION=1.21.0 bash diff --git a/README.md b/README.md index 8faf22a35..d60962cff 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ For detailed documentation, visit [docs.dokploy.com](https://docs.dokploy.com).
Hostinger LX Aer + + + +
diff --git a/apps/api/src/utils.ts b/apps/api/src/utils.ts index ee2ac3e50..0d0b574fc 100644 --- a/apps/api/src/utils.ts +++ b/apps/api/src/utils.ts @@ -1,9 +1,9 @@ import { - deployRemoteApplication, - deployRemoteCompose, - deployRemotePreviewApplication, - rebuildRemoteApplication, - rebuildRemoteCompose, + deployApplication, + deployCompose, + deployPreviewApplication, + rebuildApplication, + rebuildCompose, updateApplicationStatus, updateCompose, updatePreviewDeployment, @@ -16,13 +16,13 @@ export const deploy = async (job: DeployJob) => { await updateApplicationStatus(job.applicationId, "running"); if (job.server) { if (job.type === "redeploy") { - await rebuildRemoteApplication({ + await rebuildApplication({ applicationId: job.applicationId, titleLog: job.titleLog || "Rebuild deployment", descriptionLog: job.descriptionLog || "", }); } else if (job.type === "deploy") { - await deployRemoteApplication({ + await deployApplication({ applicationId: job.applicationId, titleLog: job.titleLog || "Manual deployment", descriptionLog: job.descriptionLog || "", @@ -36,13 +36,13 @@ export const deploy = async (job: DeployJob) => { if (job.server) { if (job.type === "redeploy") { - await rebuildRemoteCompose({ + await rebuildCompose({ composeId: job.composeId, titleLog: job.titleLog || "Rebuild deployment", descriptionLog: job.descriptionLog || "", }); } else if (job.type === "deploy") { - await deployRemoteCompose({ + await deployCompose({ composeId: job.composeId, titleLog: job.titleLog || "Manual deployment", descriptionLog: job.descriptionLog || "", @@ -55,7 +55,7 @@ export const deploy = async (job: DeployJob) => { }); if (job.server) { if (job.type === "deploy") { - await deployRemotePreviewApplication({ + await deployPreviewApplication({ applicationId: job.applicationId, titleLog: job.titleLog || "Preview Deployment", descriptionLog: job.descriptionLog || "", diff --git a/apps/dokploy/.env.example b/apps/dokploy/.env.example index ba57ec7be..8f801196e 100644 --- a/apps/dokploy/.env.example +++ b/apps/dokploy/.env.example @@ -1,3 +1,3 @@ DATABASE_URL="postgres://dokploy:amukds4wi9001583845717ad2@localhost:5432/dokploy" PORT=3000 -NODE_ENV=development \ No newline at end of file +NODE_ENV=development diff --git a/apps/dokploy/__test__/deploy/application.command.test.ts b/apps/dokploy/__test__/deploy/application.command.test.ts new file mode 100644 index 000000000..a0c4387c8 --- /dev/null +++ b/apps/dokploy/__test__/deploy/application.command.test.ts @@ -0,0 +1,276 @@ +import * as adminService from "@dokploy/server/services/admin"; +import * as applicationService from "@dokploy/server/services/application"; +import { deployApplication } from "@dokploy/server/services/application"; +import * as deploymentService from "@dokploy/server/services/deployment"; +import * as builders from "@dokploy/server/utils/builders"; +import * as notifications from "@dokploy/server/utils/notifications/build-success"; +import * as execProcess from "@dokploy/server/utils/process/execAsync"; +import * as gitProvider from "@dokploy/server/utils/providers/git"; +import { beforeEach, describe, expect, it, vi } from "vitest"; + +vi.mock("@dokploy/server/db", () => { + const createChainableMock = (): any => { + const chain = { + set: vi.fn(() => chain), + where: vi.fn(() => chain), + returning: vi.fn().mockResolvedValue([{}] as any), + } as any; + return chain; + }; + + return { + db: { + select: vi.fn(), + insert: vi.fn(), + update: vi.fn(() => createChainableMock()), + delete: vi.fn(), + query: { + applications: { + findFirst: vi.fn(), + }, + }, + }, + }; +}); + +vi.mock("@dokploy/server/services/application", async () => { + const actual = await vi.importActual< + typeof import("@dokploy/server/services/application") + >("@dokploy/server/services/application"); + return { + ...actual, + findApplicationById: vi.fn(), + updateApplicationStatus: vi.fn(), + }; +}); + +vi.mock("@dokploy/server/services/admin", () => ({ + getDokployUrl: vi.fn(), +})); + +vi.mock("@dokploy/server/services/deployment", () => ({ + createDeployment: vi.fn(), + updateDeploymentStatus: vi.fn(), + updateDeployment: vi.fn(), +})); + +vi.mock("@dokploy/server/utils/providers/git", async () => { + const actual = await vi.importActual< + typeof import("@dokploy/server/utils/providers/git") + >("@dokploy/server/utils/providers/git"); + return { + ...actual, + getGitCommitInfo: vi.fn(), + }; +}); + +vi.mock("@dokploy/server/utils/process/execAsync", () => ({ + execAsync: vi.fn(), + ExecError: class ExecError extends Error {}, +})); + +vi.mock("@dokploy/server/utils/builders", async () => { + const actual = await vi.importActual< + typeof import("@dokploy/server/utils/builders") + >("@dokploy/server/utils/builders"); + return { + ...actual, + mechanizeDockerContainer: vi.fn(), + getBuildCommand: vi.fn(), + }; +}); + +vi.mock("@dokploy/server/utils/notifications/build-success", () => ({ + sendBuildSuccessNotifications: vi.fn(), +})); + +vi.mock("@dokploy/server/utils/notifications/build-error", () => ({ + sendBuildErrorNotifications: vi.fn(), +})); + +vi.mock("@dokploy/server/services/rollbacks", () => ({ + createRollback: vi.fn(), +})); + +import { db } from "@dokploy/server/db"; +import { cloneGitRepository } from "@dokploy/server/utils/providers/git"; + +const createMockApplication = (overrides = {}) => ({ + applicationId: "test-app-id", + name: "Test App", + appName: "test-app", + sourceType: "git" as const, + customGitUrl: "https://github.com/Dokploy/examples.git", + customGitBranch: "main", + customGitSSHKeyId: null, + buildType: "nixpacks" as const, + buildPath: "/astro", + env: "NODE_ENV=production", + serverId: null, + rollbackActive: false, + enableSubmodules: false, + environmentId: "env-id", + environment: { + projectId: "project-id", + env: "", + name: "production", + project: { + name: "Test Project", + organizationId: "org-id", + env: "", + }, + }, + domains: [], + ...overrides, +}); + +const createMockDeployment = () => ({ + deploymentId: "deployment-id", + logPath: "/tmp/test-deployment.log", +}); + +describe("deployApplication - Command Generation Tests", () => { + beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + createMockApplication() as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + createMockApplication() as any, + ); + vi.mocked(adminService.getDokployUrl).mockResolvedValue( + "http://localhost:3000", + ); + vi.mocked(deploymentService.createDeployment).mockResolvedValue( + createMockDeployment() as any, + ); + vi.mocked(execProcess.execAsync).mockResolvedValue({ + stdout: "", + stderr: "", + } as any); + vi.mocked(builders.mechanizeDockerContainer).mockResolvedValue( + undefined as any, + ); + vi.mocked(deploymentService.updateDeploymentStatus).mockResolvedValue( + undefined as any, + ); + vi.mocked(applicationService.updateApplicationStatus).mockResolvedValue( + {} as any, + ); + vi.mocked(notifications.sendBuildSuccessNotifications).mockResolvedValue( + undefined as any, + ); + vi.mocked(gitProvider.getGitCommitInfo).mockResolvedValue({ + message: "test commit", + hash: "abc123", + }); + vi.mocked(deploymentService.updateDeployment).mockResolvedValue({} as any); + }); + + it("should generate correct git clone command for astro example", async () => { + const app = createMockApplication(); + const command = await cloneGitRepository(app); + console.log(command); + + expect(command).toContain("https://github.com/Dokploy/examples.git"); + expect(command).not.toContain("--recurse-submodules"); + expect(command).toContain("--branch main"); + expect(command).toContain("--depth 1"); + expect(command).toContain("git clone"); + }); + + it("should generate git clone with submodules when enabled", async () => { + const app = createMockApplication({ enableSubmodules: true }); + const command = await cloneGitRepository(app); + + expect(command).toContain("--recurse-submodules"); + expect(command).toContain("https://github.com/Dokploy/examples.git"); + }); + + it("should verify nixpacks command is called with correct app", async () => { + const mockNixpacksCommand = "nixpacks build /path/to/app --name test-app"; + vi.mocked(builders.getBuildCommand).mockReturnValue(mockNixpacksCommand); + + await deployApplication({ + applicationId: "test-app-id", + titleLog: "Test deployment", + descriptionLog: "", + }); + + expect(builders.getBuildCommand).toHaveBeenCalledWith( + expect.objectContaining({ + buildType: "nixpacks", + customGitUrl: "https://github.com/Dokploy/examples.git", + buildPath: "/astro", + }), + ); + + expect(execProcess.execAsync).toHaveBeenCalledWith( + expect.stringContaining("nixpacks build"), + ); + }); + + it("should verify railpack command includes correct parameters", async () => { + const mockApp = createMockApplication({ buildType: "railpack" }); + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + mockApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + mockApp as any, + ); + + const mockRailpackCommand = "railpack prepare /path/to/app"; + vi.mocked(builders.getBuildCommand).mockReturnValue(mockRailpackCommand); + + await deployApplication({ + applicationId: "test-app-id", + titleLog: "Railpack test", + descriptionLog: "", + }); + + expect(builders.getBuildCommand).toHaveBeenCalledWith( + expect.objectContaining({ + buildType: "railpack", + }), + ); + + expect(execProcess.execAsync).toHaveBeenCalledWith( + expect.stringContaining("railpack prepare"), + ); + }); + + it("should execute commands in correct order", async () => { + const mockNixpacksCommand = "nixpacks build"; + vi.mocked(builders.getBuildCommand).mockReturnValue(mockNixpacksCommand); + + await deployApplication({ + applicationId: "test-app-id", + titleLog: "Test", + descriptionLog: "", + }); + + const execCalls = vi.mocked(execProcess.execAsync).mock.calls; + expect(execCalls.length).toBeGreaterThan(0); + + const fullCommand = execCalls[0]?.[0]; + expect(fullCommand).toContain("set -e"); + expect(fullCommand).toContain("git clone"); + expect(fullCommand).toContain("nixpacks build"); + }); + + it("should include log redirection in command", async () => { + const mockCommand = "nixpacks build"; + vi.mocked(builders.getBuildCommand).mockReturnValue(mockCommand); + + await deployApplication({ + applicationId: "test-app-id", + titleLog: "Test", + descriptionLog: "", + }); + + const execCalls = vi.mocked(execProcess.execAsync).mock.calls; + const fullCommand = execCalls[0]?.[0]; + + expect(fullCommand).toContain(">> /tmp/test-deployment.log 2>&1"); + }); +}); diff --git a/apps/dokploy/__test__/deploy/application.real.test.ts b/apps/dokploy/__test__/deploy/application.real.test.ts new file mode 100644 index 000000000..43ff07836 --- /dev/null +++ b/apps/dokploy/__test__/deploy/application.real.test.ts @@ -0,0 +1,479 @@ +import { existsSync } from "node:fs"; +import path from "node:path"; +import type { ApplicationNested } from "@dokploy/server"; +import { paths } from "@dokploy/server/constants"; +import { execAsync } from "@dokploy/server/utils/process/execAsync"; +import { format } from "date-fns"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +const REAL_TEST_TIMEOUT = 180000; // 3 minutes + +// Mock ONLY database and notifications +vi.mock("@dokploy/server/db", () => { + const createChainableMock = (): any => { + const chain: any = { + set: vi.fn(() => chain), + where: vi.fn(() => chain), + returning: vi.fn().mockResolvedValue([{}]), + }; + return chain; + }; + + return { + db: { + select: vi.fn(), + insert: vi.fn(), + update: vi.fn(() => createChainableMock()), + delete: vi.fn(), + query: { + applications: { + findFirst: vi.fn(), + }, + }, + }, + }; +}); + +vi.mock("@dokploy/server/services/application", async () => { + const actual = await vi.importActual< + typeof import("@dokploy/server/services/application") + >("@dokploy/server/services/application"); + return { + ...actual, + findApplicationById: vi.fn(), + updateApplicationStatus: vi.fn(), + }; +}); + +vi.mock("@dokploy/server/services/admin", () => ({ + getDokployUrl: vi.fn().mockResolvedValue("http://localhost:3000"), +})); + +vi.mock("@dokploy/server/services/deployment", () => ({ + createDeployment: vi.fn(), + updateDeploymentStatus: vi.fn(), + updateDeployment: vi.fn(), +})); + +vi.mock("@dokploy/server/utils/notifications/build-success", () => ({ + sendBuildSuccessNotifications: vi.fn(), +})); + +vi.mock("@dokploy/server/utils/notifications/build-error", () => ({ + sendBuildErrorNotifications: vi.fn(), +})); + +vi.mock("@dokploy/server/services/rollbacks", () => ({ + createRollback: vi.fn(), +})); + +// NOT mocked (executed for real): +// - execAsync +// - cloneGitRepository +// - getBuildCommand +// - mechanizeDockerContainer (requires Docker Swarm) + +import { db } from "@dokploy/server/db"; +import * as adminService from "@dokploy/server/services/admin"; +import * as applicationService from "@dokploy/server/services/application"; +import { deployApplication } from "@dokploy/server/services/application"; +import * as deploymentService from "@dokploy/server/services/deployment"; + +const createMockApplication = ( + overrides: Partial = {}, +): ApplicationNested => + ({ + applicationId: "test-app-id", + name: "Real Test App", + appName: `real-test-${Date.now()}`, + sourceType: "git" as const, + customGitUrl: "https://github.com/Dokploy/examples.git", + customGitBranch: "main", + customGitSSHKeyId: null, + customGitBuildPath: "/astro", + buildType: "nixpacks" as const, + env: "NODE_ENV=production", + serverId: null, + rollbackActive: false, + enableSubmodules: false, + environmentId: "env-id", + environment: { + projectId: "project-id", + env: "", + name: "production", + project: { + name: "Test Project", + organizationId: "org-id", + env: "", + }, + }, + domains: [], + mounts: [], + security: [], + redirects: [], + ports: [], + registry: null, + ...overrides, + }) as ApplicationNested; + +const createMockDeployment = async (appName: string) => { + const { LOGS_PATH } = paths(false); // false = local, no remote server + const formattedDateTime = format(new Date(), "yyyy-MM-dd:HH:mm:ss"); + const fileName = `${appName}-${formattedDateTime}.log`; + const logFilePath = path.join(LOGS_PATH, appName, fileName); + + // Actually create the log directory + await execAsync(`mkdir -p ${path.dirname(logFilePath)}`); + await execAsync(`echo "Initializing deployment" > ${logFilePath}`); + + return { + deploymentId: "deployment-id", + logPath: logFilePath, + }; +}; + +async function cleanupDocker(appName: string) { + try { + await execAsync(`docker stop ${appName} 2>/dev/null || true`); + await execAsync(`docker rm ${appName} 2>/dev/null || true`); + await execAsync(`docker rmi ${appName} 2>/dev/null || true`); + } catch (error) { + console.log("Docker cleanup completed"); + } +} + +async function cleanupFiles(appName: string) { + try { + const { LOGS_PATH, APPLICATIONS_PATH } = paths(false); + + // Clean cloned code directories + const appPath = path.join(APPLICATIONS_PATH, appName); + await execAsync(`rm -rf ${appPath} 2>/dev/null || true`); + + // Clean logs for appName - removes entire folder + const logPath = path.join(LOGS_PATH, appName); + await execAsync(`rm -rf ${logPath} 2>/dev/null || true`); + + console.log(`✅ Cleaned up files and logs for ${appName}`); + } catch (error) { + console.error(`⚠️ Error during cleanup for ${appName}:`, error); + } +} + +describe( + "deployApplication - REAL Execution Tests", + () => { + let currentAppName: string; + let currentDeployment: any; + const allTestAppNames: string[] = []; + + beforeEach(async () => { + vi.clearAllMocks(); + currentAppName = `real-test-${Date.now()}`; + currentDeployment = await createMockDeployment(currentAppName); + allTestAppNames.push(currentAppName); + + const mockApp = createMockApplication({ appName: currentAppName }); + + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + mockApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + mockApp as any, + ); + vi.mocked(adminService.getDokployUrl).mockResolvedValue( + "http://localhost:3000", + ); + vi.mocked(deploymentService.createDeployment).mockResolvedValue( + currentDeployment as any, + ); + vi.mocked(deploymentService.updateDeploymentStatus).mockResolvedValue( + undefined as any, + ); + vi.mocked(applicationService.updateApplicationStatus).mockResolvedValue( + {} as any, + ); + vi.mocked(deploymentService.updateDeployment).mockResolvedValue( + {} as any, + ); + }); + + afterEach(async () => { + // ALWAYS cleanup, even if test failed or passed + console.log(`\n🧹 Cleaning up test: ${currentAppName}`); + + // Clean current appName + try { + await cleanupDocker(currentAppName); + await cleanupFiles(currentAppName); + } catch (error) { + console.error("⚠️ Error cleaning current app:", error); + } + + // Clean ALL test folders just in case + try { + const { LOGS_PATH, APPLICATIONS_PATH } = paths(false); + await execAsync(`rm -rf ${LOGS_PATH}/real-* 2>/dev/null || true`); + await execAsync( + `rm -rf ${APPLICATIONS_PATH}/real-* 2>/dev/null || true`, + ); + console.log("✅ Cleaned up all test artifacts"); + } catch (error) { + console.error("⚠️ Error cleaning all artifacts:", error); + } + + console.log("✅ Cleanup completed\n"); + }); + + it( + "should REALLY clone git repo and build with nixpacks", + async () => { + console.log(`\n🚀 Testing real deployment with app: ${currentAppName}`); + + const result = await deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Nixpacks Test", + descriptionLog: "Testing real execution", + }); + + expect(result).toBe(true); + + // Verify that Docker image was actually created + const { stdout: dockerImages } = await execAsync( + `docker images ${currentAppName} --format "{{.Repository}}"`, + ); + console.log("dockerImages", dockerImages); + expect(dockerImages.trim()).toBe(currentAppName); + console.log(`✅ Docker image created: ${currentAppName}`); + + // Verify log exists and has content + expect(existsSync(currentDeployment.logPath)).toBe(true); + const { stdout: logContent } = await execAsync( + `cat ${currentDeployment.logPath}`, + ); + expect(logContent).toContain("Cloning"); + expect(logContent).toContain("nixpacks"); + console.log(`✅ Build log created with ${logContent.length} chars`); + + // Verify update functions were called + expect(deploymentService.updateDeploymentStatus).toHaveBeenCalledWith( + "deployment-id", + "done", + ); + }, + REAL_TEST_TIMEOUT, + ); + + it.skip( + "should REALLY build with railpack (SKIPPED: requires special permissions)", + async () => { + const railpackAppName = `real-railpack-${Date.now()}`; + const railpackApp = createMockApplication({ + appName: railpackAppName, + buildType: "railpack", + railpackVersion: "3", + }); + currentAppName = railpackAppName; + allTestAppNames.push(railpackAppName); + + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + railpackApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + railpackApp as any, + ); + + console.log(`\n🚀 Testing real railpack deployment: ${currentAppName}`); + + const result = await deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Railpack Test", + descriptionLog: "", + }); + + expect(result).toBe(true); + + const { stdout: dockerImages } = await execAsync( + `docker images ${currentAppName} --format "{{.Repository}}"`, + ); + expect(dockerImages.trim()).toBe(currentAppName); + console.log(`✅ Railpack image created: ${currentAppName}`); + + const { stdout: logContent } = await execAsync( + `cat ${currentDeployment.logPath}`, + ); + expect(logContent).toContain("railpack"); + console.log("✅ Railpack build completed"); + }, + REAL_TEST_TIMEOUT, + ); + + it( + "should handle REAL git clone errors", + async () => { + const errorAppName = `real-error-${Date.now()}`; + const errorApp = createMockApplication({ + appName: errorAppName, + customGitUrl: + "https://github.com/invalid/nonexistent-repo-123456.git", + }); + currentAppName = errorAppName; + allTestAppNames.push(errorAppName); + + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + errorApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + errorApp as any, + ); + + console.log(`\n🚀 Testing real error handling: ${currentAppName}`); + + await expect( + deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Error Test", + descriptionLog: "", + }), + ).rejects.toThrow(); + + // Verify error status was called + expect(deploymentService.updateDeploymentStatus).toHaveBeenCalledWith( + "deployment-id", + "error", + ); + + // Verify log contains error + const { stdout: logContent } = await execAsync( + `cat ${currentDeployment.logPath}`, + ); + expect(logContent.toLowerCase()).toContain("error"); + console.log("✅ Error handling verified"); + }, + REAL_TEST_TIMEOUT, + ); + + it( + "should REALLY clone with submodules when enabled", + async () => { + const submodulesAppName = `real-submodules-${Date.now()}`; + const submodulesApp = createMockApplication({ + appName: submodulesAppName, + enableSubmodules: true, + }); + currentAppName = submodulesAppName; + allTestAppNames.push(submodulesAppName); + + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + submodulesApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + submodulesApp as any, + ); + + console.log(`\n🚀 Testing real submodules support: ${currentAppName}`); + + const result = await deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Submodules Test", + descriptionLog: "", + }); + + expect(result).toBe(true); + + // Verify deployment completed successfully + const { stdout: logContent } = await execAsync( + `cat ${currentDeployment.logPath}`, + ); + expect(logContent).toContain("Cloning"); + expect(logContent.length).toBeGreaterThan(100); + console.log("✅ Submodules deployment completed"); + + // Verify image + const { stdout: dockerImages } = await execAsync( + `docker images ${currentAppName} --format "{{.Repository}}"`, + ); + expect(dockerImages.trim()).toBe(currentAppName); + }, + REAL_TEST_TIMEOUT, + ); + + it( + "should verify REAL commit info extraction", + async () => { + console.log(`\n🚀 Testing real commit info: ${currentAppName}`); + + await deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Commit Test", + descriptionLog: "", + }); + + // Verify updateDeployment was called with commit info + expect(deploymentService.updateDeployment).toHaveBeenCalled(); + const updateCall = vi.mocked(deploymentService.updateDeployment).mock + .calls[0]; + + // Real commit info should have title and hash + expect(updateCall?.[1]).toHaveProperty("title"); + expect(updateCall?.[1]).toHaveProperty("description"); + expect(updateCall?.[1]?.description).toContain("Commit:"); + + console.log( + `✅ Real commit extracted: ${updateCall?.[1]?.title?.substring(0, 50)}...`, + ); + }, + REAL_TEST_TIMEOUT, + ); + + it( + "should REALLY build with Dockerfile", + async () => { + const dockerfileAppName = `real-dockerfile-${Date.now()}`; + const dockerfileApp = createMockApplication({ + appName: dockerfileAppName, + buildType: "dockerfile", + customGitBuildPath: "/deno", + dockerfile: "Dockerfile", + }); + currentAppName = dockerfileAppName; + allTestAppNames.push(dockerfileAppName); + + vi.mocked(db.query.applications.findFirst).mockResolvedValue( + dockerfileApp as any, + ); + vi.mocked(applicationService.findApplicationById).mockResolvedValue( + dockerfileApp as any, + ); + + console.log(`\n🚀 Testing real Dockerfile build: ${currentAppName}`); + + const result = await deployApplication({ + applicationId: "test-app-id", + titleLog: "Real Dockerfile Test", + descriptionLog: "", + }); + + expect(result).toBe(true); + + // Verify log + const { stdout: logContent } = await execAsync( + `cat ${currentDeployment.logPath}`, + ); + expect(logContent).toContain("Building"); + expect(logContent).toContain(dockerfileAppName); + console.log("✅ Dockerfile build log verified"); + + // Verify image + const { stdout: dockerImages } = await execAsync( + `docker images ${currentAppName} --format "{{.Repository}}"`, + ); + console.log("dockerImages", dockerImages); + expect(dockerImages.trim()).toBe(currentAppName); + console.log(`✅ Docker image created: ${currentAppName}`); + }, + REAL_TEST_TIMEOUT, + ); + }, + REAL_TEST_TIMEOUT, +); diff --git a/apps/dokploy/__test__/deploy/github.test.ts b/apps/dokploy/__test__/deploy/github.test.ts index 03805b08d..46be44883 100644 --- a/apps/dokploy/__test__/deploy/github.test.ts +++ b/apps/dokploy/__test__/deploy/github.test.ts @@ -1,5 +1,10 @@ import { describe, expect, it } from "vitest"; -import { extractCommitMessage } from "@/pages/api/deploy/[refreshToken]"; +import { + extractCommitMessage, + extractImageName, + extractImageTag, + extractImageTagFromRequest, +} from "@/pages/api/deploy/[refreshToken]"; describe("GitHub Webhook Skip CI", () => { const mockGithubHeaders = { @@ -96,3 +101,308 @@ describe("GitHub Webhook Skip CI", () => { ); }); }); + +describe("GitHub Packages Docker Image Tag Extraction", () => { + it("should extract tag from container_metadata", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + container_metadata: { + tag: { + name: "v1.0.0", + digest: "sha256:abc123...", + }, + }, + package_url: "ghcr.io/owner/repo:v1.0.0", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBe("v1.0.0"); + }); + + it("should extract tag from package_url when container_metadata tag matches version", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + container_metadata: { + tag: { + name: "sha256:abc123...", + digest: "sha256:abc123...", + }, + }, + package_url: "ghcr.io/owner/repo:latest", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBe("latest"); + }); + + it("should extract tag from package_url when container_metadata is missing", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + package_url: "ghcr.io/owner/repo:1.2.3", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBe("1.2.3"); + }); + + it("should handle different tag formats in package_url", () => { + const headers = { "x-github-event": "registry_package" }; + const testCases = [ + { url: "ghcr.io/owner/repo:latest", expected: "latest" }, + { url: "ghcr.io/owner/repo:v1.0.0", expected: "v1.0.0" }, + { url: "ghcr.io/owner/repo:1.2.3", expected: "1.2.3" }, + { url: "ghcr.io/owner/repo:dev", expected: "dev" }, + ]; + + for (const testCase of testCases) { + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + package_url: testCase.url, + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBe(testCase.expected); + } + }); + + it("should return null for non-registry_package events", () => { + const headers = { "x-github-event": "push" }; + const body = { + registry_package: { + package_version: { + package_url: "ghcr.io/owner/repo:latest", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBeNull(); + }); + + it("should return null when package_version is missing", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: {}, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBeNull(); + }); + + it("should return null when package_url has no tag", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + package_url: "ghcr.io/owner/repo", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBeNull(); + }); + + it("should return null when package_url ends with colon (no tag)", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + package_url: "ghcr.io/owner/repo:", + container_metadata: { + tag: { + name: "", + digest: "sha256:abc123...", + }, + }, + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBeNull(); + }); + + it("should return null when tag name is empty string", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + container_metadata: { + tag: { + name: "", + digest: "sha256:abc123...", + }, + }, + package_url: "ghcr.io/owner/repo:", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBeNull(); + }); + + it("should ignore tag if it matches the version (digest)", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + container_metadata: { + tag: { + name: "sha256:abc123...", + digest: "sha256:abc123...", + }, + }, + package_url: "ghcr.io/owner/repo:latest", + }, + }, + }; + + const tag = extractImageTagFromRequest(headers, body); + expect(tag).toBe("latest"); + }); + + it("should handle registry_package commit message with package_url", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + package_url: "ghcr.io/owner/repo:latest", + }, + }, + }; + + const message = extractCommitMessage(headers, body); + expect(message).toBe("Docker GHCR image pushed: ghcr.io/owner/repo:latest"); + }); + + it("should handle registry_package commit message when package_url is missing", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: { + package_version: { + version: "sha256:abc123...", + }, + }, + }; + + const message = extractCommitMessage(headers, body); + expect(message).toBe("Docker GHCR image pushed"); + }); + + it("should handle registry_package commit message when package_version is missing", () => { + const headers = { "x-github-event": "registry_package" }; + const body = { + registry_package: {}, + }; + + const message = extractCommitMessage(headers, body); + expect(message).toBe("NEW COMMIT"); + }); +}); + +describe("Docker Image Name and Tag Extraction", () => { + describe("extractImageName", () => { + it("should return image name without tag", () => { + expect(extractImageName("my-image:latest")).toBe("my-image"); + expect(extractImageName("my-image:1.0.0")).toBe("my-image"); + expect(extractImageName("ghcr.io/owner/repo:latest")).toBe( + "ghcr.io/owner/repo", + ); + }); + + it("should return full image name when no tag is present", () => { + expect(extractImageName("my-image")).toBe("my-image"); + expect(extractImageName("ghcr.io/owner/repo")).toBe("ghcr.io/owner/repo"); + }); + + it("should handle images with port numbers correctly", () => { + expect(extractImageName("registry:5000/image:tag")).toBe( + "registry:5000/image", + ); + expect(extractImageName("localhost:5000/my-app:latest")).toBe( + "localhost:5000/my-app", + ); + }); + + it("should handle complex image paths", () => { + expect( + extractImageName("myregistryhost:5000/fedora/httpd:version1.0"), + ).toBe("myregistryhost:5000/fedora/httpd"); + expect(extractImageName("registry.example.com:8080/ns/app:v1.2.3")).toBe( + "registry.example.com:8080/ns/app", + ); + }); + + it("should return null for invalid inputs", () => { + expect(extractImageName(null)).toBeNull(); + expect(extractImageName("")).toBeNull(); + }); + + it("should handle edge cases with multiple colons", () => { + expect(extractImageName("image:tag:extra")).toBe("image:tag"); + expect(extractImageName("registry:5000:invalid")).toBe("registry:5000"); + }); + }); + + describe("extractImageTag", () => { + it("should extract tag from image with tag", () => { + expect(extractImageTag("my-image:latest")).toBe("latest"); + expect(extractImageTag("my-image:1.0.0")).toBe("1.0.0"); + expect(extractImageTag("ghcr.io/owner/repo:v1.2.3")).toBe("v1.2.3"); + }); + + it("should return 'latest' when no tag is present", () => { + expect(extractImageTag("my-image")).toBe("latest"); + expect(extractImageTag("ghcr.io/owner/repo")).toBe("latest"); + }); + + it("should handle complex image paths with tags", () => { + expect( + extractImageTag("myregistryhost:5000/fedora/httpd:version1.0"), + ).toBe("version1.0"); + expect(extractImageTag("registry.example.com:8080/ns/app:v1.2.3")).toBe( + "v1.2.3", + ); + }); + + it("should return null for invalid inputs", () => { + expect(extractImageTag(null)).toBeNull(); + expect(extractImageTag("")).toBeNull(); + }); + + it("should handle edge cases with multiple colons", () => { + expect(extractImageTag("image:tag:extra")).toBe("extra"); + expect(extractImageTag("registry:5000/image:tag")).toBe("tag"); + }); + + it("should handle numeric tags", () => { + expect(extractImageTag("my-image:123")).toBe("123"); + expect(extractImageTag("my-image:1")).toBe("1"); + }); + }); +}); diff --git a/apps/dokploy/__test__/drop/drop.test.ts b/apps/dokploy/__test__/drop/drop.test.ts index b597b3aa4..bd2d3c981 100644 --- a/apps/dokploy/__test__/drop/drop.test.ts +++ b/apps/dokploy/__test__/drop/drop.test.ts @@ -30,6 +30,10 @@ const baseApp: ApplicationNested = { previewLabels: [], herokuVersion: "", giteaBranch: "", + buildServerId: "", + buildRegistryId: "", + buildRegistry: null, + args: [], giteaBuildPath: "", previewRequireCollaboratorPermissions: false, giteaId: "", @@ -42,12 +46,14 @@ const baseApp: ApplicationNested = { triggerType: "push", appName: "", autoDeploy: true, + endpointSpecSwarm: null, serverId: "", registryUrl: "", branch: null, dockerBuildStage: "", isPreviewDeploymentsActive: false, previewBuildArgs: null, + previewBuildSecrets: null, previewCertificateType: "none", previewCustomCertResolver: null, previewEnv: null, @@ -73,6 +79,7 @@ const baseApp: ApplicationNested = { }, }, buildArgs: null, + buildSecrets: null, buildPath: "/", gitlabPathNamespace: "", buildType: "nixpacks", @@ -133,6 +140,7 @@ const baseApp: ApplicationNested = { username: null, dockerContextPath: null, rollbackActive: false, + stopGracePeriodSwarm: null, }; describe("unzipDrop using real zip files", () => { diff --git a/apps/dokploy/__test__/env/environment.test.ts b/apps/dokploy/__test__/env/environment.test.ts index 95d46dcc0..24ef18b00 100644 --- a/apps/dokploy/__test__/env/environment.test.ts +++ b/apps/dokploy/__test__/env/environment.test.ts @@ -1,4 +1,7 @@ -import { prepareEnvironmentVariables } from "@dokploy/server/index"; +import { + prepareEnvironmentVariables, + prepareEnvironmentVariablesForShell, +} from "@dokploy/server/index"; import { describe, expect, it } from "vitest"; const projectEnv = ` @@ -332,4 +335,310 @@ IS_DEV=\${{environment.DEVELOPMENT}} "IS_DEV=0", ]); }); + + it("handles environment variables with single quotes in values", () => { + const envWithSingleQuotes = ` +ENV_VARIABLE='ENVITONME'NT' +ANOTHER_VAR='value with 'quotes' inside' +SIMPLE_VAR=no-quotes +`; + + const serviceWithSingleQuotes = ` +TEST_VAR=\${{environment.ENV_VARIABLE}} +ANOTHER_TEST=\${{environment.ANOTHER_VAR}} +SIMPLE=\${{environment.SIMPLE_VAR}} +`; + + const resolved = prepareEnvironmentVariables( + serviceWithSingleQuotes, + "", + envWithSingleQuotes, + ); + + expect(resolved).toEqual([ + "TEST_VAR=ENVITONME'NT", + "ANOTHER_TEST=value with 'quotes' inside", + "SIMPLE=no-quotes", + ]); + }); +}); + +describe("prepareEnvironmentVariablesForShell (shell escaping)", () => { + it("escapes single quotes in environment variable values", () => { + const serviceEnv = ` +ENV_VARIABLE='ENVITONME'NT' +ANOTHER_VAR='value with 'quotes' inside' +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // shell-quote should wrap these in double quotes + expect(resolved).toEqual([ + `"ENV_VARIABLE=ENVITONME'NT"`, + `"ANOTHER_VAR=value with 'quotes' inside"`, + ]); + }); + + it("escapes double quotes in environment variable values", () => { + const serviceEnv = ` +MESSAGE="Hello "World"" +QUOTED_PATH="/path/to/"file"" +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // shell-quote wraps in single quotes when there are double quotes inside + expect(resolved).toEqual([ + `'MESSAGE=Hello "World"'`, + `'QUOTED_PATH=/path/to/"file"'`, + ]); + }); + + it("escapes dollar signs in environment variable values", () => { + const serviceEnv = ` +PRICE=$100 +VARIABLE=$HOME/path +TEMPLATE=Hello $USER +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // Dollar signs should be escaped to prevent variable expansion + for (const env of resolved) { + expect(env).toContain("$"); + } + }); + + it("escapes backticks in environment variable values", () => { + const serviceEnv = ` +COMMAND=\`echo "test"\` +NESTED=value with \`backticks\` inside +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // Backticks are escaped/removed by dotenv parsing, but values should be safely quoted + expect(resolved.length).toBe(2); + expect(resolved[0]).toContain("COMMAND"); + expect(resolved[1]).toContain("NESTED"); + }); + + it("handles environment variables with spaces", () => { + const serviceEnv = ` +FULL_NAME="John Doe" +MESSAGE='Hello World' +SENTENCE=This is a test +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // shell-quote uses single quotes for strings with spaces + expect(resolved).toEqual([ + `'FULL_NAME=John Doe'`, + `'MESSAGE=Hello World'`, + `'SENTENCE=This is a test'`, + ]); + }); + + it("handles environment variables with backslashes", () => { + const serviceEnv = ` +WINDOWS_PATH=C:\\Users\\Documents +ESCAPED=value\\with\\backslashes +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // Backslashes should be properly escaped + expect(resolved.length).toBe(2); + for (const env of resolved) { + expect(env).toContain("\\"); + } + }); + + it("handles simple environment variables without special characters", () => { + const serviceEnv = ` +NODE_ENV=production +PORT=3000 +DEBUG=true +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // shell-quote escapes the = sign in some cases + expect(resolved).toEqual([ + "NODE_ENV\\=production", + "PORT\\=3000", + "DEBUG\\=true", + ]); + }); + + it("handles environment variables with mixed special characters", () => { + const serviceEnv = ` +COMPLEX='value with "double" and 'single' quotes' +BASH_COMMAND=echo "$HOME" && echo 'test' +WEIRD=\`echo "$VAR"\` with 'quotes' and "more" +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // All should be escaped, none should throw errors + expect(resolved.length).toBe(3); + // Verify each can be safely used in shell + for (const env of resolved) { + expect(typeof env).toBe("string"); + expect(env.length).toBeGreaterThan(0); + } + }); + + it("handles environment variables with newlines", () => { + const serviceEnv = ` +MULTILINE="line1 +line2 +line3" +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(1); + expect(resolved[0]).toContain("MULTILINE"); + }); + + it("handles empty environment variable values", () => { + const serviceEnv = ` +EMPTY= +EMPTY_QUOTED="" +EMPTY_SINGLE='' +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + // shell-quote escapes the = sign for empty values + expect(resolved).toEqual([ + "EMPTY\\=", + "EMPTY_QUOTED\\=", + "EMPTY_SINGLE\\=", + ]); + }); + + it("handles environment variables with equals signs in values", () => { + const serviceEnv = ` +EQUATION=a=b+c +CONNECTION_STRING=user=admin;password=test +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(2); + expect(resolved[0]).toContain("EQUATION"); + expect(resolved[1]).toContain("CONNECTION_STRING"); + }); + + it("resolves and escapes environment variables together", () => { + const projectEnv = ` +BASE_URL=https://example.com +API_KEY='secret-key-with-quotes' +`; + + const environmentEnv = ` +ENV_NAME=production +DB_PASS='pa$$word' +`; + + const serviceEnv = ` +FULL_URL=\${{project.BASE_URL}}/api +AUTH_KEY=\${{project.API_KEY}} +ENVIRONMENT=\${{environment.ENV_NAME}} +DB_PASSWORD=\${{environment.DB_PASS}} +CUSTOM='value with 'quotes' inside' +`; + + const resolved = prepareEnvironmentVariablesForShell( + serviceEnv, + projectEnv, + environmentEnv, + ); + + expect(resolved.length).toBe(5); + // All resolved values should be properly escaped + for (const env of resolved) { + expect(typeof env).toBe("string"); + } + }); + + it("handles environment variables with semicolons and ampersands", () => { + const serviceEnv = ` +COMMAND=echo "test" && echo "test2" +MULTIPLE=cmd1; cmd2; cmd3 +URL_WITH_PARAMS=https://example.com?a=1&b=2&c=3 +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(3); + // These should be safely escaped to prevent command injection + for (const env of resolved) { + expect(typeof env).toBe("string"); + expect(env.length).toBeGreaterThan(0); + } + }); + + it("handles environment variables with pipes and redirects", () => { + const serviceEnv = ` +PIPE_COMMAND=cat file | grep test +REDIRECT=echo "test" > output.txt +BOTH=cat input.txt | grep pattern > output.txt +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(3); + // Pipes and redirects should be safely quoted + expect(resolved[0]).toContain("PIPE_COMMAND"); + expect(resolved[1]).toContain("REDIRECT"); + expect(resolved[2]).toContain("BOTH"); + // At least one should contain a pipe + const hasPipe = resolved.some((env) => env.includes("|")); + expect(hasPipe).toBe(true); + }); + + it("handles environment variables with parentheses and brackets", () => { + const serviceEnv = ` +MATH=(a+b)*c +ARRAY=[1,2,3] +JSON={"key":"value"} +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(3); + expect(resolved[0]).toContain("("); + expect(resolved[1]).toContain("["); + expect(resolved[2]).toContain("{"); + }); + + it("handles very long environment variable values", () => { + const longValue = "a".repeat(10000); + const serviceEnv = `LONG_VAR=${longValue}`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(1); + expect(resolved[0]).toContain("LONG_VAR"); + expect(resolved[0]?.length).toBeGreaterThan(10000); + }); + + it("handles special unicode characters in environment variables", () => { + const serviceEnv = ` +EMOJI=Hello 🌍 World 🚀 +CHINESE=你好世界 +SPECIAL=café résumé naïve +`; + + const resolved = prepareEnvironmentVariablesForShell(serviceEnv, "", ""); + + expect(resolved.length).toBe(3); + expect(resolved[0]).toContain("🌍"); + expect(resolved[1]).toContain("你好"); + expect(resolved[2]).toContain("café"); + }); }); diff --git a/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts b/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts new file mode 100644 index 000000000..38948ac5c --- /dev/null +++ b/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts @@ -0,0 +1,110 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import type { ApplicationNested } from "@dokploy/server/utils/builders"; +import { mechanizeDockerContainer } from "@dokploy/server/utils/builders"; + +type MockCreateServiceOptions = { + TaskTemplate?: { + ContainerSpec?: { + StopGracePeriod?: number; + }; + }; + [key: string]: unknown; +}; + +const { inspectMock, getServiceMock, createServiceMock, getRemoteDockerMock } = + vi.hoisted(() => { + const inspect = vi.fn<[], Promise>(); + const getService = vi.fn(() => ({ inspect })); + const createService = vi.fn<[MockCreateServiceOptions], Promise>( + async () => undefined, + ); + const getRemoteDocker = vi.fn(async () => ({ + getService, + createService, + })); + return { + inspectMock: inspect, + getServiceMock: getService, + createServiceMock: createService, + getRemoteDockerMock: getRemoteDocker, + }; + }); + +vi.mock("@dokploy/server/utils/servers/remote-docker", () => ({ + getRemoteDocker: getRemoteDockerMock, +})); + +const createApplication = ( + overrides: Partial = {}, +): ApplicationNested => + ({ + appName: "test-app", + buildType: "dockerfile", + env: null, + mounts: [], + cpuLimit: null, + memoryLimit: null, + memoryReservation: null, + cpuReservation: null, + command: null, + ports: [], + sourceType: "docker", + dockerImage: "example:latest", + registry: null, + environment: { + project: { env: null }, + env: null, + }, + replicas: 1, + stopGracePeriodSwarm: 0n, + serverId: "server-id", + ...overrides, + }) as unknown as ApplicationNested; + +describe("mechanizeDockerContainer", () => { + beforeEach(() => { + inspectMock.mockReset(); + inspectMock.mockRejectedValue(new Error("service not found")); + getServiceMock.mockClear(); + createServiceMock.mockClear(); + getRemoteDockerMock.mockClear(); + getRemoteDockerMock.mockResolvedValue({ + getService: getServiceMock, + createService: createServiceMock, + }); + }); + + it("converts bigint stopGracePeriodSwarm to a number and keeps zero values", async () => { + const application = createApplication({ stopGracePeriodSwarm: 0n }); + + await mechanizeDockerContainer(application); + + expect(createServiceMock).toHaveBeenCalledTimes(1); + const call = createServiceMock.mock.calls[0]; + if (!call) { + throw new Error("createServiceMock should have been called once"); + } + const [settings] = call; + expect(settings.TaskTemplate?.ContainerSpec?.StopGracePeriod).toBe(0); + expect(typeof settings.TaskTemplate?.ContainerSpec?.StopGracePeriod).toBe( + "number", + ); + }); + + it("omits StopGracePeriod when stopGracePeriodSwarm is null", async () => { + const application = createApplication({ stopGracePeriodSwarm: null }); + + await mechanizeDockerContainer(application); + + expect(createServiceMock).toHaveBeenCalledTimes(1); + const call = createServiceMock.mock.calls[0]; + if (!call) { + throw new Error("createServiceMock should have been called once"); + } + const [settings] = call; + expect(settings.TaskTemplate?.ContainerSpec).not.toHaveProperty( + "StopGracePeriod", + ); + }); +}); diff --git a/apps/dokploy/__test__/templates/helpers.template.test.ts b/apps/dokploy/__test__/templates/helpers.template.test.ts index 1144b65fe..3ae92ae20 100644 --- a/apps/dokploy/__test__/templates/helpers.template.test.ts +++ b/apps/dokploy/__test__/templates/helpers.template.test.ts @@ -228,5 +228,58 @@ describe("helpers functions", () => { "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzU2ODk2MDAsImV4cCI6MTczNTY5MzIwMCwiaXNzIjoidGVzdC1pc3N1ZXIiLCJjdXN0b21wcm9wIjoiY3VzdG9tdmFsdWUifQ.m42U7PZSUSCf7gBOJrxJir0rQmyPq4rA59Dydr_QahI", ); }); + + it("should handle JWT payload with newlines and whitespace by trimming them", () => { + const iat = Math.floor(new Date("2025-01-01T00:00:00Z").getTime() / 1000); + const expiry = iat + 3600; + const payloadWithNewlines = `{ + "role": "anon", + "iss": "supabase", + "exp": ${expiry} +} +`; + const jwt = processValue( + "${jwt:secret:payload}", + { + secret: "mysecret", + payload: payloadWithNewlines, + }, + mockSchema, + ); + expect(jwt).toMatch(jwtMatchExp); + const parts = jwt.split(".") as JWTParts; + jwtCheckHeader(parts[0]); + const decodedPayload = jwtBase64Decode(parts[1]); + expect(decodedPayload).toHaveProperty("role"); + expect(decodedPayload.role).toEqual("anon"); + expect(decodedPayload).toHaveProperty("iss"); + expect(decodedPayload.iss).toEqual("supabase"); + expect(decodedPayload).toHaveProperty("exp"); + expect(decodedPayload.exp).toEqual(expiry); + }); + + it("should handle JWT payload with leading and trailing whitespace", () => { + const iat = Math.floor(new Date("2025-01-01T00:00:00Z").getTime() / 1000); + const expiry = iat + 3600; + const payloadWithWhitespace = ` {"role": "service_role", "iss": "supabase", "exp": ${expiry}} `; + const jwt = processValue( + "${jwt:secret:payload}", + { + secret: "mysecret", + payload: payloadWithWhitespace, + }, + mockSchema, + ); + expect(jwt).toMatch(jwtMatchExp); + const parts = jwt.split(".") as JWTParts; + jwtCheckHeader(parts[0]); + const decodedPayload = jwtBase64Decode(parts[1]); + expect(decodedPayload).toHaveProperty("role"); + expect(decodedPayload.role).toEqual("service_role"); + expect(decodedPayload).toHaveProperty("iss"); + expect(decodedPayload.iss).toEqual("supabase"); + expect(decodedPayload).toHaveProperty("exp"); + expect(decodedPayload.exp).toEqual(expiry); + }); }); }); diff --git a/apps/dokploy/__test__/traefik/traefik.test.ts b/apps/dokploy/__test__/traefik/traefik.test.ts index 5be96e473..e6b98c3ba 100644 --- a/apps/dokploy/__test__/traefik/traefik.test.ts +++ b/apps/dokploy/__test__/traefik/traefik.test.ts @@ -11,10 +11,15 @@ const baseApp: ApplicationNested = { giteaRepository: "", giteaOwner: "", giteaBranch: "", + buildServerId: "", + buildRegistryId: "", + buildRegistry: null, giteaBuildPath: "", giteaId: "", + args: [], cleanCache: false, applicationStatus: "done", + endpointSpecSwarm: null, appName: "", autoDeploy: true, enableSubmodules: false, @@ -25,8 +30,10 @@ const baseApp: ApplicationNested = { registryUrl: "", watchPaths: [], buildArgs: null, + buildSecrets: null, isPreviewDeploymentsActive: false, previewBuildArgs: null, + previewBuildSecrets: null, triggerType: "push", previewCertificateType: "none", previewEnv: null, @@ -111,6 +118,7 @@ const baseApp: ApplicationNested = { updateConfigSwarm: null, username: null, dockerContextPath: null, + stopGracePeriodSwarm: null, }; const baseDomain: Domain = { diff --git a/apps/dokploy/__test__/vitest.config.ts b/apps/dokploy/__test__/vitest.config.ts index ddc84d6ac..7270b828a 100644 --- a/apps/dokploy/__test__/vitest.config.ts +++ b/apps/dokploy/__test__/vitest.config.ts @@ -13,7 +13,11 @@ export default defineConfig({ NODE: "test", }, }, - plugins: [tsconfigPaths()], + plugins: [ + tsconfigPaths({ + projects: [path.resolve(__dirname, "../tsconfig.json")], + }), + ], resolve: { alias: { "@dokploy/server": path.resolve( diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx index 9e10f43ec..739bd87a5 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx @@ -25,6 +25,7 @@ import { FormLabel, FormMessage, } from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; import { Tooltip, TooltipContent, @@ -121,6 +122,22 @@ const NetworkSwarmSchema = z.array( const LabelsSwarmSchema = z.record(z.string()); +const EndpointPortConfigSwarmSchema = z + .object({ + Protocol: z.string().optional(), + TargetPort: z.number().optional(), + PublishedPort: z.number().optional(), + PublishMode: z.string().optional(), + }) + .strict(); + +const EndpointSpecSwarmSchema = z + .object({ + Mode: z.string().optional(), + Ports: z.array(EndpointPortConfigSwarmSchema).optional(), + }) + .strict(); + const createStringToJSONSchema = (schema: z.ZodTypeAny) => { return z .string() @@ -176,10 +193,21 @@ const addSwarmSettings = z.object({ modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(), labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(), networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: createStringToJSONSchema( + EndpointSpecSwarmSchema, + ).nullable(), }); type AddSwarmSettings = z.infer; +const hasStopGracePeriodSwarm = ( + value: unknown, +): value is { stopGracePeriodSwarm: bigint | number | string | null } => + typeof value === "object" && + value !== null && + "stopGracePeriodSwarm" in value; + interface Props { id: string; type: "postgres" | "mariadb" | "mongo" | "mysql" | "redis" | "application"; @@ -224,12 +252,23 @@ export const AddSwarmSettings = ({ id, type }: Props) => { modeSwarm: null, labelsSwarm: null, networkSwarm: null, + stopGracePeriodSwarm: null, + endpointSpecSwarm: null, }, resolver: zodResolver(addSwarmSettings), }); useEffect(() => { if (data) { + const stopGracePeriodValue = hasStopGracePeriodSwarm(data) + ? data.stopGracePeriodSwarm + : null; + const normalizedStopGracePeriod = + stopGracePeriodValue === null || stopGracePeriodValue === undefined + ? null + : typeof stopGracePeriodValue === "bigint" + ? stopGracePeriodValue + : BigInt(stopGracePeriodValue); form.reset({ healthCheckSwarm: data.healthCheckSwarm ? JSON.stringify(data.healthCheckSwarm, null, 2) @@ -255,6 +294,10 @@ export const AddSwarmSettings = ({ id, type }: Props) => { networkSwarm: data.networkSwarm ? JSON.stringify(data.networkSwarm, null, 2) : null, + stopGracePeriodSwarm: normalizedStopGracePeriod, + endpointSpecSwarm: data.endpointSpecSwarm + ? JSON.stringify(data.endpointSpecSwarm, null, 2) + : null, }); } }, [form, form.reset, data]); @@ -275,6 +318,8 @@ export const AddSwarmSettings = ({ id, type }: Props) => { modeSwarm: data.modeSwarm, labelsSwarm: data.labelsSwarm, networkSwarm: data.networkSwarm, + stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null, + endpointSpecSwarm: data.endpointSpecSwarm, }) .then(async () => { toast.success("Swarm settings updated"); @@ -352,9 +397,9 @@ export const AddSwarmSettings = ({ id, type }: Props) => { language="json" placeholder={`{ "Test" : ["CMD-SHELL", "curl -f http://localhost:3000/health"], - "Interval" : 10000, - "Timeout" : 10000, - "StartPeriod" : 10000, + "Interval" : 10000000000, + "Timeout" : 10000000000, + "StartPeriod" : 10000000000, "Retries" : 10 }`} className="h-[12rem] font-mono" @@ -407,9 +452,9 @@ export const AddSwarmSettings = ({ id, type }: Props) => { language="json" placeholder={`{ "Condition" : "on-failure", - "Delay" : 10000, + "Delay" : 10000000000, "MaxAttempts" : 10, - "Window" : 10000 + "Window" : 10000000000 } `} className="h-[12rem] font-mono" {...field} @@ -529,9 +574,9 @@ export const AddSwarmSettings = ({ id, type }: Props) => { language="json" placeholder={`{ "Parallelism" : 1, - "Delay" : 10000, + "Delay" : 10000000000, "FailureAction" : "continue", - "Monitor" : 10000, + "Monitor" : 10000000000, "MaxFailureRatio" : 10, "Order" : "start-first" }`} @@ -587,9 +632,9 @@ export const AddSwarmSettings = ({ id, type }: Props) => { language="json" placeholder={`{ "Parallelism" : 1, - "Delay" : 10000, + "Delay" : 10000000000, "FailureAction" : "continue", - "Monitor" : 10000, + "Monitor" : 10000000000, "MaxFailureRatio" : 10, "Order" : "start-first" }`} @@ -774,7 +819,118 @@ export const AddSwarmSettings = ({ id, type }: Props) => { )} /> + ( + + Stop Grace Period (nanoseconds) + + + + + Duration in nanoseconds + + + + + +
+														{`Enter duration in nanoseconds:
+														• 30000000000 - 30 seconds
+														• 120000000000 - 2 minutes  
+														• 3600000000000 - 1 hour
+														• 0 - no grace period`}
+													
+
+
+
+
+ + + field.onChange( + e.target.value ? BigInt(e.target.value) : null, + ) + } + /> + +
+										
+									
+
+ )} + /> + ( + + Endpoint Spec + + + + + Check the interface + + + + + +
+														{`{
+	Mode?: string | undefined;
+	Ports?: Array<{
+		Protocol?: string | undefined;
+		TargetPort?: number | undefined;
+		PublishedPort?: number | undefined;
+		PublishMode?: string | undefined;
+	}> | undefined;
+}`}
+													
+
+
+
+
+ + + +
+										
+									
+
+ )} + /> + + + {fields.length === 0 && ( +

+ No arguments added yet. Click "Add Argument" to add one. +

+ )} + + {fields.map((field, index) => ( + ( + +
+ + + + +
+ +
+ )} + /> + ))} +
+
+ + + + + ); +}; diff --git a/apps/dokploy/components/dashboard/application/advanced/show-resources.tsx b/apps/dokploy/components/dashboard/application/advanced/show-resources.tsx index 25040067b..3beedcdbc 100644 --- a/apps/dokploy/components/dashboard/application/advanced/show-resources.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/show-resources.tsx @@ -150,7 +150,10 @@ export const ShowResources = ({ id, type }: Props) => { render={({ field }) => { return ( -
+
e.preventDefault()} + > Memory Limit @@ -182,7 +185,10 @@ export const ShowResources = ({ id, type }: Props) => { name="memoryReservation" render={({ field }) => ( -
+
e.preventDefault()} + > Memory Reservation @@ -215,7 +221,10 @@ export const ShowResources = ({ id, type }: Props) => { render={({ field }) => { return ( -
+
e.preventDefault()} + > CPU Limit @@ -249,7 +258,10 @@ export const ShowResources = ({ id, type }: Props) => { render={({ field }) => { return ( -
+
e.preventDefault()} + > CPU Reservation diff --git a/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx b/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx index 00be8a1e1..2bfd6bbc0 100644 --- a/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx @@ -59,7 +59,13 @@ const mySchema = z.discriminatedUnion("type", [ z .object({ type: z.literal("volume"), - volumeName: z.string().min(1, "Volume name required"), + volumeName: z + .string() + .min(1, "Volume name required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), }) .merge(mountSchema), z @@ -318,7 +324,7 @@ export const AddVolumes = ({ control={form.control} name="content" render={({ field }) => ( - + Content @@ -327,7 +333,7 @@ export const AddVolumes = ({ placeholder={`NODE_ENV=production PORT=3000 `} - className="h-96 font-mono" + className="h-96 font-mono " {...field} /> diff --git a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx index 38d02ec90..44fb050bc 100644 --- a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx @@ -41,7 +41,13 @@ const mySchema = z.discriminatedUnion("type", [ z .object({ type: z.literal("volume"), - volumeName: z.string().min(1, "Volume name required"), + volumeName: z + .string() + .min(1, "Volume name required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), }) .merge(mountSchema), z diff --git a/apps/dokploy/components/dashboard/application/deployments/kill-build.tsx b/apps/dokploy/components/dashboard/application/deployments/kill-build.tsx new file mode 100644 index 000000000..784534dd6 --- /dev/null +++ b/apps/dokploy/components/dashboard/application/deployments/kill-build.tsx @@ -0,0 +1,65 @@ +import { Scissors } from "lucide-react"; +import { toast } from "sonner"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; +import { Button } from "@/components/ui/button"; +import { api } from "@/utils/api"; + +interface Props { + id: string; + type: "application" | "compose"; +} + +export const KillBuild = ({ id, type }: Props) => { + const { mutateAsync, isLoading } = + type === "application" + ? api.application.killBuild.useMutation() + : api.compose.killBuild.useMutation(); + + return ( + + + + + + + Are you sure to kill the build? + + This will kill the build process + + + + Cancel + { + await mutateAsync({ + applicationId: id || "", + composeId: id || "", + }) + .then(() => { + toast.success("Build killed successfully"); + }) + .catch((err) => { + toast.error(err.message); + }); + }} + > + Confirm + + + + + ); +}; diff --git a/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx b/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx index 69c697721..0d403ecd2 100644 --- a/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx +++ b/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx @@ -1,6 +1,8 @@ -import { Loader2 } from "lucide-react"; +import copy from "copy-to-clipboard"; +import { Check, Copy, Loader2 } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Dialog, @@ -29,9 +31,10 @@ export const ShowDeployment = ({ const [data, setData] = useState(""); const [showExtraLogs, setShowExtraLogs] = useState(false); const [filteredLogs, setFilteredLogs] = useState([]); - const wsRef = useRef(null); // Ref to hold WebSocket instance + const wsRef = useRef(null); const [autoScroll, setAutoScroll] = useState(true); const scrollRef = useRef(null); + const [copied, setCopied] = useState(false); const scrollToBottom = () => { if (autoScroll && scrollRef.current) { @@ -106,6 +109,20 @@ export const ShowDeployment = ({ } }, [filteredLogs, autoScroll]); + const handleCopy = () => { + const logContent = filteredLogs + .map(({ timestamp, message }: LogLine) => + `${timestamp?.toISOString() || ""} ${message}`.trim(), + ) + .join("\n"); + + const success = copy(logContent); + if (success) { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } + }; + const optionalErrors = parseLogs(errorMessage || ""); return ( @@ -128,13 +145,27 @@ export const ShowDeployment = ({ Deployment - + See all the details of this deployment |{" "} {filteredLogs.length} lines + + {serverId && (
>( + new Set(), + ); + + const MAX_DESCRIPTION_LENGTH = 200; + + const truncateDescription = (description: string): string => { + if (description.length <= MAX_DESCRIPTION_LENGTH) { + return description; + } + const truncated = description.slice(0, MAX_DESCRIPTION_LENGTH); + const lastSpace = truncated.lastIndexOf(" "); + if (lastSpace > MAX_DESCRIPTION_LENGTH - 20 && lastSpace > 0) { + return `${truncated.slice(0, lastSpace)}...`; + } + return `${truncated}...`; + }; // Check for stuck deployment (more than 9 minutes) - only for the most recent deployment const stuckDeployment = useMemo(() => { @@ -118,6 +144,9 @@ export const ShowDeployments = ({
+ {(type === "application" || type === "compose") && ( + + )} {(type === "application" || type === "compose") && ( )} @@ -217,122 +246,168 @@ export const ShowDeployments = ({
) : (
- {deployments?.map((deployment, index) => ( -
-
- - {index + 1}. {deployment.status} - - - - {deployment.title} - - {deployment.description && ( - - {deployment.description} + {deployments?.map((deployment, index) => { + const titleText = deployment?.title?.trim() || ""; + const needsTruncation = titleText.length > MAX_DESCRIPTION_LENGTH; + const isExpanded = expandedDescriptions.has( + deployment.deploymentId, + ); + + return ( +
+
+ + {index + 1}. {deployment.status} + - )} -
-
-
- - {deployment.startedAt && deployment.finishedAt && ( - - - {formatDuration( - Math.floor( - (new Date(deployment.finishedAt).getTime() - - new Date(deployment.startedAt).getTime()) / - 1000, - ), - )} - - )} -
-
- {deployment.pid && deployment.status === "running" && ( - { - await killProcess({ - deploymentId: deployment.deploymentId, - }) - .then(() => { - toast.success("Process killed successfully"); - }) - .catch(() => { - toast.error("Error killing process"); - }); - }} - > - - - )} - + {isExpanded ? ( + <> + + Show less + + ) : ( + <> + + Show more + + )} + + )} + {/* Hash (from description) - shown in compact form */} + {deployment.description?.trim() && ( + + {deployment.description} + + )} +
+
+
+
+ + {deployment.startedAt && deployment.finishedAt && ( + + + {formatDuration( + Math.floor( + (new Date(deployment.finishedAt).getTime() - + new Date(deployment.startedAt).getTime()) / + 1000, + ), + )} + + )} +
- {deployment?.rollback && - deployment.status === "done" && - type === "application" && ( +
+ {deployment.pid && deployment.status === "running" && ( { - await rollback({ - rollbackId: deployment.rollback.rollbackId, + await killProcess({ + deploymentId: deployment.deploymentId, }) .then(() => { - toast.success( - "Rollback initiated successfully", - ); + toast.success("Process killed successfully"); }) .catch(() => { - toast.error("Error initiating rollback"); + toast.error("Error killing process"); }); }} > )} + + + {deployment?.rollback && + deployment.status === "done" && + type === "application" && ( + { + await rollback({ + rollbackId: deployment.rollback.rollbackId, + }) + .then(() => { + toast.success( + "Rollback initiated successfully", + ); + }) + .catch(() => { + toast.error("Error initiating rollback"); + }); + }} + > + + + )} +
-
- ))} + ); + })}
)} setActiveLog(null)} logPath={activeLog?.logPath || ""} diff --git a/apps/dokploy/components/dashboard/application/domains/handle-domain.tsx b/apps/dokploy/components/dashboard/application/domains/handle-domain.tsx index 9d7a074f9..bb5366c33 100644 --- a/apps/dokploy/components/dashboard/application/domains/handle-domain.tsx +++ b/apps/dokploy/components/dashboard/application/domains/handle-domain.tsx @@ -46,7 +46,13 @@ export type CacheType = "fetch" | "cache"; export const domain = z .object({ - host: z.string().min(1, { message: "Add a hostname" }), + host: z + .string() + .min(1, { message: "Add a hostname" }) + .refine((val) => val === val.trim(), { + message: "Domain name cannot have leading or trailing spaces", + }) + .transform((val) => val.trim()), path: z.string().min(1).optional(), internalPath: z.string().optional(), stripPath: z.boolean().optional(), @@ -299,6 +305,13 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => { {isError && {error?.message}} + {type === "compose" && ( + + Whenever you make changes to domains, remember to redeploy your + compose to apply the changes. + + )} +
{ }); }; + // Add keyboard shortcut for Ctrl+S/Cmd+S + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading) { + e.preventDefault(); + form.handleSubmit(onSubmit)(); + } + }; + + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("keydown", handleKeyDown); + }; + }, [form, onSubmit, isLoading]); + return (
diff --git a/apps/dokploy/components/dashboard/application/environment/show.tsx b/apps/dokploy/components/dashboard/application/environment/show.tsx index 78edb1aaa..48e978880 100644 --- a/apps/dokploy/components/dashboard/application/environment/show.tsx +++ b/apps/dokploy/components/dashboard/application/environment/show.tsx @@ -12,6 +12,7 @@ import { api } from "@/utils/api"; const addEnvironmentSchema = z.object({ env: z.string(), buildArgs: z.string(), + buildSecrets: z.string(), }); type EnvironmentSchema = z.infer; @@ -37,6 +38,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { defaultValues: { env: "", buildArgs: "", + buildSecrets: "", }, resolver: zodResolver(addEnvironmentSchema), }); @@ -44,15 +46,18 @@ export const ShowEnvironment = ({ applicationId }: Props) => { // Watch form values const currentEnv = form.watch("env"); const currentBuildArgs = form.watch("buildArgs"); + const currentBuildSecrets = form.watch("buildSecrets"); const hasChanges = currentEnv !== (data?.env || "") || - currentBuildArgs !== (data?.buildArgs || ""); + currentBuildArgs !== (data?.buildArgs || "") || + currentBuildSecrets !== (data?.buildSecrets || ""); useEffect(() => { if (data) { form.reset({ env: data.env || "", buildArgs: data.buildArgs || "", + buildSecrets: data.buildSecrets || "", }); } }, [data, form]); @@ -61,6 +66,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { mutateAsync({ env: formData.env, buildArgs: formData.buildArgs, + buildSecrets: formData.buildSecrets, applicationId, }) .then(async () => { @@ -76,9 +82,25 @@ export const ShowEnvironment = ({ applicationId }: Props) => { form.reset({ env: data?.env || "", buildArgs: data?.buildArgs || "", + buildSecrets: data?.buildSecrets || "", }); }; + // Add keyboard shortcut for Ctrl+S/Cmd+S + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading) { + e.preventDefault(); + form.handleSubmit(onSubmit)(); + } + }; + + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("keydown", handleKeyDown); + }; + }, [form, onSubmit, isLoading]); + return ( @@ -104,13 +126,36 @@ export const ShowEnvironment = ({ applicationId }: Props) => { {data?.buildType === "dockerfile" && ( - Available only at build-time. See documentation  + Arguments are available only at build-time. See + documentation  + here + + . + + } + placeholder="NPM_TOKEN=xyz" + /> + )} + {data?.buildType === "dockerfile" && ( + + Secrets are specially designed for sensitive information and + are only available at build-time. See documentation  + diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx index 6f6db5dd1..1f54ddd58 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx @@ -150,7 +150,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => { enableSubmodules: data.enableSubmodules || false, }) .then(async () => { - toast.success("Service Provided Saved"); + toast.success("Service Provider Saved"); await refetch(); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-git-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-git-provider.tsx index 61690e740..e9be3a2f5 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-git-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-git-provider.tsx @@ -59,7 +59,7 @@ export const SaveGitProvider = ({ applicationId }: Props) => { const router = useRouter(); const { mutateAsync, isLoading } = - api.application.saveGitProdiver.useMutation(); + api.application.saveGitProvider.useMutation(); const form = useForm({ defaultValues: { diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx index 9a4b92ce1..80d6850ca 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx @@ -149,7 +149,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => { enableSubmodules: data.enableSubmodules, }) .then(async () => { - toast.success("Service Provided Saved"); + toast.success("Service Provider Saved"); await refetch(); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx index cb7209f8a..d6f65caf3 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx @@ -167,7 +167,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => { enableSubmodules: data.enableSubmodules, }) .then(async () => { - toast.success("Service Provided Saved"); + toast.success("Service Provider Saved"); await refetch(); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx index d93bbd1c8..9c2e48931 100644 --- a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx +++ b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx @@ -182,7 +182,16 @@ export const ShowPreviewDeployments = ({ applicationId }: Props) => { id={deployment.previewDeploymentId} type="previewDeployment" serverId={data?.serverId || ""} - /> + > + + { form.reset({ env: data.previewEnv || "", buildArgs: data.previewBuildArgs || "", + buildSecrets: data.previewBuildSecrets || "", wildcardDomain: data.previewWildcard || "*.traefik.me", port: data.previewPort || 3000, previewLabels: data.previewLabels || [], @@ -127,6 +129,7 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { updateApplication({ previewEnv: formData.env, previewBuildArgs: formData.buildArgs, + previewBuildSecrets: formData.buildSecrets, previewWildcard: formData.wildcardDomain, previewPort: formData.port, previewLabels: formData.previewLabels, @@ -467,13 +470,37 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { {data?.buildType === "dockerfile" && ( - Available only at build-time. See documentation  + Arguments are available only at build-time. See + documentation  + here + + . + + } + placeholder="NPM_TOKEN=xyz" + /> + )} + {data?.buildType === "dockerfile" && ( + + Secrets are specially designed for sensitive information + and are only available at build-time. See + documentation  + diff --git a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx index 3209b6e03..26bfa9421 100644 --- a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx @@ -6,6 +6,7 @@ import { Terminal, Trash2, } from "lucide-react"; +import { useState } from "react"; import { toast } from "sonner"; import { DialogAction } from "@/components/shared/dialog-action"; import { Badge } from "@/components/ui/badge"; @@ -33,6 +34,9 @@ interface Props { } export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { + const [runningSchedules, setRunningSchedules] = useState>( + new Set(), + ); const { data: schedules, isLoading: isLoadingSchedules, @@ -46,14 +50,27 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { enabled: !!id, }, ); - const utils = api.useUtils(); - const { mutateAsync: deleteSchedule, isLoading: isDeleting } = api.schedule.delete.useMutation(); + const { mutateAsync: runManually } = api.schedule.runManually.useMutation(); - const { mutateAsync: runManually, isLoading } = - api.schedule.runManually.useMutation(); + const handleRunManually = async (scheduleId: string) => { + setRunningSchedules((prev) => new Set(prev).add(scheduleId)); + try { + await runManually({ scheduleId }); + toast.success("Schedule run successfully"); + await refetchSchedules(); + } catch { + toast.error("Error running schedule"); + } finally { + setRunningSchedules((prev) => { + const newSet = new Set(prev); + newSet.delete(scheduleId); + return newSet; + }); + } + }; return ( @@ -67,7 +84,6 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { Schedule tasks to run automatically at specified intervals.
- {schedules && schedules.length > 0 && ( )} @@ -75,7 +91,7 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { {isLoadingSchedules ? ( -
+
Loading scheduled tasks... @@ -91,13 +107,13 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { return (
-
+
-
+

{schedule.name} @@ -132,16 +148,15 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { )}

{schedule.command && ( -
- - +
+ + {schedule.command}
)}
-
{ serverId={serverId || undefined} > - @@ -160,37 +174,26 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => { type="button" variant="ghost" size="icon" - isLoading={isLoading} - onClick={async () => { - toast.success("Schedule run successfully"); - - await runManually({ - scheduleId: schedule.scheduleId, - }) - .then(async () => { - await new Promise((resolve) => - setTimeout(resolve, 1500), - ); - refetchSchedules(); - }) - .catch(() => { - toast.error("Error running schedule"); - }); - }} + disabled={runningSchedules.has(schedule.scheduleId)} + onClick={() => + handleRunManually(schedule.scheduleId) + } > - + {runningSchedules.has(schedule.scheduleId) ? ( + + ) : ( + + )} Run Manual Schedule - - { diff --git a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx index 804b4c39b..e179713de 100644 --- a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx +++ b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx @@ -47,7 +47,13 @@ const formSchema = z .object({ name: z.string().min(1, "Name is required"), cronExpression: z.string().min(1, "Cron expression is required"), - volumeName: z.string().min(1, "Volume name is required"), + volumeName: z + .string() + .min(1, "Volume name is required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), prefix: z.string(), keepLatestCount: z.coerce .number() diff --git a/apps/dokploy/components/dashboard/application/volume-backups/show-volume-backups.tsx b/apps/dokploy/components/dashboard/application/volume-backups/show-volume-backups.tsx index c88dd92f5..2e4dac472 100644 --- a/apps/dokploy/components/dashboard/application/volume-backups/show-volume-backups.tsx +++ b/apps/dokploy/components/dashboard/application/volume-backups/show-volume-backups.tsx @@ -5,6 +5,7 @@ import { Play, Trash2, } from "lucide-react"; +import { useState } from "react"; import { toast } from "sonner"; import { DialogAction } from "@/components/shared/dialog-action"; import { Badge } from "@/components/ui/badge"; @@ -38,6 +39,7 @@ export const ShowVolumeBackups = ({ type = "application", serverId, }: Props) => { + const [runningBackups, setRunningBackups] = useState>(new Set()); const { data: volumeBackups, isLoading: isLoadingVolumeBackups, @@ -51,34 +53,46 @@ export const ShowVolumeBackups = ({ enabled: !!id, }, ); - const utils = api.useUtils(); - const { mutateAsync: deleteVolumeBackup, isLoading: isDeleting } = api.volumeBackups.delete.useMutation(); - - const { mutateAsync: runManually, isLoading } = + const { mutateAsync: runManually } = api.volumeBackups.runManually.useMutation(); + const handleRunManually = async (volumeBackupId: string) => { + setRunningBackups((prev) => new Set(prev).add(volumeBackupId)); + try { + await runManually({ volumeBackupId }); + toast.success("Volume backup run successfully"); + await refetchVolumeBackups(); + } catch { + toast.error("Error running volume backup"); + } finally { + setRunningBackups((prev) => { + const newSet = new Set(prev); + newSet.delete(volumeBackupId); + return newSet; + }); + } + }; + return ( -
+
Volume Backups Schedule volume backups to run automatically at specified - intervals. + intervals
- -
+
{volumeBackups && volumeBackups.length > 0 && ( <> -
{isLoadingVolumeBackups ? ( -
+
Loading volume backups... @@ -113,13 +127,13 @@ export const ShowVolumeBackups = ({ return (
-
+
-
+

{volumeBackup.name} @@ -143,18 +157,16 @@ export const ShowVolumeBackups = ({

- -
+
- @@ -162,25 +174,18 @@ export const ShowVolumeBackups = ({ type="button" variant="ghost" size="icon" - isLoading={isLoading} - onClick={async () => { - toast.success("Volume backup run successfully"); - - await runManually({ - volumeBackupId: volumeBackup.volumeBackupId, - }) - .then(async () => { - await new Promise((resolve) => - setTimeout(resolve, 1500), - ); - refetchVolumeBackups(); - }) - .catch(() => { - toast.error("Error running volume backup"); - }); - }} + disabled={runningBackups.has( + volumeBackup.volumeBackupId, + )} + onClick={() => + handleRunManually(volumeBackup.volumeBackupId) + } > - + {runningBackups.has(volumeBackup.volumeBackupId) ? ( + + ) : ( + + )} @@ -188,13 +193,11 @@ export const ShowVolumeBackups = ({ - - @@ -230,7 +233,7 @@ export const ShowVolumeBackups = ({ })}
) : ( -
+

No volume backups diff --git a/apps/dokploy/components/dashboard/compose/delete-service.tsx b/apps/dokploy/components/dashboard/compose/delete-service.tsx index e75aad5e5..5c8577dff 100644 --- a/apps/dokploy/components/dashboard/compose/delete-service.tsx +++ b/apps/dokploy/components/dashboard/compose/delete-service.tsx @@ -104,7 +104,7 @@ export const DeleteService = ({ id, type }: Props) => { push( `/dashboard/project/${result?.environment?.projectId}/environment/${result?.environment?.environmentId}`, ); - toast.success("deleted successfully"); + toast.success("Service deleted successfully"); setIsOpen(false); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/compose/general/actions.tsx b/apps/dokploy/components/dashboard/compose/general/actions.tsx index 870444be7..1bbeb880e 100644 --- a/apps/dokploy/components/dashboard/compose/general/actions.tsx +++ b/apps/dokploy/components/dashboard/compose/general/actions.tsx @@ -195,6 +195,7 @@ export const ComposeActions = ({ composeId }: Props) => { + +

+ + {fields.length === 0 && ( +

+ No arguments added yet. Click "Add Argument" to add one. +

+ )} + + {fields.map((field, index) => ( + ( + +
+ + + + +
+ +
+ )} + /> + ))} +
+
- + */} {environment.name !== "production" && (
- + {canDeleteEnvironments && ( + + )}
)}
@@ -285,13 +294,15 @@ export const AdvancedEnvironmentSelector = ({ })} - setIsCreateDialogOpen(true)} - > - - Create Environment - + {canCreateEnvironments && ( + setIsCreateDialogOpen(true)} + > + + Create Environment + + )} diff --git a/apps/dokploy/components/dashboard/project/environment-variables.tsx b/apps/dokploy/components/dashboard/project/environment-variables.tsx index 8cafc8073..e833fa779 100644 --- a/apps/dokploy/components/dashboard/project/environment-variables.tsx +++ b/apps/dokploy/components/dashboard/project/environment-variables.tsx @@ -82,6 +82,21 @@ export const EnvironmentVariables = ({ environmentId, children }: Props) => { .finally(() => {}); }; + // Add keyboard shortcut for Ctrl+S/Cmd+S + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading && isOpen) { + e.preventDefault(); + form.handleSubmit(onSubmit)(); + } + }; + + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("keydown", handleKeyDown); + }; + }, [form, onSubmit, isLoading, isOpen]); + return ( diff --git a/apps/dokploy/components/dashboard/projects/project-environment.tsx b/apps/dokploy/components/dashboard/projects/project-environment.tsx index 86dfd2433..cb6245f08 100644 --- a/apps/dokploy/components/dashboard/projects/project-environment.tsx +++ b/apps/dokploy/components/dashboard/projects/project-environment.tsx @@ -81,6 +81,21 @@ export const ProjectEnvironment = ({ projectId, children }: Props) => { .finally(() => {}); }; + // Add keyboard shortcut for Ctrl+S/Cmd+S + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading && isOpen) { + e.preventDefault(); + form.handleSubmit(onSubmit)(); + } + }; + + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("keydown", handleKeyDown); + }; + }, [form, onSubmit, isLoading, isOpen]); + return ( diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index 783c5bb32..e5411690e 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -14,6 +14,7 @@ import { useEffect, useMemo, useState } from "react"; import { toast } from "sonner"; import { BreadcrumbSidebar } from "@/components/shared/breadcrumb-sidebar"; import { DateTooltip } from "@/components/shared/date-tooltip"; +import { FocusShortcutInput } from "@/components/shared/focus-shortcut-input"; import { StatusTooltip } from "@/components/shared/status-tooltip"; import { AlertDialog, @@ -44,7 +45,6 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { FocusShortcutInput } from "@/components/shared/focus-shortcut-input"; import { Select, SelectContent, @@ -52,12 +52,14 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { TimeBadge } from "@/components/ui/time-badge"; import { api } from "@/utils/api"; import { HandleProject } from "./handle-project"; import { ProjectEnvironment } from "./project-environment"; export const ShowProjects = () => { const utils = api.useUtils(); + const { data: isCloud } = api.settings.isCloud.useQuery(); const { data, isLoading } = api.project.all.useQuery(); const { data: auth } = api.user.get.useQuery(); const { mutateAsync } = api.project.remove.useMutation(); @@ -135,6 +137,11 @@ export const ShowProjects = () => { + {!isCloud && ( +
+ +
+ )}
@@ -148,7 +155,6 @@ export const ShowProjects = () => { Create and manage your projects - {(auth?.role === "owner" || auth?.canCreateProjects) && (
@@ -298,7 +304,13 @@ export const ShowProjects = () => { {domain.host} @@ -340,7 +352,13 @@ export const ShowProjects = () => { {domain.host} diff --git a/apps/dokploy/components/dashboard/requests/request-distribution-chart.tsx b/apps/dokploy/components/dashboard/requests/request-distribution-chart.tsx index 2a5db2a94..c760c8175 100644 --- a/apps/dokploy/components/dashboard/requests/request-distribution-chart.tsx +++ b/apps/dokploy/components/dashboard/requests/request-distribution-chart.tsx @@ -49,51 +49,65 @@ export const RequestDistributionChart = ({ ); return ( - - - - - - new Date(value).toLocaleTimeString([], { - hour: "2-digit", - minute: "2-digit", - }) - } - /> - - } - labelFormatter={(value) => - new Date(value).toLocaleString([], { - month: "short", - day: "numeric", - hour: "2-digit", - minute: "2-digit", - }) - } - /> - - - - +
+ + + + + + new Date(value).toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + }) + } + /> + + } + labelFormatter={(value) => + new Date(value).toLocaleString([], { + month: "short", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + }) + } + /> + + + + +
); }; diff --git a/apps/dokploy/components/dashboard/requests/show-requests.tsx b/apps/dokploy/components/dashboard/requests/show-requests.tsx index ab602f463..3b5315c3e 100644 --- a/apps/dokploy/components/dashboard/requests/show-requests.tsx +++ b/apps/dokploy/components/dashboard/requests/show-requests.tsx @@ -51,13 +51,19 @@ export const ShowRequests = () => { const { mutateAsync: updateLogCleanup } = api.settings.updateLogCleanup.useMutation(); const [cronExpression, setCronExpression] = useState(null); + + // Set default date range to last 3 days + const getDefaultDateRange = () => { + const to = new Date(); + const from = new Date(); + from.setDate(from.getDate() - 3); + return { from, to }; + }; + const [dateRange, setDateRange] = useState<{ from: Date | undefined; to: Date | undefined; - }>({ - from: undefined, - to: undefined, - }); + }>(getDefaultDateRange()); useEffect(() => { if (logCleanupStatus) { @@ -169,17 +175,13 @@ export const ShowRequests = () => { {isActive ? ( <>
- {(dateRange.from || dateRange.to) && ( - - )} +
@@ -1150,54 +1210,67 @@ export const HandleNotifications = ({ notificationId }: Props) => { isLoadingDiscord || isLoadingEmail || isLoadingGotify || - isLoadingNtfy + isLoadingNtfy || + isLoadingLark } variant="secondary" + type="button" onClick={async () => { + const isValid = await form.trigger(); + if (!isValid) return; + + const data = form.getValues(); + try { - if (type === "slack") { + if (data.type === "slack") { await testSlackConnection({ - webhookUrl: form.getValues("webhookUrl"), - channel: form.getValues("channel"), + webhookUrl: data.webhookUrl, + channel: data.channel, }); - } else if (type === "telegram") { + } else if (data.type === "telegram") { await testTelegramConnection({ - botToken: form.getValues("botToken"), - chatId: form.getValues("chatId"), - messageThreadId: form.getValues("messageThreadId") || "", + botToken: data.botToken, + chatId: data.chatId, + messageThreadId: data.messageThreadId || "", }); - } else if (type === "discord") { + } else if (data.type === "discord") { await testDiscordConnection({ - webhookUrl: form.getValues("webhookUrl"), - decoration: form.getValues("decoration"), + webhookUrl: data.webhookUrl, + decoration: data.decoration, }); - } else if (type === "email") { + } else if (data.type === "email") { await testEmailConnection({ - smtpServer: form.getValues("smtpServer"), - smtpPort: form.getValues("smtpPort"), - username: form.getValues("username"), - password: form.getValues("password"), - toAddresses: form.getValues("toAddresses"), - fromAddress: form.getValues("fromAddress"), + smtpServer: data.smtpServer, + smtpPort: data.smtpPort, + username: data.username, + password: data.password, + fromAddress: data.fromAddress, + toAddresses: data.toAddresses, }); - } else if (type === "gotify") { + } else if (data.type === "gotify") { await testGotifyConnection({ - serverUrl: form.getValues("serverUrl"), - appToken: form.getValues("appToken"), - priority: form.getValues("priority"), - decoration: form.getValues("decoration"), + serverUrl: data.serverUrl, + appToken: data.appToken, + priority: data.priority, + decoration: data.decoration, }); - } else if (type === "ntfy") { + } else if (data.type === "ntfy") { await testNtfyConnection({ - serverUrl: form.getValues("serverUrl"), - topic: form.getValues("topic"), - accessToken: form.getValues("accessToken"), - priority: form.getValues("priority"), + serverUrl: data.serverUrl, + topic: data.topic, + accessToken: data.accessToken, + priority: data.priority, + }); + } else if (data.type === "lark") { + await testLarkConnection({ + webhookUrl: data.webhookUrl, }); } toast.success("Connection Success"); - } catch { - toast.error("Error testing the provider"); + } catch (error) { + toast.error( + `Error testing the provider: ${error instanceof Error ? error.message : "Unknown error"}`, + ); } }} > diff --git a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx index fe31acc4c..5b7a2220e 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx @@ -1,7 +1,10 @@ -import { Bell, Loader2, Mail, MessageCircleMore, Trash2 } from "lucide-react"; +import { Bell, Loader2, Mail, Trash2 } from "lucide-react"; import { toast } from "sonner"; import { DiscordIcon, + GotifyIcon, + LarkIcon, + NtfyIcon, SlackIcon, TelegramIcon, } from "@/components/icons/notification-icons"; @@ -33,7 +36,7 @@ export const ShowNotifications = () => { Add your providers to receive notifications, like Discord, Slack, - Telegram, Email. + Telegram, Email, Lark. @@ -85,12 +88,17 @@ export const ShowNotifications = () => { )} {notification.notificationType === "gotify" && (
- +
)} {notification.notificationType === "ntfy" && (
- + +
+ )} + {notification.notificationType === "lark" && ( +
+
)} diff --git a/apps/dokploy/components/dashboard/settings/profile/configure-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/configure-2fa.tsx new file mode 100644 index 000000000..17220cd11 --- /dev/null +++ b/apps/dokploy/components/dashboard/settings/profile/configure-2fa.tsx @@ -0,0 +1,429 @@ +import { zodResolver } from "@hookform/resolvers/zod"; +import copy from "copy-to-clipboard"; +import { + CopyIcon, + DownloadIcon, + KeyRound, + RefreshCw, + ShieldOff, +} from "lucide-react"; +import { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import { toast } from "sonner"; +import { z } from "zod"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { authClient } from "@/lib/auth-client"; +import { api } from "@/utils/api"; +import { + BACKUP_CODES_PLACEHOLDER, + backupCodeTemplate, + DATE_PLACEHOLDER, + USERNAME_PLACEHOLDER, +} from "./enable-2fa"; + +const PasswordSchema = z.object({ + password: z.string().min(8, { + message: "Password is required", + }), +}); + +type PasswordForm = z.infer; +type Step = "password" | "actions" | "backup-codes"; + +export const Configure2FA = () => { + const utils = api.useUtils(); + const { data: currentUser } = api.user.get.useQuery(); + const [isDialogOpen, setIsDialogOpen] = useState(false); + const [step, setStep] = useState("password"); + const [password, setPassword] = useState(""); + const [backupCodes, setBackupCodes] = useState([]); + const [showDisableConfirm, setShowDisableConfirm] = useState(false); + const [isDisabling, setIsDisabling] = useState(false); + const [isRegenerating, setIsRegenerating] = useState(false); + + const form = useForm({ + resolver: zodResolver(PasswordSchema), + defaultValues: { + password: "", + }, + }); + + useEffect(() => { + if (!isDialogOpen) { + setStep("password"); + setPassword(""); + setBackupCodes([]); + form.reset(); + } + }, [isDialogOpen, form]); + + const handlePasswordSubmit = async (formData: PasswordForm) => { + setIsRegenerating(true); + try { + // Verify password by attempting to generate backup codes + // This validates the password and checks if 2FA is enabled + const result = await authClient.twoFactor.generateBackupCodes({ + password: formData.password, + }); + + if (result.error) { + form.setError("password", { message: result.error.message }); + toast.error(result.error.message); + return; + } + + // If we get here, password is correct + setPassword(formData.password); + setStep("actions"); + } catch (error) { + form.setError("password", { + message: error instanceof Error ? error.message : "Incorrect password", + }); + toast.error("Incorrect password"); + } finally { + setIsRegenerating(false); + } + }; + + const handleRegenerateBackupCodes = async () => { + setIsRegenerating(true); + try { + const result = await authClient.twoFactor.generateBackupCodes({ + password, + }); + + if (result.error) { + toast.error(result.error.message); + return; + } + + if (result.data?.backupCodes) { + setBackupCodes(result.data.backupCodes); + setStep("backup-codes"); + toast.success("Backup codes regenerated successfully"); + } + } catch (error) { + toast.error( + error instanceof Error + ? error.message + : "Failed to regenerate backup codes", + ); + } finally { + setIsRegenerating(false); + } + }; + + const handleDisable2FA = async () => { + setIsDisabling(true); + try { + const result = await authClient.twoFactor.disable({ + password, + }); + + if (result.error) { + toast.error(result.error.message); + return; + } + + toast.success("2FA disabled successfully"); + utils.user.get.invalidate(); + setIsDialogOpen(false); + setShowDisableConfirm(false); + } catch (error) { + toast.error("Failed to disable 2FA. Please try again."); + } finally { + setIsDisabling(false); + } + }; + + const handleCloseDialog = () => { + if (step === "backup-codes") { + setStep("actions"); + } else { + setIsDialogOpen(false); + } + }; + + const handleDownloadBackupCodes = () => { + if (!backupCodes || backupCodes.length === 0) { + toast.error("No backup codes to download."); + return; + } + + const backupCodesFormatted = backupCodes + .map((code, index) => ` ${index + 1}. ${code}`) + .join("\n"); + + const date = new Date(); + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + const filename = `dokploy-2fa-backup-codes-${year}${month}${day}.txt`; + + const backupCodesText = backupCodeTemplate + .replace(USERNAME_PLACEHOLDER, currentUser?.user?.email || "unknown") + .replace(DATE_PLACEHOLDER, date.toLocaleString()) + .replace(BACKUP_CODES_PLACEHOLDER, backupCodesFormatted); + + const blob = new Blob([backupCodesText], { type: "text/plain" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }; + + const handleCopyBackupCodes = () => { + const date = new Date(); + + const backupCodesFormatted = backupCodes + .map((code, index) => ` ${index + 1}. ${code}`) + .join("\n"); + + const backupCodesText = backupCodeTemplate + .replace(USERNAME_PLACEHOLDER, currentUser?.user?.email || "unknown") + .replace(DATE_PLACEHOLDER, date.toLocaleString()) + .replace(BACKUP_CODES_PLACEHOLDER, backupCodesFormatted); + + copy(backupCodesText); + toast.success("Backup codes copied to clipboard"); + }; + + return ( + <> + + + + + + + + {step === "password" && "Verify Your Identity"} + {step === "actions" && "2FA Configuration"} + {step === "backup-codes" && "New Backup Codes"} + + + {step === "password" && + "Enter your password to manage your 2FA settings"} + {step === "actions" && + "Choose an action to manage your two-factor authentication"} + {step === "backup-codes" && + "Save these backup codes in a secure place"} + + + + {step === "password" && ( + + + ( + + Password + + + + + Enter your password to continue + + + + )} + /> +
+ + +
+ + + )} + + {step === "actions" && ( +
+
+
+
+
+

+ + Regenerate Backup Codes +

+

+ Generate new backup codes to replace your existing ones. + This will invalidate all previous backup codes. +

+
+
+ +
+ +
+
+
+

+ + Disable 2FA +

+

+ Completely disable two-factor authentication for your + account. This will make your account less secure. +

+
+
+ +
+
+ +
+ +
+
+ )} + + {step === "backup-codes" && ( +
+
+
+ {backupCodes.map((code, index) => ( + + {code} + + ))} +
+

+ Save these backup codes in a secure place. You can use them to + access your account if you lose access to your authenticator + device. Each code can only be used once. +

+
+ +
+ + +
+ +
+ + +
+
+ )} +
+
+ + + + + Are you absolutely sure? + + This will permanently disable Two-Factor Authentication for your + account. Your account will be less secure without 2FA enabled. + + + + Cancel + + {isDisabling ? "Disabling..." : "Disable 2FA"} + + + + + + ); +}; diff --git a/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx deleted file mode 100644 index 4055d4079..000000000 --- a/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import { zodResolver } from "@hookform/resolvers/zod"; -import { useState } from "react"; -import { useForm } from "react-hook-form"; -import { toast } from "sonner"; -import { z } from "zod"; -import { - AlertDialog, - AlertDialogContent, - AlertDialogDescription, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog"; -import { Button } from "@/components/ui/button"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { authClient } from "@/lib/auth-client"; -import { api } from "@/utils/api"; - -const PasswordSchema = z.object({ - password: z.string().min(8, { - message: "Password is required", - }), -}); - -type PasswordForm = z.infer; - -export const Disable2FA = () => { - const utils = api.useUtils(); - const [isOpen, setIsOpen] = useState(false); - const [isLoading, setIsLoading] = useState(false); - - const form = useForm({ - resolver: zodResolver(PasswordSchema), - defaultValues: { - password: "", - }, - }); - - const handleSubmit = async (formData: PasswordForm) => { - setIsLoading(true); - try { - const result = await authClient.twoFactor.disable({ - password: formData.password, - }); - - if (result.error) { - form.setError("password", { - message: result.error.message, - }); - toast.error(result.error.message); - return; - } - - toast.success("2FA disabled successfully"); - utils.user.get.invalidate(); - setIsOpen(false); - } catch { - form.setError("password", { - message: "Connection error. Please try again.", - }); - toast.error("Connection error. Please try again."); - } finally { - setIsLoading(false); - } - }; - - return ( - - - - - - - Are you absolutely sure? - - This action cannot be undone. This will permanently disable - Two-Factor Authentication for your account. - - - -
- - ( - - Password - - - - - Enter your password to disable 2FA - - - - )} - /> -
- - -
- - -
-
- ); -}; diff --git a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx index e630ec4f8..656b27401 100644 --- a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx +++ b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx @@ -1,5 +1,6 @@ import { zodResolver } from "@hookform/resolvers/zod"; -import { Fingerprint, QrCode } from "lucide-react"; +import copy from "copy-to-clipboard"; +import { CopyIcon, DownloadIcon, Fingerprint, QrCode } from "lucide-react"; import QRCode from "qrcode"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; @@ -29,6 +30,12 @@ import { InputOTPGroup, InputOTPSlot, } from "@/components/ui/input-otp"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { authClient } from "@/lib/auth-client"; import { api } from "@/utils/api"; @@ -54,6 +61,26 @@ type TwoFactorSetupData = { type PasswordForm = z.infer; type PinForm = z.infer; +export const USERNAME_PLACEHOLDER = "%username%"; +export const DATE_PLACEHOLDER = "%date%"; +export const BACKUP_CODES_PLACEHOLDER = "%backupCodes%"; + +export const backupCodeTemplate = `Dokploy - BACKUP VERIFICATION CODES + +Points to note +-------------- +# Each code can be used only once. +# Do not share these codes with anyone. + +Generated codes +--------------- +Username: ${USERNAME_PLACEHOLDER} +Generated on: ${DATE_PLACEHOLDER} + + +${BACKUP_CODES_PLACEHOLDER} +`; + export const Enable2FA = () => { const utils = api.useUtils(); const [data, setData] = useState(null); @@ -62,6 +89,7 @@ export const Enable2FA = () => { const [step, setStep] = useState<"password" | "verify">("password"); const [isPasswordLoading, setIsPasswordLoading] = useState(false); const [otpValue, setOtpValue] = useState(""); + const { data: currentUser } = api.user.get.useQuery(); const handleVerifySubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -178,6 +206,54 @@ export const Enable2FA = () => { } }; + const handleDownloadBackupCodes = () => { + if (!backupCodes || backupCodes.length === 0) { + toast.error("No backup codes to download."); + return; + } + + const backupCodesFormatted = backupCodes + .map((code, index) => ` ${index + 1}. ${code}`) + .join("\n"); + + const date = new Date(); + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + const filename = `dokploy-2fa-backup-codes-${year}${month}${day}.txt`; + + const backupCodesText = backupCodeTemplate + .replace(USERNAME_PLACEHOLDER, currentUser?.user?.email || "unknown") + .replace(DATE_PLACEHOLDER, date.toLocaleString()) + .replace(BACKUP_CODES_PLACEHOLDER, backupCodesFormatted); + + const blob = new Blob([backupCodesText], { type: "text/plain" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }; + + const handleCopyBackupCodes = () => { + const date = new Date(); + + const backupCodesFormatted = backupCodes + .map((code, index) => ` ${index + 1}. ${code}`) + .join("\n"); + + const backupCodesText = backupCodeTemplate + .replace(USERNAME_PLACEHOLDER, currentUser?.user?.email || "unknown") + .replace(DATE_PLACEHOLDER, date.toLocaleString()) + .replace(BACKUP_CODES_PLACEHOLDER, backupCodesFormatted); + + copy(backupCodesText); + toast.success("Backup codes copied to clipboard"); + }; + return ( @@ -264,6 +340,7 @@ export const Enable2FA = () => { Scan this QR code with your authenticator app + {/** biome-ignore lint/performance/noImgElement: This is a valid use case for an img element */} 2FA QR Code { {backupCodes && backupCodes.length > 0 && (
-

Backup Codes

+
+

Backup Codes

+
+ + + + + + +

Copy

+
+
+
+ + + + + + + +

Download

+
+
+
+
+
{backupCodes.map((code, index) => ( { - const _utils = api.useUtils(); const { data, refetch, isLoading } = api.user.get.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -120,28 +119,27 @@ export const ProfileForm = () => { }, [form, data]); const onSubmit = async (values: Profile) => { - await mutateAsync({ - email: values.email.toLowerCase(), - password: values.password || undefined, - image: values.image, - currentPassword: values.currentPassword || undefined, - allowImpersonation: values.allowImpersonation, - name: values.name || undefined, - }) - .then(async () => { - await refetch(); - toast.success("Profile Updated"); - form.reset({ - email: values.email, - password: "", - image: values.image, - currentPassword: "", - name: values.name || "", - }); - }) - .catch(() => { - toast.error("Error updating the profile"); + try { + await mutateAsync({ + email: values.email.toLowerCase(), + password: values.password || undefined, + image: values.image, + currentPassword: values.currentPassword || undefined, + allowImpersonation: values.allowImpersonation, + name: values.name || undefined, }); + await refetch(); + toast.success("Profile Updated"); + form.reset({ + email: values.email, + password: "", + image: values.image, + currentPassword: "", + name: values.name || "", + }); + } catch (error) { + toast.error("Error updating the profile"); + } }; return ( @@ -158,7 +156,8 @@ export const ProfileForm = () => { {t("settings.profile.description")}
- {!data?.user.twoFactorEnabled ? : } + + {!data?.user.twoFactorEnabled ? : } @@ -257,8 +256,16 @@ export const ProfileForm = () => { onValueChange={(e) => { field.onChange(e); }} - defaultValue={field.value} - value={field.value} + defaultValue={ + field.value?.startsWith("data:") + ? "upload" + : field.value + } + value={ + field.value?.startsWith("data:") + ? "upload" + : field.value + } className="flex flex-row flex-wrap gap-2 max-xl:justify-center" > @@ -279,6 +286,72 @@ export const ProfileForm = () => { + + + + + +
+ document + .getElementById("avatar-upload") + ?.click() + } + > + {field.value?.startsWith("data:") ? ( + // biome-ignore lint/performance/noImgElement: this is an justified use of img element + Custom avatar + ) : ( + + + + )} +
+ { + const file = e.target.files?.[0]; + if (file) { + // max file size 2mb + if (file.size > 2 * 1024 * 1024) { + toast.error( + "Image size must be less than 2MB", + ); + return; + } + const reader = new FileReader(); + reader.onload = (event) => { + const result = event.target + ?.result as string; + field.onChange(result); + }; + reader.readAsDataURL(file); + } + }} + /> +
+
{availableAvatars.map((image) => ( @@ -289,6 +362,7 @@ export const ProfileForm = () => { /> + {/* biome-ignore lint/performance/noImgElement: this is an justified use of img element */} ; @@ -89,6 +90,7 @@ export const HandleServers = ({ serverId }: Props) => { port: 22, username: "root", sshKeyId: "", + serverType: "deploy", }, resolver: zodResolver(Schema), }); @@ -101,6 +103,7 @@ export const HandleServers = ({ serverId }: Props) => { port: data?.port || 22, username: data?.username || "root", sshKeyId: data?.sshKeyId || "", + serverType: data?.serverType || "deploy", }); }, [form, form.reset, form.formState.isSubmitSuccessful, data]); @@ -116,6 +119,7 @@ export const HandleServers = ({ serverId }: Props) => { port: data.port || 22, username: data.username || "root", sshKeyId: data.sshKeyId || "", + serverType: data.serverType || "deploy", serverId: serverId || "", }) .then(async (_data) => { @@ -266,6 +270,50 @@ export const HandleServers = ({ serverId }: Props) => { )} /> + { + const serverTypeValue = form.watch("serverType"); + return ( + + Server Type + + + {serverTypeValue === "deploy" && ( + + Deploy servers are used to run your applications, + databases, and services. They handle the deployment and + execution of your projects. + + )} + {serverTypeValue === "build" && ( + + Build servers are dedicated to building your + applications. They handle the compilation and build + process, offloading this work from your deployment + servers. Build servers won't appear in deployment + options. + + )} + + ); + }} + /> { const [activeLog, setActiveLog] = useState(null); const { data: isCloud } = api.settings.isCloud.useQuery(); + const isBuildServer = server?.serverType === "build"; const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [filteredLogs, setFilteredLogs] = useState([]); const [isDeploying, setIsDeploying] = useState(false); @@ -117,17 +118,26 @@ export const SetupServer = ({ serverId }: Props) => { SSH Keys Deployments Validate - Security - {isCloud && ( - Monitoring + + {!isBuildServer && ( + <> + Security + {isCloud && ( + Monitoring + )} + GPU Setup + )} - GPU Setup {
- -
- -
-
- -
-
- -
-
-
- -
- -
-
+ {!isBuildServer && ( + <> + +
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+ + )}
)} diff --git a/apps/dokploy/components/dashboard/settings/servers/show-servers.tsx b/apps/dokploy/components/dashboard/settings/servers/show-servers.tsx index 191aab9ce..2f8ac24e2 100644 --- a/apps/dokploy/components/dashboard/settings/servers/show-servers.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/show-servers.tsx @@ -129,6 +129,9 @@ export const ShowServers = () => { Status )} + + Type + IP Address @@ -153,6 +156,8 @@ export const ShowServers = () => { {data?.map((server) => { const canDelete = server.totalSum === 0; const isActive = server.serverStatus === "active"; + const isBuildServer = + server.serverType === "build"; return ( @@ -171,6 +176,15 @@ export const ShowServers = () => { )} + + + {server.serverType} + + {server.ipAddress} @@ -233,11 +247,12 @@ export const ShowServers = () => { serverId={server.serverId} /> - {server.sshKeyId && ( - - )} + {server.sshKeyId && + !isBuildServer && ( + + )} )} @@ -286,41 +301,43 @@ export const ShowServers = () => { - {isActive && server.sshKeyId && ( - <> - - - Extra - + {isActive && + server.sshKeyId && + !isBuildServer && ( + <> + + + Extra + - - - {isCloud && ( - - )} + + {isCloud && ( + + )} - - + + - - - )} + + + )} diff --git a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx index c09753f3e..5aaf154fd 100644 --- a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx @@ -25,6 +25,13 @@ export const ValidateServer = ({ serverId }: Props) => { enabled: !!serverId, }, ); + const { data: server } = api.server.one.useQuery( + { serverId }, + { + enabled: !!serverId, + }, + ); + const isBuildServer = server?.serverType === "build"; const _utils = api.useUtils(); return ( @@ -73,7 +80,9 @@ export const ValidateServer = ({ serverId }: Props) => {

Status

- Shows the server configuration status + {isBuildServer + ? "Shows the build server configuration status" + : "Shows the server configuration status"}

{ : undefined } /> - + {!isBuildServer && ( + + )} { } /> - + {!isBuildServer && ( + <> + + + + )} { : "Not Created" } /> -
diff --git a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx index 0141aca08..1f463a18f 100644 --- a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx @@ -95,6 +95,7 @@ export const CreateServer = ({ stepper }: Props) => { port: data.port || 22, username: data.username || "root", sshKeyId: data.sshKeyId || "", + serverType: "deploy", }) .then(async (_data) => { toast.success("Server Created"); diff --git a/apps/dokploy/components/dashboard/settings/users/add-permissions.tsx b/apps/dokploy/components/dashboard/settings/users/add-permissions.tsx index a918da98f..7c6ef8b84 100644 --- a/apps/dokploy/components/dashboard/settings/users/add-permissions.tsx +++ b/apps/dokploy/components/dashboard/settings/users/add-permissions.tsx @@ -1,6 +1,5 @@ -import type { findEnvironmentById } from "@dokploy/server/index"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; @@ -27,12 +26,10 @@ import { FormMessage, } from "@/components/ui/form"; import { Switch } from "@/components/ui/switch"; -import { api } from "@/utils/api"; +import { api, type RouterOutputs } from "@/utils/api"; -type Environment = Omit< - Awaited>, - "project" ->; +type Project = RouterOutputs["project"]["all"][number]; +type Environment = Project["environments"][number]; export type Services = { appName: string; @@ -53,17 +50,16 @@ export type Services = { }; export const extractServices = (data: Environment | undefined) => { - const applications: Services[] = - data?.applications.map((item) => ({ - appName: item.appName, - name: item.name, - type: "application", - id: item.applicationId, - createdAt: item.createdAt, - status: item.applicationStatus, - description: item.description, - serverId: item.serverId, - })) || []; + const applications: Services[] = (data?.applications?.map((item) => ({ + appName: item.appName, + name: item.name, + type: "application", + id: item.applicationId, + createdAt: item.createdAt, + status: item.applicationStatus, + description: item.description, + serverId: item.serverId, + })) ?? []) as Services[]; const mariadb: Services[] = data?.mariadb.map((item) => ({ @@ -125,17 +121,16 @@ export const extractServices = (data: Environment | undefined) => { serverId: item.serverId, })) || []; - const compose: Services[] = - data?.compose.map((item) => ({ - appName: item.appName, - name: item.name, - type: "compose", - id: item.composeId, - createdAt: item.createdAt, - status: item.composeStatus, - description: item.description, - serverId: item.serverId, - })) || []; + const compose: Services[] = (data?.compose?.map((item) => ({ + appName: item.appName, + name: item.name, + type: "compose", + id: item.composeId, + createdAt: item.createdAt, + status: item.composeStatus, + description: item.description, + serverId: item.serverId, + })) ?? []) as Services[]; applications.push( ...mysql, @@ -161,11 +156,13 @@ const addPermissions = z.object({ canCreateServices: z.boolean().optional().default(false), canDeleteProjects: z.boolean().optional().default(false), canDeleteServices: z.boolean().optional().default(false), + canDeleteEnvironments: z.boolean().optional().default(false), canAccessToTraefikFiles: z.boolean().optional().default(false), canAccessToDocker: z.boolean().optional().default(false), canAccessToAPI: z.boolean().optional().default(false), canAccessToSSHKeys: z.boolean().optional().default(false), canAccessToGitProviders: z.boolean().optional().default(false), + canCreateEnvironments: z.boolean().optional().default(false), }); type AddPermissions = z.infer; @@ -175,6 +172,7 @@ interface Props { } export const AddUserPermissions = ({ userId }: Props) => { + const [isOpen, setIsOpen] = useState(false); const { data: projects } = api.project.all.useQuery(); const { data, refetch } = api.user.one.useQuery( @@ -192,13 +190,25 @@ export const AddUserPermissions = ({ userId }: Props) => { const form = useForm({ defaultValues: { accessedProjects: [], + accessedEnvironments: [], accessedServices: [], + canDeleteEnvironments: false, + canCreateProjects: false, + canCreateServices: false, + canDeleteProjects: false, + canDeleteServices: false, + canAccessToTraefikFiles: false, + canAccessToDocker: false, + canAccessToAPI: false, + canAccessToSSHKeys: false, + canAccessToGitProviders: false, + canCreateEnvironments: false, }, resolver: zodResolver(addPermissions), }); useEffect(() => { - if (data) { + if (data && isOpen) { form.reset({ accessedProjects: data.accessedProjects || [], accessedEnvironments: data.accessedEnvironments || [], @@ -207,14 +217,16 @@ export const AddUserPermissions = ({ userId }: Props) => { canCreateServices: data.canCreateServices, canDeleteProjects: data.canDeleteProjects, canDeleteServices: data.canDeleteServices, + canDeleteEnvironments: data.canDeleteEnvironments || false, canAccessToTraefikFiles: data.canAccessToTraefikFiles, canAccessToDocker: data.canAccessToDocker, canAccessToAPI: data.canAccessToAPI, canAccessToSSHKeys: data.canAccessToSSHKeys, canAccessToGitProviders: data.canAccessToGitProviders, + canCreateEnvironments: data.canCreateEnvironments, }); } - }, [form, form.formState.isSubmitSuccessful, form.reset, data]); + }, [form, form.reset, data, isOpen]); const onSubmit = async (data: AddPermissions) => { await mutateAsync({ @@ -223,6 +235,7 @@ export const AddUserPermissions = ({ userId }: Props) => { canCreateProjects: data.canCreateProjects, canDeleteServices: data.canDeleteServices, canDeleteProjects: data.canDeleteProjects, + canDeleteEnvironments: data.canDeleteEnvironments, canAccessToTraefikFiles: data.canAccessToTraefikFiles, accessedProjects: data.accessedProjects || [], accessedEnvironments: data.accessedEnvironments || [], @@ -231,17 +244,19 @@ export const AddUserPermissions = ({ userId }: Props) => { canAccessToAPI: data.canAccessToAPI, canAccessToSSHKeys: data.canAccessToSSHKeys, canAccessToGitProviders: data.canAccessToGitProviders, + canCreateEnvironments: data.canCreateEnvironments, }) .then(async () => { toast.success("Permissions updated"); refetch(); + setIsOpen(false); }) .catch(() => { toast.error("Error updating the permissions"); }); }; return ( - + { )} /> + ( + +
+ Create Environments + + Allow the user to create environments + +
+ + + +
+ )} + /> + ( + +
+ Delete Environments + + Allow the user to delete environments + +
+ + + +
+ )} + /> { ) : (
- See all users Email @@ -111,35 +109,75 @@ export const ShowUsers = () => { - - - - - - - Actions - + {member.role !== "owner" && ( + + + + + + + Actions + - {member.role !== "owner" && ( - )} - {member.role !== "owner" && ( - <> - {!isCloud && ( - { + {!isCloud && ( + { + await mutateAsync({ + userId: member.user.id, + }) + .then(() => { + toast.success( + "User deleted successfully", + ); + refetch(); + }) + .catch(() => { + toast.error( + "Error deleting destination", + ); + }); + }} + > + e.preventDefault()} + > + Delete User + + + )} + + { + if (!isCloud) { + const orgCount = + await utils.user.checkUserOrganizations.fetch( + { + userId: member.user.id, + }, + ); + + console.log(orgCount); + + if (orgCount === 1) { await mutateAsync({ userId: member.user.id, }) @@ -151,86 +189,40 @@ export const ShowUsers = () => { }) .catch(() => { toast.error( - "Error deleting destination", + "Error deleting user", ); }); - }} - > - - e.preventDefault() - } - > - Delete User - - - )} - - { - if (!isCloud) { - const orgCount = - await utils.user.checkUserOrganizations.fetch( - { - userId: member.user.id, - }, - ); - - console.log(orgCount); - - if (orgCount === 1) { - await mutateAsync({ - userId: member.user.id, - }) - .then(() => { - toast.success( - "User deleted successfully", - ); - refetch(); - }) - .catch(() => { - toast.error( - "Error deleting user", - ); - }); - return; - } + return; } + } - const { error } = - await authClient.organization.removeMember( - { - memberIdOrEmail: member.id, - }, - ); + const { error } = + await authClient.organization.removeMember( + { + memberIdOrEmail: member.id, + }, + ); - if (!error) { - toast.success( - "User unlinked successfully", - ); - refetch(); - } else { - toast.error( - "Error unlinking user", - ); - } - }} + if (!error) { + toast.success( + "User unlinked successfully", + ); + refetch(); + } else { + toast.error("Error unlinking user"); + } + }} + > + e.preventDefault()} > - e.preventDefault()} - > - Unlink User - - - - )} - - + Unlink User + + + + + )} ); diff --git a/apps/dokploy/components/dashboard/settings/web-domain.tsx b/apps/dokploy/components/dashboard/settings/web-domain.tsx index cafb95f53..51cb7af3e 100644 --- a/apps/dokploy/components/dashboard/settings/web-domain.tsx +++ b/apps/dokploy/components/dashboard/settings/web-domain.tsx @@ -5,6 +5,7 @@ import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; +import { AlertBlock } from "@/components/shared/alert-block"; import { Button } from "@/components/ui/button"; import { Card, @@ -76,6 +77,9 @@ export const WebDomain = () => { resolver: zodResolver(addServerDomain), }); const https = form.watch("https"); + const domain = form.watch("domain") || ""; + const host = data?.user?.host || ""; + const hasChanged = domain !== host; useEffect(() => { if (data) { form.reset({ @@ -119,6 +123,19 @@ export const WebDomain = () => { + {/* Warning for GitHub webhook URL changes */} + {hasChanged && ( + +
+

⚠️ Important: URL Change Impact

+

+ If you change the Dokploy Server URL make sure to update + your Github Apps to keep the auto-deploy working and preview + deployments working. +

+
+
+ )}
{ +export const DockerTerminalModal = ({ + children, + appName, + serverId, + appType, +}: Props) => { const { data, isLoading } = api.docker.getContainersByAppNameMatch.useQuery( { appName, + appType, serverId, }, { enabled: !!appName, }, ); + const [containerId, setContainerId] = useState(); const [mainDialogOpen, setMainDialogOpen] = useState(false); const [confirmDialogOpen, setConfirmDialogOpen] = useState(false); @@ -83,7 +90,7 @@ export const DockerTerminalModal = ({ children, appName, serverId }: Props) => { {children} event.preventDefault()} > @@ -92,7 +99,6 @@ export const DockerTerminalModal = ({ children, appName, serverId }: Props) => { Easy way to access to docker container - + + + + + All servers + {hasServicesWithoutServer && ( + +
+ + Dokploy server +
+
+ )} + {availableServers.map((server) => ( + +
+ + {server.serverName} +
+
+ ))} +
+ + )} @@ -1389,7 +1537,15 @@ const EnvironmentPage = ( -
+
+ {service.serverName && ( +
+ + + {service.serverName} + +
+ )} Created diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId]/services/application/[applicationId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId]/services/application/[applicationId].tsx index f8d0154f5..a20d307b3 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId]/services/application/[applicationId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId]/services/application/[applicationId].tsx @@ -17,6 +17,7 @@ import { AddCommand } from "@/components/dashboard/application/advanced/general/ import { ShowPorts } from "@/components/dashboard/application/advanced/ports/show-port"; import { ShowRedirects } from "@/components/dashboard/application/advanced/redirects/show-redirects"; import { ShowSecurity } from "@/components/dashboard/application/advanced/security/show-security"; +import { ShowBuildServer } from "@/components/dashboard/application/advanced/show-build-server"; import { ShowResources } from "@/components/dashboard/application/advanced/show-resources"; import { ShowTraefikConfig } from "@/components/dashboard/application/advanced/traefik/show-traefik-config"; import { ShowVolumes } from "@/components/dashboard/application/advanced/volumes/show-volumes"; @@ -353,7 +354,7 @@ const Service = ( id={applicationId} type="application" /> - + diff --git a/apps/dokploy/pages/register.tsx b/apps/dokploy/pages/register.tsx index 60a3d8de4..4452eb1ea 100644 --- a/apps/dokploy/pages/register.tsx +++ b/apps/dokploy/pages/register.tsx @@ -101,7 +101,7 @@ const Register = ({ isCloud }: Props) => { setIsError(true); setError(error.message || "An error occurred"); } else { - toast.success("User registered successfuly", { + toast.success("User registered successfully", { duration: 2000, }); if (!isCloud) { diff --git a/apps/dokploy/reset-2fa.ts b/apps/dokploy/reset-2fa.ts index 089b7118b..77af3d506 100644 --- a/apps/dokploy/reset-2fa.ts +++ b/apps/dokploy/reset-2fa.ts @@ -1,6 +1,6 @@ import { findAdmin } from "@dokploy/server"; import { db } from "@dokploy/server/db"; -import { users_temp } from "@dokploy/server/db/schema"; +import { user } from "@dokploy/server/db/schema"; import { eq } from "drizzle-orm"; (async () => { @@ -8,11 +8,11 @@ import { eq } from "drizzle-orm"; const result = await findAdmin(); const update = await db - .update(users_temp) + .update(user) .set({ twoFactorEnabled: false, }) - .where(eq(users_temp.id, result.userId)); + .where(eq(user.id, result.userId)); if (update) { console.log("2FA reset successful"); diff --git a/apps/dokploy/scripts/generate-openapi.ts b/apps/dokploy/scripts/generate-openapi.ts new file mode 100644 index 000000000..16f826474 --- /dev/null +++ b/apps/dokploy/scripts/generate-openapi.ts @@ -0,0 +1,132 @@ +#!/usr/bin/env tsx + +/** + * Script to generate OpenAPI specification locally + * This runs in CI/CD to generate the openapi.json file + * which can then be consumed by the documentation website + */ + +import { writeFileSync } from "node:fs"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { generateOpenApiDocument } from "@dokploy/trpc-openapi"; +import { appRouter } from "../server/api/root"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +async function generateOpenAPI() { + try { + console.log("🔄 Generating OpenAPI specification..."); + + const openApiDocument = generateOpenApiDocument(appRouter, { + title: "Dokploy API", + version: "1.0.0", + baseUrl: "https://your-dokploy-instance.com/api", + docsUrl: "https://docs.dokploy.com/api", + tags: [ + "admin", + "docker", + "compose", + "registry", + "cluster", + "user", + "domain", + "destination", + "backup", + "deployment", + "mounts", + "certificates", + "settings", + "security", + "redirects", + "port", + "project", + "application", + "mysql", + "postgres", + "redis", + "mongo", + "mariadb", + "sshRouter", + "gitProvider", + "bitbucket", + "github", + "gitlab", + "gitea", + "server", + "swarm", + "ai", + "organization", + "schedule", + "rollback", + "volumeBackups", + "environment", + ], + }); + + // Enhance metadata + openApiDocument.info = { + title: "Dokploy API", + description: + "Complete API documentation for Dokploy - Deploy applications, manage databases, and orchestrate your infrastructure. This API allows you to programmatically manage all aspects of your Dokploy instance.", + version: "1.0.0", + contact: { + name: "Dokploy Team", + url: "https://dokploy.com", + }, + license: { + name: "Apache 2.0", + url: "https://github.com/dokploy/dokploy/blob/canary/LICENSE", + }, + }; + + // Add security schemes + openApiDocument.components = { + ...openApiDocument.components, + securitySchemes: { + apiKey: { + type: "apiKey", + in: "header", + name: "x-api-key", + description: + "API key authentication. Generate an API key from your Dokploy dashboard under Settings > API Keys.", + }, + }, + }; + + // Apply global security + openApiDocument.security = [ + { + apiKey: [], + }, + ]; + + // Add external docs + openApiDocument.externalDocs = { + description: "Full documentation", + url: "https://docs.dokploy.com", + }; + + // Write to root of repo + const outputPath = resolve(__dirname, "../../../openapi.json"); + writeFileSync( + outputPath, + JSON.stringify(openApiDocument, null, 2), + "utf-8", + ); + + console.log("✅ OpenAPI specification generated successfully!"); + console.log(`📄 Output: ${outputPath}`); + console.log( + `📊 Endpoints: ${Object.keys(openApiDocument.paths || {}).length}`, + ); + } catch (error) { + console.error("❌ Error generating OpenAPI specification:", error); + process.exit(1); + } finally { + process.exit(0); + } +} + +generateOpenAPI(); diff --git a/apps/dokploy/server/api/routers/ai.ts b/apps/dokploy/server/api/routers/ai.ts index 6fa2e0cdc..e03da905d 100644 --- a/apps/dokploy/server/api/routers/ai.ts +++ b/apps/dokploy/server/api/routers/ai.ts @@ -62,6 +62,12 @@ export const aiRouter = createTRPCRouter({ case "ollama": response = await fetch(`${input.apiUrl}/api/tags`, { headers }); break; + case "gemini": + response = await fetch( + `${input.apiUrl}/models?key=${encodeURIComponent(input.apiKey)}`, + { headers: {} }, + ); + break; default: if (!input.apiKey) throw new TRPCError({ diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 45fe15c6f..c713fd7eb 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -58,7 +58,11 @@ import { applications, } from "@/server/db/schema"; import type { DeploymentJob } from "@/server/queues/queue-types"; -import { cleanQueuesByApplication, myQueue } from "@/server/queues/queueSetup"; +import { + cleanQueuesByApplication, + killDockerBuild, + myQueue, +} from "@/server/queues/queueSetup"; import { cancelDeployment, deploy } from "@/server/utils/deploy"; import { uploadFileSchema } from "@/utils/schema"; @@ -360,6 +364,7 @@ export const applicationRouter = createTRPCRouter({ await updateApplication(input.applicationId, { env: input.env, buildArgs: input.buildArgs, + buildSecrets: input.buildSecrets, }); return true; }), @@ -524,7 +529,7 @@ export const applicationRouter = createTRPCRouter({ return true; }), - saveGitProdiver: protectedProcedure + saveGitProvider: protectedProcedure .input(apiSaveGitProvider) .mutation(async ({ input, ctx }) => { const application = await findApplicationById(input.applicationId); @@ -724,7 +729,21 @@ export const applicationRouter = createTRPCRouter({ } await cleanQueuesByApplication(input.applicationId); }), - + killBuild: protectedProcedure + .input(apiFindOneApplication) + .mutation(async ({ input, ctx }) => { + const application = await findApplicationById(input.applicationId); + if ( + application.environment.project.organizationId !== + ctx.session.activeOrganizationId + ) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You are not authorized to kill this build", + }); + } + await killDockerBuild("application", application.serverId); + }), readTraefikConfig: protectedProcedure .input(apiFindOneApplication) .query(async ({ input, ctx }) => { diff --git a/apps/dokploy/server/api/routers/compose.ts b/apps/dokploy/server/api/routers/compose.ts index 512ea9718..e233dc6ca 100644 --- a/apps/dokploy/server/api/routers/compose.ts +++ b/apps/dokploy/server/api/routers/compose.ts @@ -3,13 +3,14 @@ import { addNewService, checkServiceAccess, cloneCompose, - cloneComposeRemote, createCommand, createCompose, createComposeByTemplate, createDomain, createMount, deleteMount, + execAsync, + execAsyncRemote, findComposeById, findDomainsByComposeId, findEnvironmentById, @@ -58,7 +59,11 @@ import { compose as composeTable, } from "@/server/db/schema"; import type { DeploymentJob } from "@/server/queues/queue-types"; -import { cleanQueuesByCompose, myQueue } from "@/server/queues/queueSetup"; +import { + cleanQueuesByCompose, + killDockerBuild, + myQueue, +} from "@/server/queues/queueSetup"; import { cancelDeployment, deploy } from "@/server/utils/deploy"; import { generatePassword } from "@/templates/utils"; import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc"; @@ -245,6 +250,22 @@ export const composeRouter = createTRPCRouter({ }); } await cleanQueuesByCompose(input.composeId); + return { success: true, message: "Queues cleaned successfully" }; + }), + killBuild: protectedProcedure + .input(apiFindCompose) + .mutation(async ({ input, ctx }) => { + const compose = await findComposeById(input.composeId); + if ( + compose.environment.project.organizationId !== + ctx.session.activeOrganizationId + ) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You are not authorized to kill this build", + }); + } + await killDockerBuild("compose", compose.serverId); }), loadServices: protectedProcedure @@ -301,10 +322,12 @@ export const composeRouter = createTRPCRouter({ message: "You are not authorized to fetch this compose", }); } + + const command = await cloneCompose(compose); if (compose.serverId) { - await cloneComposeRemote(compose); + await execAsyncRemote(compose.serverId, command); } else { - await cloneCompose(compose); + await execAsync(command); } return compose.sourceType; } catch (err) { @@ -405,6 +428,7 @@ export const composeRouter = createTRPCRouter({ removeOnFail: true, }, ); + return { success: true, message: "Deployment queued" }; }), redeploy: protectedProcedure .input(apiRedeployCompose) @@ -440,6 +464,7 @@ export const composeRouter = createTRPCRouter({ removeOnFail: true, }, ); + return { success: true, message: "Redeployment queued" }; }), stop: protectedProcedure .input(apiFindCompose) diff --git a/apps/dokploy/server/api/routers/destination.ts b/apps/dokploy/server/api/routers/destination.ts index dc5892c85..d7cbf53d5 100644 --- a/apps/dokploy/server/api/routers/destination.ts +++ b/apps/dokploy/server/api/routers/destination.ts @@ -47,15 +47,19 @@ export const destinationRouter = createTRPCRouter({ input; try { const rcloneFlags = [ - `--s3-access-key-id=${accessKey}`, - `--s3-secret-access-key=${secretAccessKey}`, - `--s3-region=${region}`, - `--s3-endpoint=${endpoint}`, + `--s3-access-key-id="${accessKey}"`, + `--s3-secret-access-key="${secretAccessKey}"`, + `--s3-region="${region}"`, + `--s3-endpoint="${endpoint}"`, "--s3-no-check-bucket", "--s3-force-path-style", + "--retries 1", + "--low-level-retries 1", + "--timeout 10s", + "--contimeout 5s", ]; if (provider) { - rcloneFlags.unshift(`--s3-provider=${provider}`); + rcloneFlags.unshift(`--s3-provider="${provider}"`); } const rcloneDestination = `:s3:${bucket}`; const rcloneCommand = `rclone ls ${rcloneFlags.join(" ")} "${rcloneDestination}"`; diff --git a/apps/dokploy/server/api/routers/environment.ts b/apps/dokploy/server/api/routers/environment.ts index 98c565134..6051284ab 100644 --- a/apps/dokploy/server/api/routers/environment.ts +++ b/apps/dokploy/server/api/routers/environment.ts @@ -1,6 +1,8 @@ import { addNewEnvironment, checkEnvironmentAccess, + checkEnvironmentCreationPermission, + checkEnvironmentDeletionPermission, createEnvironment, deleteEnvironment, duplicateEnvironment, @@ -54,9 +56,12 @@ export const environmentRouter = createTRPCRouter({ .input(apiCreateEnvironment) .mutation(async ({ input, ctx }) => { try { - // Check if user has access to the project - // This would typically involve checking project ownership/membership - // For now, we'll use a basic organization check + // Check if user has permission to create environments + await checkEnvironmentCreationPermission( + ctx.user.id, + input.projectId, + ctx.session.activeOrganizationId, + ); if (input.name === "production") { throw new TRPCError({ @@ -76,6 +81,9 @@ export const environmentRouter = createTRPCRouter({ } return environment; } catch (error) { + if (error instanceof TRPCError) { + throw error; + } throw new TRPCError({ code: "BAD_REQUEST", message: `Error creating the environment: ${error instanceof Error ? error.message : error}`, @@ -187,14 +195,6 @@ export const environmentRouter = createTRPCRouter({ .input(apiRemoveEnvironment) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.role === "member") { - await checkEnvironmentAccess( - ctx.user.id, - input.environmentId, - ctx.session.activeOrganizationId, - "access", - ); - } const environment = await findEnvironmentById(input.environmentId); if ( environment.project.organizationId !== @@ -206,27 +206,33 @@ export const environmentRouter = createTRPCRouter({ }); } - // Check environment access for members - if (ctx.user.role === "member") { - const { accessedEnvironments } = await findMemberById( - ctx.user.id, - ctx.session.activeOrganizationId, - ); + // Check environment deletion permission + await checkEnvironmentDeletionPermission( + ctx.user.id, + environment.projectId, + ctx.session.activeOrganizationId, + ); - if (!accessedEnvironments.includes(environment.environmentId)) { - throw new TRPCError({ - code: "FORBIDDEN", - message: "You are not allowed to delete this environment", - }); - } + // Additional check for environment access for members + if (ctx.user.role === "member") { + await checkEnvironmentAccess( + ctx.user.id, + input.environmentId, + ctx.session.activeOrganizationId, + "access", + ); } const deletedEnvironment = await deleteEnvironment(input.environmentId); return deletedEnvironment; } catch (error) { + if (error instanceof TRPCError) { + throw error; + } throw new TRPCError({ code: "BAD_REQUEST", message: `Error deleting the environment: ${error instanceof Error ? error.message : error}`, + cause: error, }); } }), diff --git a/apps/dokploy/server/api/routers/notification.ts b/apps/dokploy/server/api/routers/notification.ts index 09a2aed2a..c483b813e 100644 --- a/apps/dokploy/server/api/routers/notification.ts +++ b/apps/dokploy/server/api/routers/notification.ts @@ -2,6 +2,7 @@ import { createDiscordNotification, createEmailNotification, createGotifyNotification, + createLarkNotification, createNtfyNotification, createSlackNotification, createTelegramNotification, @@ -11,6 +12,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendServerThresholdNotifications, sendSlackNotification, @@ -18,6 +20,7 @@ import { updateDiscordNotification, updateEmailNotification, updateGotifyNotification, + updateLarkNotification, updateNtfyNotification, updateSlackNotification, updateTelegramNotification, @@ -36,6 +39,7 @@ import { apiCreateDiscord, apiCreateEmail, apiCreateGotify, + apiCreateLark, apiCreateNtfy, apiCreateSlack, apiCreateTelegram, @@ -43,18 +47,20 @@ import { apiTestDiscordConnection, apiTestEmailConnection, apiTestGotifyConnection, + apiTestLarkConnection, apiTestNtfyConnection, apiTestSlackConnection, apiTestTelegramConnection, apiUpdateDiscord, apiUpdateEmail, apiUpdateGotify, + apiUpdateLark, apiUpdateNtfy, apiUpdateSlack, apiUpdateTelegram, notifications, server, - users_temp, + user, } from "@/server/db/schema"; export const notificationRouter = createTRPCRouter({ @@ -105,7 +111,7 @@ export const notificationRouter = createTRPCRouter({ } catch (error) { throw new TRPCError({ code: "BAD_REQUEST", - message: "Error testing the notification", + message: `${error instanceof Error ? error.message : "Unknown error"}`, cause: error, }); } @@ -222,7 +228,7 @@ export const notificationRouter = createTRPCRouter({ } catch (error) { throw new TRPCError({ code: "BAD_REQUEST", - message: "Error testing the notification", + message: `${error instanceof Error ? error.message : "Unknown error"}`, cause: error, }); } @@ -279,7 +285,7 @@ export const notificationRouter = createTRPCRouter({ } catch (error) { throw new TRPCError({ code: "BAD_REQUEST", - message: "Error testing the notification", + message: `${error instanceof Error ? error.message : "Unknown error"}`, cause: error, }); } @@ -328,6 +334,7 @@ export const notificationRouter = createTRPCRouter({ email: true, gotify: true, ntfy: true, + lark: true, }, orderBy: desc(notifications.createdAt), where: eq(notifications.organizationId, ctx.session.activeOrganizationId), @@ -352,9 +359,9 @@ export const notificationRouter = createTRPCRouter({ if (input.ServerType === "Dokploy") { const result = await db .select() - .from(users_temp) + .from(user) .where( - sql`${users_temp.metricsConfig}::jsonb -> 'server' ->> 'token' = ${input.Token}`, + sql`${user.metricsConfig}::jsonb -> 'server' ->> 'token' = ${input.Token}`, ); if (!result?.[0]?.id) { @@ -511,6 +518,63 @@ export const notificationRouter = createTRPCRouter({ }); } }), + createLark: adminProcedure + .input(apiCreateLark) + .mutation(async ({ input, ctx }) => { + try { + return await createLarkNotification( + input, + ctx.session.activeOrganizationId, + ); + } catch (error) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Error creating the notification", + cause: error, + }); + } + }), + updateLark: adminProcedure + .input(apiUpdateLark) + .mutation(async ({ input, ctx }) => { + try { + const notification = await findNotificationById(input.notificationId); + if ( + IS_CLOUD && + notification.organizationId !== ctx.session.activeOrganizationId + ) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You are not authorized to update this notification", + }); + } + return await updateLarkNotification({ + ...input, + organizationId: ctx.session.activeOrganizationId, + }); + } catch (error) { + throw error; + } + }), + testLarkConnection: adminProcedure + .input(apiTestLarkConnection) + .mutation(async ({ input }) => { + try { + await sendLarkNotification(input, { + msg_type: "text", + content: { + text: "Hi, From Dokploy 👋", + }, + }); + return true; + } catch (error) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Error testing the notification", + cause: error, + }); + } + }), getEmailProviders: adminProcedure.query(async ({ ctx }) => { return await db.query.notifications.findMany({ where: eq(notifications.organizationId, ctx.session.activeOrganizationId), diff --git a/apps/dokploy/server/api/routers/organization.ts b/apps/dokploy/server/api/routers/organization.ts index a015310d1..e8ca9eb16 100644 --- a/apps/dokploy/server/api/routers/organization.ts +++ b/apps/dokploy/server/api/routers/organization.ts @@ -41,6 +41,11 @@ export const organizationRouter = createTRPCRouter({ }); } + // Check if this is the user's first organization + const existingMemberships = await db.query.member.findMany({ + where: eq(member.userId, ctx.user.id), + }); + await db.insert(member).values({ organizationId: result.id, role: "owner", @@ -63,6 +68,11 @@ export const organizationRouter = createTRPCRouter({ ), ), ), + with: { + members: { + where: eq(member.userId, ctx.user.id), + }, + }, }); return memberResult; }), @@ -184,4 +194,45 @@ export const organizationRouter = createTRPCRouter({ .delete(invitation) .where(eq(invitation.id, input.invitationId)); }), + setDefault: protectedProcedure + .input( + z.object({ + organizationId: z.string().min(1), + }), + ) + .mutation(async ({ ctx, input }) => { + // Verify user is a member of this organization + const userMember = await db.query.member.findFirst({ + where: and( + eq(member.organizationId, input.organizationId), + eq(member.userId, ctx.user.id), + ), + }); + + if (!userMember) { + throw new TRPCError({ + code: "FORBIDDEN", + message: "You are not a member of this organization", + }); + } + + // First, unset all defaults for this user + await db + .update(member) + .set({ isDefault: false }) + .where(eq(member.userId, ctx.user.id)); + + // Then set this organization as default + await db + .update(member) + .set({ isDefault: true }) + .where( + and( + eq(member.organizationId, input.organizationId), + eq(member.userId, ctx.user.id), + ), + ); + + return { success: true }; + }), }); diff --git a/apps/dokploy/server/api/routers/postgres.ts b/apps/dokploy/server/api/routers/postgres.ts index a05072ab7..3112beb66 100644 --- a/apps/dokploy/server/api/routers/postgres.ts +++ b/apps/dokploy/server/api/routers/postgres.ts @@ -8,6 +8,7 @@ import { findEnvironmentById, findPostgresById, findProjectById, + getMountPath, IS_CLOUD, rebuildDatabase, removePostgresById, @@ -37,6 +38,7 @@ import { postgres as postgresTable, } from "@/server/db/schema"; import { cancelJobs } from "@/server/utils/backup"; + export const postgresRouter = createTRPCRouter({ create: protectedProcedure .input(apiCreatePostgres) @@ -79,11 +81,13 @@ export const postgresRouter = createTRPCRouter({ ); } + const mountPath = getMountPath(input.dockerImage); + await createMount({ serviceId: newPostgres.postgresId, serviceType: "postgres", volumeName: `${newPostgres.appName}-data`, - mountPath: "/var/lib/postgresql/data", + mountPath: mountPath, type: "volume", }); @@ -282,12 +286,16 @@ export const postgresRouter = createTRPCRouter({ const backups = await findBackupsByDbId(input.postgresId, "postgres"); const cleanupOperations = [ - removeService(postgres.appName, postgres.serverId), - cancelJobs(backups), - removePostgresById(input.postgresId), + async () => await removeService(postgres?.appName, postgres.serverId), + async () => await cancelJobs(backups), + async () => await removePostgresById(input.postgresId), ]; - await Promise.allSettled(cleanupOperations); + for (const operation of cleanupOperations) { + try { + await operation(); + } catch (_) {} + } return postgres; }), @@ -363,6 +371,7 @@ export const postgresRouter = createTRPCRouter({ message: "You are not authorized to update this Postgres", }); } + const service = await updatePostgresById(postgresId, { ...rest, }); diff --git a/apps/dokploy/server/api/routers/project.ts b/apps/dokploy/server/api/routers/project.ts index 5dd2ee695..9f46d7de3 100644 --- a/apps/dokploy/server/api/routers/project.ts +++ b/apps/dokploy/server/api/routers/project.ts @@ -1,4 +1,5 @@ import { + addNewEnvironment, addNewProject, checkProjectAccess, createApplication, @@ -85,6 +86,12 @@ export const projectRouter = createTRPCRouter({ project.project.projectId, ctx.session.activeOrganizationId, ); + + await addNewEnvironment( + ctx.user.id, + project?.environment?.environmentId || "", + ctx.session.activeOrganizationId, + ); } return project; diff --git a/apps/dokploy/server/api/routers/server.ts b/apps/dokploy/server/api/routers/server.ts index d6904a7ec..4a044ec54 100644 --- a/apps/dokploy/server/api/routers/server.ts +++ b/apps/dokploy/server/api/routers/server.ts @@ -81,8 +81,10 @@ export const serverRouter = createTRPCRouter({ }), getDefaultCommand: protectedProcedure .input(apiFindOneServer) - .query(async () => { - return defaultCommand(); + .query(async ({ input }) => { + const server = await findServerById(input.serverId); + const isBuildServer = server.serverType === "build"; + return defaultCommand(isBuildServer); }), all: protectedProcedure.query(async ({ ctx }) => { const result = await db @@ -124,10 +126,30 @@ export const serverRouter = createTRPCRouter({ isNotNull(server.sshKeyId), eq(server.organizationId, ctx.session.activeOrganizationId), eq(server.serverStatus, "active"), + eq(server.serverType, "deploy"), ) : and( isNotNull(server.sshKeyId), eq(server.organizationId, ctx.session.activeOrganizationId), + eq(server.serverType, "deploy"), + ), + }); + return result; + }), + buildServers: protectedProcedure.query(async ({ ctx }) => { + const result = await db.query.server.findMany({ + orderBy: desc(server.createdAt), + where: IS_CLOUD + ? and( + isNotNull(server.sshKeyId), + eq(server.organizationId, ctx.session.activeOrganizationId), + eq(server.serverStatus, "active"), + eq(server.serverType, "build"), + ) + : and( + isNotNull(server.sshKeyId), + eq(server.organizationId, ctx.session.activeOrganizationId), + eq(server.serverType, "build"), ), }); return result; @@ -383,6 +405,15 @@ export const serverRouter = createTRPCRouter({ const ip = await getPublicIpWithFallback(); return ip; }), + getServerTime: protectedProcedure.query(() => { + if (IS_CLOUD) { + return null; + } + return { + time: new Date(), + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, + }; + }), getServerMetrics: protectedProcedure .input( z.object({ diff --git a/apps/dokploy/server/api/routers/settings.ts b/apps/dokploy/server/api/routers/settings.ts index b4968c260..e0a74f5cf 100644 --- a/apps/dokploy/server/api/routers/settings.ts +++ b/apps/dokploy/server/api/routers/settings.ts @@ -587,7 +587,7 @@ export const settingsRouter = createTRPCRouter({ return ports.some((port) => port.targetPort === 8080); }), - readStatsLogs: adminProcedure + readStatsLogs: protectedProcedure .meta({ openapi: { path: "/read-stats-logs", @@ -650,7 +650,7 @@ export const settingsRouter = createTRPCRouter({ const processedLogs = processLogs(rawConfig as string, input?.dateRange); return processedLogs || []; }), - haveActivateRequests: adminProcedure.query(async () => { + haveActivateRequests: protectedProcedure.query(async () => { if (IS_CLOUD) { return true; } @@ -665,7 +665,7 @@ export const settingsRouter = createTRPCRouter({ return !!parsedConfig?.accessLog?.filePath; }), - toggleRequests: adminProcedure + toggleRequests: protectedProcedure .input( z.object({ enable: z.boolean(), @@ -835,7 +835,7 @@ export const settingsRouter = createTRPCRouter({ const ports = await readPorts("dokploy-traefik", input?.serverId); return ports; }), - updateLogCleanup: adminProcedure + updateLogCleanup: protectedProcedure .input( z.object({ cronExpression: z.string().nullable(), @@ -851,7 +851,7 @@ export const settingsRouter = createTRPCRouter({ return stopLogCleanup(); }), - getLogCleanupStatus: adminProcedure.query(async () => { + getLogCleanupStatus: protectedProcedure.query(async () => { return getLogCleanupStatus(); }), diff --git a/apps/dokploy/server/api/routers/user.ts b/apps/dokploy/server/api/routers/user.ts index d30b99b3a..baec4d6ac 100644 --- a/apps/dokploy/server/api/routers/user.ts +++ b/apps/dokploy/server/api/routers/user.ts @@ -4,6 +4,7 @@ import { findNotificationById, findOrganizationById, findUserById, + getDokployUrl, getUserByToken, IS_CLOUD, removeUserById, @@ -419,11 +420,10 @@ export const userRouter = createTRPCRouter({ }); } - const admin = await findAdmin(); const host = process.env.NODE_ENV === "development" ? "http://localhost:3000" - : admin.user.host; + : await getDokployUrl(); const inviteLink = `${host}/invitation?token=${input.invitationId}`; const organization = await findOrganizationById( diff --git a/apps/dokploy/server/db/validations/domain.ts b/apps/dokploy/server/db/validations/domain.ts index 4937f843b..35de518c0 100644 --- a/apps/dokploy/server/db/validations/domain.ts +++ b/apps/dokploy/server/db/validations/domain.ts @@ -2,7 +2,13 @@ import { z } from "zod"; export const domain = z .object({ - host: z.string().min(1, { message: "Add a hostname" }), + host: z + .string() + .min(1, { message: "Add a hostname" }) + .refine((val) => val === val.trim(), { + message: "Domain name cannot have leading or trailing spaces", + }) + .transform((val) => val.trim()), path: z.string().min(1).optional(), port: z .number() @@ -33,7 +39,13 @@ export const domain = z export const domainCompose = z .object({ - host: z.string().min(1, { message: "Host is required" }), + host: z + .string() + .min(1, { message: "Add a hostname" }) + .refine((val) => val === val.trim(), { + message: "Domain name cannot have leading or trailing spaces", + }) + .transform((val) => val.trim()), path: z.string().min(1).optional(), port: z .number() diff --git a/apps/dokploy/server/queues/deployments-queue.ts b/apps/dokploy/server/queues/deployments-queue.ts index b8dfb8cd0..4c117e7e3 100644 --- a/apps/dokploy/server/queues/deployments-queue.ts +++ b/apps/dokploy/server/queues/deployments-queue.ts @@ -2,13 +2,8 @@ import { deployApplication, deployCompose, deployPreviewApplication, - deployRemoteApplication, - deployRemoteCompose, - deployRemotePreviewApplication, rebuildApplication, rebuildCompose, - rebuildRemoteApplication, - rebuildRemoteCompose, updateApplicationStatus, updateCompose, updatePreviewDeployment, @@ -24,91 +19,48 @@ export const deploymentWorker = new Worker( if (job.data.applicationType === "application") { await updateApplicationStatus(job.data.applicationId, "running"); - if (job.data.server) { - if (job.data.type === "redeploy") { - await rebuildRemoteApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } else if (job.data.type === "deploy") { - await deployRemoteApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } - } else { - if (job.data.type === "redeploy") { - await rebuildApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } else if (job.data.type === "deploy") { - await deployApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } + if (job.data.type === "redeploy") { + await rebuildApplication({ + applicationId: job.data.applicationId, + titleLog: job.data.titleLog, + descriptionLog: job.data.descriptionLog, + }); + } else if (job.data.type === "deploy") { + await deployApplication({ + applicationId: job.data.applicationId, + titleLog: job.data.titleLog, + descriptionLog: job.data.descriptionLog, + }); } } else if (job.data.applicationType === "compose") { await updateCompose(job.data.composeId, { composeStatus: "running", }); - - if (job.data.server) { - if (job.data.type === "redeploy") { - await rebuildRemoteCompose({ - composeId: job.data.composeId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } else if (job.data.type === "deploy") { - await deployRemoteCompose({ - composeId: job.data.composeId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } - } else { - if (job.data.type === "deploy") { - await deployCompose({ - composeId: job.data.composeId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } else if (job.data.type === "redeploy") { - await rebuildCompose({ - composeId: job.data.composeId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - }); - } + if (job.data.type === "deploy") { + await deployCompose({ + composeId: job.data.composeId, + titleLog: job.data.titleLog, + descriptionLog: job.data.descriptionLog, + }); + } else if (job.data.type === "redeploy") { + await rebuildCompose({ + composeId: job.data.composeId, + titleLog: job.data.titleLog, + descriptionLog: job.data.descriptionLog, + }); } } else if (job.data.applicationType === "application-preview") { await updatePreviewDeployment(job.data.previewDeploymentId, { previewStatus: "running", }); - if (job.data.server) { - if (job.data.type === "deploy") { - await deployRemotePreviewApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - previewDeploymentId: job.data.previewDeploymentId, - }); - } - } else { - if (job.data.type === "deploy") { - await deployPreviewApplication({ - applicationId: job.data.applicationId, - titleLog: job.data.titleLog, - descriptionLog: job.data.descriptionLog, - previewDeploymentId: job.data.previewDeploymentId, - }); - } + + if (job.data.type === "deploy") { + await deployPreviewApplication({ + applicationId: job.data.applicationId, + titleLog: job.data.titleLog, + descriptionLog: job.data.descriptionLog, + previewDeploymentId: job.data.previewDeploymentId, + }); } } } catch (error) { diff --git a/apps/dokploy/server/queues/queueSetup.ts b/apps/dokploy/server/queues/queueSetup.ts index 1577273c8..351f5d1c0 100644 --- a/apps/dokploy/server/queues/queueSetup.ts +++ b/apps/dokploy/server/queues/queueSetup.ts @@ -1,3 +1,7 @@ +import { + execAsync, + execAsyncRemote, +} from "@dokploy/server/utils/process/execAsync"; import { Queue } from "bullmq"; import { redisConfig } from "./redis-connection"; @@ -41,4 +45,31 @@ export const cleanQueuesByCompose = async (composeId: string) => { } }; +export const killDockerBuild = async ( + type: "application" | "compose", + serverId: string | null, +) => { + try { + if (type === "application") { + const command = `pkill -2 -f "docker build"`; + + if (serverId) { + await execAsyncRemote(serverId, command); + } else { + await execAsync(command); + } + } else if (type === "compose") { + const command = `pkill -2 -f "docker compose"`; + + if (serverId) { + await execAsyncRemote(serverId, command); + } else { + await execAsync(command); + } + } + } catch (error) { + console.error(error); + } +}; + export { myQueue }; diff --git a/apps/dokploy/server/wss/docker-container-logs.ts b/apps/dokploy/server/wss/docker-container-logs.ts index 8d08ebd46..47868790b 100644 --- a/apps/dokploy/server/wss/docker-container-logs.ts +++ b/apps/dokploy/server/wss/docker-container-logs.ts @@ -46,6 +46,14 @@ export const setupDockerContainerLogsWebSocketServer = ( ws.close(); return; } + + // Set up keep-alive ping mechanism to prevent timeout + // Send ping every 45 seconds to keep connection alive + const pingInterval = setInterval(() => { + if (ws.readyState === ws.OPEN) { + ws.ping(); + } + }, 45000); // 45 seconds try { if (serverId) { const server = await findServerById(serverId); @@ -86,6 +94,7 @@ export const setupDockerContainerLogsWebSocketServer = ( .on("error", (err) => { console.error("SSH connection error:", err); ws.send(`SSH error: ${err.message}`); + clearInterval(pingInterval); ws.close(); // Cierra el WebSocket si hay un error con SSH client.end(); }) @@ -96,6 +105,7 @@ export const setupDockerContainerLogsWebSocketServer = ( privateKey: server.sshKey?.privateKey, }); ws.on("close", () => { + clearInterval(pingInterval); client.end(); }); } else { @@ -121,6 +131,7 @@ export const setupDockerContainerLogsWebSocketServer = ( ws.send(data); }); ws.on("close", () => { + clearInterval(pingInterval); ptyProcess.kill(); }); ws.on("message", (message) => { diff --git a/apps/dokploy/server/wss/docker-stats.ts b/apps/dokploy/server/wss/docker-stats.ts index 99e993dce..bd740e976 100644 --- a/apps/dokploy/server/wss/docker-stats.ts +++ b/apps/dokploy/server/wss/docker-stats.ts @@ -2,6 +2,7 @@ import type http from "node:http"; import { docker, execAsync, + getHostSystemStats, getLastAdvancedStatsFile, recordAdvancedStats, validateRequest, @@ -49,6 +50,21 @@ export const setupDockerStatsMonitoringSocketServer = ( } const intervalId = setInterval(async () => { try { + // Special case: when monitoring "dokploy", get host system stats instead of container stats + if (appName === "dokploy") { + const stat = await getHostSystemStats(); + + await recordAdvancedStats(stat, appName); + const data = await getLastAdvancedStatsFile(appName); + + ws.send( + JSON.stringify({ + data, + }), + ); + return; + } + const filter = { status: ["running"], ...(appType === "application" && { diff --git a/apps/dokploy/setup.ts b/apps/dokploy/setup.ts index 55e1da87c..e0ccb86d8 100644 --- a/apps/dokploy/setup.ts +++ b/apps/dokploy/setup.ts @@ -22,7 +22,7 @@ import { await initializeNetwork(); createDefaultTraefikConfig(); createDefaultServerTraefikConfig(); - await execAsync("docker pull traefik:v3.5.0"); + await execAsync("docker pull traefik:v3.6.1"); await initializeStandaloneTraefik(); await initializeRedis(); await initializePostgres(); diff --git a/apps/dokploy/utils/gitea-utils.ts b/apps/dokploy/utils/gitea-utils.ts index ab7b82dcc..6099aaa45 100644 --- a/apps/dokploy/utils/gitea-utils.ts +++ b/apps/dokploy/utils/gitea-utils.ts @@ -22,7 +22,7 @@ export const getGiteaOAuthUrl = ( } const redirectUri = `${baseUrl}/api/providers/gitea/callback`; - const scopes = "repo repo:status read:user read:org"; + const scopes = "read:repository read:user read:organization"; return `${giteaUrl}/login/oauth/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent( redirectUri, diff --git a/apps/monitoring/monitoring/monitor.go b/apps/monitoring/monitoring/monitor.go index 0beb4320f..2567f286b 100644 --- a/apps/monitoring/monitoring/monitor.go +++ b/apps/monitoring/monitoring/monitor.go @@ -117,7 +117,7 @@ func getRealOS() string { func GetServerMetrics() database.ServerMetric { v, _ := mem.VirtualMemory() - c, _ := cpu.Percent(0, false) + c, _ := cpu.Percent(time.Second, false) cpuInfo, _ := cpu.Info() diskInfo, _ := disk.Usage("/") netInfo, _ := net.IOCounters(false) @@ -130,7 +130,8 @@ func GetServerMetrics() database.ServerMetric { } memTotalGB := float64(v.Total) / 1024 / 1024 / 1024 - memUsedGB := float64(v.Used) / 1024 / 1024 / 1024 + memAvailableGB := float64(v.Available) / 1024 / 1024 / 1024 + memUsedGB := memTotalGB - memAvailableGB memUsedPercent := (memUsedGB / memTotalGB) * 100 var networkIn, networkOut float64 diff --git a/openapi.json b/openapi.json new file mode 100644 index 000000000..76366bdb2 --- /dev/null +++ b/openapi.json @@ -0,0 +1,20004 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Dokploy API", + "description": "Complete API documentation for Dokploy - Deploy applications, manage databases, and orchestrate your infrastructure. This API allows you to programmatically manage all aspects of your Dokploy instance.", + "version": "1.0.0", + "contact": { + "name": "Dokploy Team", + "url": "https://dokploy.com" + }, + "license": { + "name": "Apache 2.0", + "url": "https://github.com/dokploy/dokploy/blob/canary/LICENSE" + } + }, + "servers": [ + { + "url": "https://your-dokploy-instance.com/api" + } + ], + "paths": { + "/admin.setupMonitoring": { + "post": { + "operationId": "admin-setupMonitoring", + "tags": ["admin"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "metricsConfig": { + "type": "object", + "properties": { + "server": { + "type": "object", + "properties": { + "refreshRate": { + "type": "number", + "minimum": 2 + }, + "port": { + "type": "number", + "minimum": 1 + }, + "token": { + "type": "string" + }, + "urlCallback": { + "type": "string", + "format": "uri" + }, + "retentionDays": { + "type": "number", + "minimum": 1 + }, + "cronJob": { + "type": "string", + "minLength": 1 + }, + "thresholds": { + "type": "object", + "properties": { + "cpu": { + "type": "number", + "minimum": 0 + }, + "memory": { + "type": "number", + "minimum": 0 + } + }, + "required": ["cpu", "memory"], + "additionalProperties": false + } + }, + "required": [ + "refreshRate", + "port", + "token", + "urlCallback", + "retentionDays", + "cronJob", + "thresholds" + ], + "additionalProperties": false + }, + "containers": { + "type": "object", + "properties": { + "refreshRate": { + "type": "number", + "minimum": 2 + }, + "services": { + "type": "object", + "properties": { + "include": { + "type": "array", + "items": { + "type": "string" + } + }, + "exclude": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } + }, + "required": ["refreshRate", "services"], + "additionalProperties": false + } + }, + "required": ["server", "containers"], + "additionalProperties": false + } + }, + "required": ["metricsConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getContainers": { + "get": { + "operationId": "docker-getContainers", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.restartContainer": { + "post": { + "operationId": "docker-restartContainer", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "containerId": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + "required": ["containerId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getConfig": { + "get": { + "operationId": "docker-getConfig", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "containerId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getContainersByAppNameMatch": { + "get": { + "operationId": "docker-getContainersByAppNameMatch", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "appType", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "enum": ["stack"] + }, + { + "type": "string", + "enum": ["docker-compose"] + } + ] + } + }, + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getContainersByAppLabel": { + "get": { + "operationId": "docker-getContainersByAppLabel", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "type", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": ["standalone", "swarm"] + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getStackContainersByAppName": { + "get": { + "operationId": "docker-getStackContainersByAppName", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/docker.getServiceContainersByAppName": { + "get": { + "operationId": "docker-getServiceContainersByAppName", + "tags": ["docker"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "pattern": "^[a-zA-Z0-9.\\-_]+$" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.create": { + "post": { + "operationId": "project-create", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string" + } + }, + "required": ["name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.one": { + "get": { + "operationId": "project-one", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "projectId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.all": { + "get": { + "operationId": "project-all", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.remove": { + "post": { + "operationId": "project-remove", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "projectId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["projectId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.update": { + "post": { + "operationId": "project-update", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "projectId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "organizationId": { + "type": "string" + }, + "env": { + "type": "string" + } + }, + "required": ["projectId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/project.duplicate": { + "post": { + "operationId": "project-duplicate", + "tags": ["project"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "sourceEnvironmentId": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "includeServices": { + "type": "boolean", + "default": true + }, + "selectedServices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "application", + "postgres", + "mariadb", + "mongo", + "mysql", + "redis", + "compose" + ] + } + }, + "required": ["id", "type"], + "additionalProperties": false + } + }, + "duplicateInSameProject": { + "type": "boolean", + "default": false + } + }, + "required": ["sourceEnvironmentId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.create": { + "post": { + "operationId": "application-create", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "environmentId": { + "type": "string" + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": ["name", "environmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.one": { + "get": { + "operationId": "application-one", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.reload": { + "post": { + "operationId": "application-reload", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appName": { + "type": "string" + }, + "applicationId": { + "type": "string" + } + }, + "required": ["appName", "applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.delete": { + "post": { + "operationId": "application-delete", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.stop": { + "post": { + "operationId": "application-stop", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.start": { + "post": { + "operationId": "application-start", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.redeploy": { + "post": { + "operationId": "application-redeploy", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string", + "minLength": 1 + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveEnvironment": { + "post": { + "operationId": "application-saveEnvironment", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + }, + "buildArgs": { + "type": "string", + "nullable": true + }, + "buildSecrets": { + "type": "string", + "nullable": true + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveBuildType": { + "post": { + "operationId": "application-saveBuildType", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "buildType": { + "type": "string", + "enum": [ + "dockerfile", + "heroku_buildpacks", + "paketo_buildpacks", + "nixpacks", + "static", + "railpack" + ] + }, + "dockerfile": { + "type": "string", + "nullable": true + }, + "dockerContextPath": { + "type": "string", + "nullable": true + }, + "dockerBuildStage": { + "type": "string", + "nullable": true + }, + "herokuVersion": { + "type": "string", + "nullable": true + }, + "railpackVersion": { + "type": "string", + "nullable": true + }, + "publishDirectory": { + "type": "string", + "nullable": true + }, + "isStaticSpa": { + "type": "boolean", + "nullable": true + } + }, + "required": [ + "applicationId", + "buildType", + "dockerContextPath", + "dockerBuildStage" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveGithubProvider": { + "post": { + "operationId": "application-saveGithubProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "repository": { + "type": "string", + "nullable": true + }, + "branch": { + "type": "string", + "nullable": true + }, + "owner": { + "type": "string", + "nullable": true + }, + "buildPath": { + "type": "string", + "nullable": true + }, + "githubId": { + "type": "string", + "nullable": true + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + }, + "triggerType": { + "type": "string", + "enum": ["push", "tag"], + "default": "push" + } + }, + "required": [ + "applicationId", + "owner", + "githubId", + "enableSubmodules" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveGitlabProvider": { + "post": { + "operationId": "application-saveGitlabProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "gitlabBranch": { + "type": "string", + "nullable": true + }, + "gitlabBuildPath": { + "type": "string", + "nullable": true + }, + "gitlabOwner": { + "type": "string", + "nullable": true + }, + "gitlabRepository": { + "type": "string", + "nullable": true + }, + "gitlabId": { + "type": "string", + "nullable": true + }, + "gitlabProjectId": { + "type": "number", + "nullable": true + }, + "gitlabPathNamespace": { + "type": "string", + "nullable": true + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + } + }, + "required": [ + "applicationId", + "gitlabBranch", + "gitlabBuildPath", + "gitlabOwner", + "gitlabRepository", + "gitlabId", + "gitlabProjectId", + "gitlabPathNamespace", + "enableSubmodules" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveBitbucketProvider": { + "post": { + "operationId": "application-saveBitbucketProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "bitbucketBranch": { + "type": "string", + "nullable": true + }, + "bitbucketBuildPath": { + "type": "string", + "nullable": true + }, + "bitbucketOwner": { + "type": "string", + "nullable": true + }, + "bitbucketRepository": { + "type": "string", + "nullable": true + }, + "bitbucketId": { + "type": "string", + "nullable": true + }, + "applicationId": { + "type": "string" + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + } + }, + "required": [ + "bitbucketBranch", + "bitbucketBuildPath", + "bitbucketOwner", + "bitbucketRepository", + "bitbucketId", + "applicationId", + "enableSubmodules" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveGiteaProvider": { + "post": { + "operationId": "application-saveGiteaProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "giteaBranch": { + "type": "string", + "nullable": true + }, + "giteaBuildPath": { + "type": "string", + "nullable": true + }, + "giteaOwner": { + "type": "string", + "nullable": true + }, + "giteaRepository": { + "type": "string", + "nullable": true + }, + "giteaId": { + "type": "string", + "nullable": true + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + } + }, + "required": [ + "applicationId", + "giteaBranch", + "giteaBuildPath", + "giteaOwner", + "giteaRepository", + "giteaId", + "enableSubmodules" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveDockerProvider": { + "post": { + "operationId": "application-saveDockerProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "dockerImage": { + "type": "string", + "nullable": true + }, + "applicationId": { + "type": "string" + }, + "username": { + "type": "string", + "nullable": true + }, + "password": { + "type": "string", + "nullable": true + }, + "registryUrl": { + "type": "string", + "nullable": true + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.saveGitProvider": { + "post": { + "operationId": "application-saveGitProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "customGitBranch": { + "type": "string", + "nullable": true + }, + "applicationId": { + "type": "string" + }, + "customGitBuildPath": { + "type": "string", + "nullable": true + }, + "customGitUrl": { + "type": "string", + "nullable": true + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + }, + "customGitSSHKeyId": { + "type": "string", + "nullable": true + } + }, + "required": ["applicationId", "enableSubmodules"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.disconnectGitProvider": { + "post": { + "operationId": "application-disconnectGitProvider", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.markRunning": { + "post": { + "operationId": "application-markRunning", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.update": { + "post": { + "operationId": "application-update", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "previewEnv": { + "type": "string", + "nullable": true + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "previewBuildArgs": { + "type": "string", + "nullable": true + }, + "previewBuildSecrets": { + "type": "string", + "nullable": true + }, + "previewLabels": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "previewWildcard": { + "type": "string", + "nullable": true + }, + "previewPort": { + "type": "number", + "nullable": true + }, + "previewHttps": { + "type": "boolean" + }, + "previewPath": { + "type": "string", + "nullable": true + }, + "previewCertificateType": { + "type": "string", + "enum": ["letsencrypt", "none", "custom"] + }, + "previewCustomCertResolver": { + "type": "string", + "nullable": true + }, + "previewLimit": { + "type": "number", + "nullable": true + }, + "isPreviewDeploymentsActive": { + "type": "boolean", + "nullable": true + }, + "previewRequireCollaboratorPermissions": { + "type": "boolean", + "nullable": true + }, + "rollbackActive": { + "type": "boolean", + "nullable": true + }, + "buildArgs": { + "type": "string", + "nullable": true + }, + "buildSecrets": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "title": { + "type": "string", + "nullable": true + }, + "enabled": { + "type": "boolean", + "nullable": true + }, + "subtitle": { + "type": "string", + "nullable": true + }, + "command": { + "type": "string", + "nullable": true + }, + "refreshToken": { + "type": "string", + "nullable": true + }, + "sourceType": { + "type": "string", + "enum": [ + "github", + "docker", + "git", + "gitlab", + "bitbucket", + "gitea", + "drop" + ] + }, + "cleanCache": { + "type": "boolean", + "nullable": true + }, + "repository": { + "type": "string", + "nullable": true + }, + "owner": { + "type": "string", + "nullable": true + }, + "branch": { + "type": "string", + "nullable": true + }, + "buildPath": { + "type": "string", + "nullable": true + }, + "triggerType": { + "type": "string", + "enum": ["push", "tag"], + "nullable": true + }, + "autoDeploy": { + "type": "boolean", + "nullable": true + }, + "gitlabProjectId": { + "type": "number", + "nullable": true + }, + "gitlabRepository": { + "type": "string", + "nullable": true + }, + "gitlabOwner": { + "type": "string", + "nullable": true + }, + "gitlabBranch": { + "type": "string", + "nullable": true + }, + "gitlabBuildPath": { + "type": "string", + "nullable": true + }, + "gitlabPathNamespace": { + "type": "string", + "nullable": true + }, + "giteaRepository": { + "type": "string", + "nullable": true + }, + "giteaOwner": { + "type": "string", + "nullable": true + }, + "giteaBranch": { + "type": "string", + "nullable": true + }, + "giteaBuildPath": { + "type": "string", + "nullable": true + }, + "bitbucketRepository": { + "type": "string", + "nullable": true + }, + "bitbucketOwner": { + "type": "string", + "nullable": true + }, + "bitbucketBranch": { + "type": "string", + "nullable": true + }, + "bitbucketBuildPath": { + "type": "string", + "nullable": true + }, + "username": { + "type": "string", + "nullable": true + }, + "password": { + "type": "string", + "nullable": true + }, + "dockerImage": { + "type": "string", + "nullable": true + }, + "registryUrl": { + "type": "string", + "nullable": true + }, + "customGitUrl": { + "type": "string", + "nullable": true + }, + "customGitBranch": { + "type": "string", + "nullable": true + }, + "customGitBuildPath": { + "type": "string", + "nullable": true + }, + "customGitSSHKeyId": { + "type": "string", + "nullable": true + }, + "enableSubmodules": { + "type": "boolean" + }, + "dockerfile": { + "type": "string", + "nullable": true + }, + "dockerContextPath": { + "type": "string", + "nullable": true + }, + "dockerBuildStage": { + "type": "string", + "nullable": true + }, + "dropBuildPath": { + "type": "string", + "nullable": true + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "buildType": { + "type": "string", + "enum": [ + "dockerfile", + "heroku_buildpacks", + "paketo_buildpacks", + "nixpacks", + "static", + "railpack" + ] + }, + "railpackVersion": { + "type": "string", + "nullable": true + }, + "herokuVersion": { + "type": "string", + "nullable": true + }, + "publishDirectory": { + "type": "string", + "nullable": true + }, + "isStaticSpa": { + "type": "boolean", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "registryId": { + "type": "string", + "nullable": true + }, + "environmentId": { + "type": "string" + }, + "githubId": { + "type": "string", + "nullable": true + }, + "gitlabId": { + "type": "string", + "nullable": true + }, + "giteaId": { + "type": "string", + "nullable": true + }, + "bitbucketId": { + "type": "string", + "nullable": true + }, + "buildServerId": { + "type": "string", + "nullable": true + }, + "buildRegistryId": { + "type": "string", + "nullable": true + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.refreshToken": { + "post": { + "operationId": "application-refreshToken", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.deploy": { + "post": { + "operationId": "application-deploy", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string", + "minLength": 1 + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.cleanQueues": { + "post": { + "operationId": "application-cleanQueues", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.killBuild": { + "post": { + "operationId": "application-killBuild", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.readTraefikConfig": { + "get": { + "operationId": "application-readTraefikConfig", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.updateTraefikConfig": { + "post": { + "operationId": "application-updateTraefikConfig", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "traefikConfig": { + "type": "string" + } + }, + "required": ["applicationId", "traefikConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.readAppMonitoring": { + "get": { + "operationId": "application-readAppMonitoring", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.move": { + "post": { + "operationId": "application-move", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["applicationId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/application.cancelDeployment": { + "post": { + "operationId": "application-cancelDeployment", + "tags": ["application"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + } + }, + "required": ["applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.create": { + "post": { + "operationId": "mysql-create", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "dockerImage": { + "type": "string", + "default": "mysql:8" + }, + "environmentId": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "databaseRootPassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": [ + "name", + "appName", + "environmentId", + "databaseName", + "databaseUser", + "databasePassword", + "databaseRootPassword" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.one": { + "get": { + "operationId": "mysql-one", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "mysqlId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.start": { + "post": { + "operationId": "mysql-start", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.stop": { + "post": { + "operationId": "mysql-stop", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.saveExternalPort": { + "post": { + "operationId": "mysql-saveExternalPort", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + }, + "externalPort": { + "type": "number", + "nullable": true + } + }, + "required": ["mysqlId", "externalPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.deploy": { + "post": { + "operationId": "mysql-deploy", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.changeStatus": { + "post": { + "operationId": "mysql-changeStatus", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + } + }, + "required": ["mysqlId", "applicationStatus"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.reload": { + "post": { + "operationId": "mysql-reload", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + }, + "appName": { + "type": "string", + "minLength": 1 + } + }, + "required": ["mysqlId", "appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.remove": { + "post": { + "operationId": "mysql-remove", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.saveEnvironment": { + "post": { + "operationId": "mysql-saveEnvironment", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.update": { + "post": { + "operationId": "mysql-update", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "databaseRootPassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "dockerImage": { + "type": "string", + "default": "mysql:8" + }, + "command": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "externalPort": { + "type": "number", + "nullable": true + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "environmentId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.move": { + "post": { + "operationId": "mysql-move", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["mysqlId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mysql.rebuild": { + "post": { + "operationId": "mysql-rebuild", + "tags": ["mysql"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mysqlId": { + "type": "string" + } + }, + "required": ["mysqlId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.create": { + "post": { + "operationId": "postgres-create", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string" + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "dockerImage": { + "type": "string", + "default": "postgres:15" + }, + "environmentId": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": [ + "name", + "appName", + "databaseName", + "databaseUser", + "databasePassword", + "environmentId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.one": { + "get": { + "operationId": "postgres-one", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "postgresId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.start": { + "post": { + "operationId": "postgres-start", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.stop": { + "post": { + "operationId": "postgres-stop", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.saveExternalPort": { + "post": { + "operationId": "postgres-saveExternalPort", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + }, + "externalPort": { + "type": "number", + "nullable": true + } + }, + "required": ["postgresId", "externalPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.deploy": { + "post": { + "operationId": "postgres-deploy", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.changeStatus": { + "post": { + "operationId": "postgres-changeStatus", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + } + }, + "required": ["postgresId", "applicationStatus"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.remove": { + "post": { + "operationId": "postgres-remove", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.saveEnvironment": { + "post": { + "operationId": "postgres-saveEnvironment", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.reload": { + "post": { + "operationId": "postgres-reload", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + }, + "appName": { + "type": "string" + } + }, + "required": ["postgresId", "appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.update": { + "post": { + "operationId": "postgres-update", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string" + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "description": { + "type": "string", + "nullable": true + }, + "dockerImage": { + "type": "string", + "default": "postgres:15" + }, + "command": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "externalPort": { + "type": "number", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "environmentId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.move": { + "post": { + "operationId": "postgres-move", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["postgresId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/postgres.rebuild": { + "post": { + "operationId": "postgres-rebuild", + "tags": ["postgres"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "postgresId": { + "type": "string" + } + }, + "required": ["postgresId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.create": { + "post": { + "operationId": "redis-create", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string" + }, + "dockerImage": { + "type": "string", + "default": "redis:8" + }, + "environmentId": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": [ + "name", + "appName", + "databasePassword", + "environmentId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.one": { + "get": { + "operationId": "redis-one", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "redisId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.start": { + "post": { + "operationId": "redis-start", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.reload": { + "post": { + "operationId": "redis-reload", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + }, + "appName": { + "type": "string", + "minLength": 1 + } + }, + "required": ["redisId", "appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.stop": { + "post": { + "operationId": "redis-stop", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.saveExternalPort": { + "post": { + "operationId": "redis-saveExternalPort", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + }, + "externalPort": { + "type": "number", + "nullable": true + } + }, + "required": ["redisId", "externalPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.deploy": { + "post": { + "operationId": "redis-deploy", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.changeStatus": { + "post": { + "operationId": "redis-changeStatus", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + } + }, + "required": ["redisId", "applicationStatus"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.remove": { + "post": { + "operationId": "redis-remove", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.saveEnvironment": { + "post": { + "operationId": "redis-saveEnvironment", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.update": { + "post": { + "operationId": "redis-update", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "databasePassword": { + "type": "string" + }, + "dockerImage": { + "type": "string", + "default": "redis:8" + }, + "command": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "externalPort": { + "type": "number", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "environmentId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.move": { + "post": { + "operationId": "redis-move", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["redisId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redis.rebuild": { + "post": { + "operationId": "redis-rebuild", + "tags": ["redis"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redisId": { + "type": "string" + } + }, + "required": ["redisId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.create": { + "post": { + "operationId": "mongo-create", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "dockerImage": { + "type": "string", + "default": "mongo:15" + }, + "environmentId": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "serverId": { + "type": "string", + "nullable": true + }, + "replicaSets": { + "type": "boolean", + "default": false, + "nullable": true + } + }, + "required": [ + "name", + "appName", + "environmentId", + "databaseUser", + "databasePassword" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.one": { + "get": { + "operationId": "mongo-one", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "mongoId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.start": { + "post": { + "operationId": "mongo-start", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.stop": { + "post": { + "operationId": "mongo-stop", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.saveExternalPort": { + "post": { + "operationId": "mongo-saveExternalPort", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + }, + "externalPort": { + "type": "number", + "nullable": true + } + }, + "required": ["mongoId", "externalPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.deploy": { + "post": { + "operationId": "mongo-deploy", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.changeStatus": { + "post": { + "operationId": "mongo-changeStatus", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + } + }, + "required": ["mongoId", "applicationStatus"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.reload": { + "post": { + "operationId": "mongo-reload", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + }, + "appName": { + "type": "string", + "minLength": 1 + } + }, + "required": ["mongoId", "appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.remove": { + "post": { + "operationId": "mongo-remove", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.saveEnvironment": { + "post": { + "operationId": "mongo-saveEnvironment", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.update": { + "post": { + "operationId": "mongo-update", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "dockerImage": { + "type": "string", + "default": "mongo:15" + }, + "command": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "externalPort": { + "type": "number", + "nullable": true + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "environmentId": { + "type": "string" + }, + "replicaSets": { + "type": "boolean", + "default": false, + "nullable": true + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.move": { + "post": { + "operationId": "mongo-move", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["mongoId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mongo.rebuild": { + "post": { + "operationId": "mongo-rebuild", + "tags": ["mongo"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mongoId": { + "type": "string" + } + }, + "required": ["mongoId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.create": { + "post": { + "operationId": "mariadb-create", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "dockerImage": { + "type": "string", + "default": "mariadb:6" + }, + "databaseRootPassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "environmentId": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": [ + "name", + "appName", + "databaseRootPassword", + "environmentId", + "databaseName", + "databaseUser", + "databasePassword" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.one": { + "get": { + "operationId": "mariadb-one", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "mariadbId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.start": { + "post": { + "operationId": "mariadb-start", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.stop": { + "post": { + "operationId": "mariadb-stop", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.saveExternalPort": { + "post": { + "operationId": "mariadb-saveExternalPort", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + }, + "externalPort": { + "type": "number", + "nullable": true + } + }, + "required": ["mariadbId", "externalPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.deploy": { + "post": { + "operationId": "mariadb-deploy", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.changeStatus": { + "post": { + "operationId": "mariadb-changeStatus", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + } + }, + "required": ["mariadbId", "applicationStatus"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.remove": { + "post": { + "operationId": "mariadb-remove", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.saveEnvironment": { + "post": { + "operationId": "mariadb-saveEnvironment", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + }, + "env": { + "type": "string", + "nullable": true + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.reload": { + "post": { + "operationId": "mariadb-reload", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + }, + "appName": { + "type": "string", + "minLength": 1 + } + }, + "required": ["mariadbId", "appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.update": { + "post": { + "operationId": "mariadb-update", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "databaseName": { + "type": "string", + "minLength": 1 + }, + "databaseUser": { + "type": "string", + "minLength": 1 + }, + "databasePassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "databaseRootPassword": { + "type": "string", + "pattern": "^[a-zA-Z0-9@#%^&*()_+\\-=[\\]{}|;:,.<>?~`]*$" + }, + "dockerImage": { + "type": "string", + "default": "mariadb:6" + }, + "command": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "memoryReservation": { + "type": "string", + "nullable": true + }, + "memoryLimit": { + "type": "string", + "nullable": true + }, + "cpuReservation": { + "type": "string", + "nullable": true + }, + "cpuLimit": { + "type": "string", + "nullable": true + }, + "externalPort": { + "type": "number", + "nullable": true + }, + "applicationStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "healthCheckSwarm": { + "type": "object", + "properties": { + "Test": { + "type": "array", + "items": { + "type": "string" + } + }, + "Interval": { + "type": "number" + }, + "Timeout": { + "type": "number" + }, + "StartPeriod": { + "type": "number" + }, + "Retries": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "restartPolicySwarm": { + "type": "object", + "properties": { + "Condition": { + "type": "string" + }, + "Delay": { + "type": "number" + }, + "MaxAttempts": { + "type": "number" + }, + "Window": { + "type": "number" + } + }, + "additionalProperties": false, + "nullable": true + }, + "placementSwarm": { + "type": "object", + "properties": { + "Constraints": { + "type": "array", + "items": { + "type": "string" + } + }, + "Preferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Spread": { + "type": "object", + "properties": { + "SpreadDescriptor": { + "type": "string" + } + }, + "required": ["SpreadDescriptor"], + "additionalProperties": false + } + }, + "required": ["Spread"], + "additionalProperties": false + } + }, + "MaxReplicas": { + "type": "number" + }, + "Platforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Architecture": { + "type": "string" + }, + "OS": { + "type": "string" + } + }, + "required": ["Architecture", "OS"], + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "updateConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "rollbackConfigSwarm": { + "type": "object", + "properties": { + "Parallelism": { + "type": "number" + }, + "Delay": { + "type": "number" + }, + "FailureAction": { + "type": "string" + }, + "Monitor": { + "type": "number" + }, + "MaxFailureRatio": { + "type": "number" + }, + "Order": { + "type": "string" + } + }, + "required": ["Parallelism", "Order"], + "additionalProperties": false, + "nullable": true + }, + "modeSwarm": { + "type": "object", + "properties": { + "Replicated": { + "type": "object", + "properties": { + "Replicas": { + "type": "number" + } + }, + "additionalProperties": false + }, + "Global": { + "type": "object", + "properties": {}, + "additionalProperties": false + }, + "ReplicatedJob": { + "type": "object", + "properties": { + "MaxConcurrent": { + "type": "number" + }, + "TotalCompletions": { + "type": "number" + } + }, + "additionalProperties": false + }, + "GlobalJob": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false, + "nullable": true + }, + "labelsSwarm": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "nullable": true + }, + "networkSwarm": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Target": { + "type": "string" + }, + "Aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "DriverOpts": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "nullable": true + }, + "stopGracePeriodSwarm": { + "type": "integer", + "nullable": true + }, + "endpointSpecSwarm": { + "type": "object", + "properties": { + "Mode": { + "type": "string" + }, + "Ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Protocol": { + "type": "string" + }, + "TargetPort": { + "type": "number" + }, + "PublishedPort": { + "type": "number" + }, + "PublishMode": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "nullable": true + }, + "replicas": { + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "environmentId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.move": { + "post": { + "operationId": "mariadb-move", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["mariadbId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mariadb.rebuild": { + "post": { + "operationId": "mariadb-rebuild", + "tags": ["mariadb"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mariadbId": { + "type": "string" + } + }, + "required": ["mariadbId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.create": { + "post": { + "operationId": "compose-create", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "environmentId": { + "type": "string" + }, + "composeType": { + "type": "string", + "enum": ["docker-compose", "stack"] + }, + "appName": { + "type": "string" + }, + "serverId": { + "type": "string", + "nullable": true + }, + "composeFile": { + "type": "string" + } + }, + "required": ["name", "environmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.one": { + "get": { + "operationId": "compose-one", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.update": { + "post": { + "operationId": "compose-update", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "appName": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "env": { + "type": "string", + "nullable": true + }, + "composeFile": { + "type": "string" + }, + "refreshToken": { + "type": "string", + "nullable": true + }, + "sourceType": { + "type": "string", + "enum": [ + "git", + "github", + "gitlab", + "bitbucket", + "gitea", + "raw" + ] + }, + "composeType": { + "type": "string", + "enum": ["docker-compose", "stack"] + }, + "repository": { + "type": "string", + "nullable": true + }, + "owner": { + "type": "string", + "nullable": true + }, + "branch": { + "type": "string", + "nullable": true + }, + "autoDeploy": { + "type": "boolean", + "nullable": true + }, + "gitlabProjectId": { + "type": "number", + "nullable": true + }, + "gitlabRepository": { + "type": "string", + "nullable": true + }, + "gitlabOwner": { + "type": "string", + "nullable": true + }, + "gitlabBranch": { + "type": "string", + "nullable": true + }, + "gitlabPathNamespace": { + "type": "string", + "nullable": true + }, + "bitbucketRepository": { + "type": "string", + "nullable": true + }, + "bitbucketOwner": { + "type": "string", + "nullable": true + }, + "bitbucketBranch": { + "type": "string", + "nullable": true + }, + "giteaRepository": { + "type": "string", + "nullable": true + }, + "giteaOwner": { + "type": "string", + "nullable": true + }, + "giteaBranch": { + "type": "string", + "nullable": true + }, + "customGitUrl": { + "type": "string", + "nullable": true + }, + "customGitBranch": { + "type": "string", + "nullable": true + }, + "customGitSSHKeyId": { + "type": "string", + "nullable": true + }, + "command": { + "type": "string" + }, + "enableSubmodules": { + "type": "boolean" + }, + "composePath": { + "type": "string", + "minLength": 1 + }, + "suffix": { + "type": "string" + }, + "randomize": { + "type": "boolean" + }, + "isolatedDeployment": { + "type": "boolean" + }, + "isolatedDeploymentsVolume": { + "type": "boolean" + }, + "triggerType": { + "type": "string", + "enum": ["push", "tag"], + "nullable": true + }, + "composeStatus": { + "type": "string", + "enum": ["idle", "running", "done", "error"] + }, + "environmentId": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "watchPaths": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "githubId": { + "type": "string", + "nullable": true + }, + "gitlabId": { + "type": "string", + "nullable": true + }, + "bitbucketId": { + "type": "string", + "nullable": true + }, + "giteaId": { + "type": "string", + "nullable": true + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.delete": { + "post": { + "operationId": "compose-delete", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + }, + "deleteVolumes": { + "type": "boolean" + } + }, + "required": ["composeId", "deleteVolumes"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.cleanQueues": { + "post": { + "operationId": "compose-cleanQueues", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.killBuild": { + "post": { + "operationId": "compose-killBuild", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.loadServices": { + "get": { + "operationId": "compose-loadServices", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "type", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "not": {} + }, + { + "type": "string", + "enum": ["fetch", "cache"] + } + ], + "default": "cache" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.loadMountsByService": { + "get": { + "operationId": "compose-loadMountsByService", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "serviceName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.fetchSourceType": { + "post": { + "operationId": "compose-fetchSourceType", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.randomizeCompose": { + "post": { + "operationId": "compose-randomizeCompose", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + }, + "suffix": { + "type": "string" + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.isolatedDeployment": { + "post": { + "operationId": "compose-isolatedDeployment", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + }, + "suffix": { + "type": "string" + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.getConvertedCompose": { + "get": { + "operationId": "compose-getConvertedCompose", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.deploy": { + "post": { + "operationId": "compose-deploy", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.redeploy": { + "post": { + "operationId": "compose-redeploy", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.stop": { + "post": { + "operationId": "compose-stop", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.start": { + "post": { + "operationId": "compose-start", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.getDefaultCommand": { + "get": { + "operationId": "compose-getDefaultCommand", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.refreshToken": { + "post": { + "operationId": "compose-refreshToken", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.deployTemplate": { + "post": { + "operationId": "compose-deployTemplate", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "environmentId": { + "type": "string" + }, + "serverId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "baseUrl": { + "type": "string" + } + }, + "required": ["environmentId", "id"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.templates": { + "get": { + "operationId": "compose-templates", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "baseUrl", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.getTags": { + "get": { + "operationId": "compose-getTags", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "baseUrl", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.disconnectGitProvider": { + "post": { + "operationId": "compose-disconnectGitProvider", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.move": { + "post": { + "operationId": "compose-move", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string" + }, + "targetEnvironmentId": { + "type": "string" + } + }, + "required": ["composeId", "targetEnvironmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.processTemplate": { + "post": { + "operationId": "compose-processTemplate", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "base64": { + "type": "string" + }, + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["base64", "composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.import": { + "post": { + "operationId": "compose-import", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "base64": { + "type": "string" + }, + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["base64", "composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/compose.cancelDeployment": { + "post": { + "operationId": "compose-cancelDeployment", + "tags": ["compose"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "composeId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["composeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.all": { + "get": { + "operationId": "user-all", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.one": { + "get": { + "operationId": "user-one", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "userId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.get": { + "get": { + "operationId": "user-get", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.haveRootAccess": { + "get": { + "operationId": "user-haveRootAccess", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getBackups": { + "get": { + "operationId": "user-getBackups", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getServerMetrics": { + "get": { + "operationId": "user-getServerMetrics", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.update": { + "post": { + "operationId": "user-update", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string" + }, + "isRegistered": { + "type": "boolean" + }, + "expirationDate": { + "type": "string" + }, + "createdAt2": { + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time", + "nullable": true + }, + "twoFactorEnabled": { + "type": "boolean", + "nullable": true + }, + "email": { + "type": "string", + "format": "email", + "minLength": 1 + }, + "emailVerified": { + "type": "boolean" + }, + "image": { + "type": "string", + "nullable": true + }, + "banned": { + "type": "boolean", + "nullable": true + }, + "banReason": { + "type": "string", + "nullable": true + }, + "banExpires": { + "type": "string", + "format": "date-time", + "nullable": true + }, + "updatedAt": { + "type": "string", + "format": "date-time" + }, + "serverIp": { + "type": "string", + "nullable": true + }, + "certificateType": { + "type": "string", + "enum": ["letsencrypt", "none", "custom"] + }, + "https": { + "type": "boolean" + }, + "host": { + "type": "string", + "nullable": true + }, + "letsEncryptEmail": { + "type": "string", + "nullable": true + }, + "sshPrivateKey": { + "type": "string", + "nullable": true + }, + "enableDockerCleanup": { + "type": "boolean" + }, + "logCleanupCron": { + "type": "string", + "nullable": true + }, + "enablePaidFeatures": { + "type": "boolean" + }, + "allowImpersonation": { + "type": "boolean" + }, + "metricsConfig": { + "type": "object", + "properties": { + "server": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["Dokploy", "Remote"] + }, + "refreshRate": { + "type": "number" + }, + "port": { + "type": "number" + }, + "token": { + "type": "string" + }, + "urlCallback": { + "type": "string" + }, + "retentionDays": { + "type": "number" + }, + "cronJob": { + "type": "string" + }, + "thresholds": { + "type": "object", + "properties": { + "cpu": { + "type": "number" + }, + "memory": { + "type": "number" + } + }, + "required": ["cpu", "memory"], + "additionalProperties": false + } + }, + "required": [ + "type", + "refreshRate", + "port", + "token", + "urlCallback", + "retentionDays", + "cronJob", + "thresholds" + ], + "additionalProperties": false + }, + "containers": { + "type": "object", + "properties": { + "refreshRate": { + "type": "number" + }, + "services": { + "type": "object", + "properties": { + "include": { + "type": "array", + "items": { + "type": "string" + } + }, + "exclude": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["include", "exclude"], + "additionalProperties": false + } + }, + "required": ["refreshRate", "services"], + "additionalProperties": false + } + }, + "required": ["server", "containers"], + "additionalProperties": false + }, + "cleanupCacheApplications": { + "type": "boolean" + }, + "cleanupCacheOnPreviews": { + "type": "boolean" + }, + "cleanupCacheOnCompose": { + "type": "boolean" + }, + "stripeCustomerId": { + "type": "string", + "nullable": true + }, + "stripeSubscriptionId": { + "type": "string", + "nullable": true + }, + "serversQuantity": { + "type": "number" + }, + "password": { + "type": "string" + }, + "currentPassword": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getUserByToken": { + "get": { + "operationId": "user-getUserByToken", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "token", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getMetricsToken": { + "get": { + "operationId": "user-getMetricsToken", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.remove": { + "post": { + "operationId": "user-remove", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "userId": { + "type": "string" + } + }, + "required": ["userId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.assignPermissions": { + "post": { + "operationId": "user-assignPermissions", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "accessedProjects": { + "type": "array", + "items": { + "type": "string" + } + }, + "accessedEnvironments": { + "type": "array", + "items": { + "type": "string" + } + }, + "accessedServices": { + "type": "array", + "items": { + "type": "string" + } + }, + "canCreateProjects": { + "type": "boolean" + }, + "canCreateServices": { + "type": "boolean" + }, + "canDeleteProjects": { + "type": "boolean" + }, + "canDeleteServices": { + "type": "boolean" + }, + "canAccessToDocker": { + "type": "boolean" + }, + "canAccessToTraefikFiles": { + "type": "boolean" + }, + "canAccessToAPI": { + "type": "boolean" + }, + "canAccessToSSHKeys": { + "type": "boolean" + }, + "canAccessToGitProviders": { + "type": "boolean" + }, + "canDeleteEnvironments": { + "type": "boolean" + }, + "canCreateEnvironments": { + "type": "boolean" + } + }, + "required": [ + "id", + "accessedProjects", + "accessedEnvironments", + "accessedServices", + "canCreateProjects", + "canCreateServices", + "canDeleteProjects", + "canDeleteServices", + "canAccessToDocker", + "canAccessToTraefikFiles", + "canAccessToAPI", + "canAccessToSSHKeys", + "canAccessToGitProviders", + "canDeleteEnvironments", + "canCreateEnvironments" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getInvitations": { + "get": { + "operationId": "user-getInvitations", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.getContainerMetrics": { + "get": { + "operationId": "user-getContainerMetrics", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "url", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "token", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "appName", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "dataPoints", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.generateToken": { + "post": { + "operationId": "user-generateToken", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.deleteApiKey": { + "post": { + "operationId": "user-deleteApiKey", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "apiKeyId": { + "type": "string" + } + }, + "required": ["apiKeyId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.createApiKey": { + "post": { + "operationId": "user-createApiKey", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "prefix": { + "type": "string" + }, + "expiresIn": { + "type": "number" + }, + "metadata": { + "type": "object", + "properties": { + "organizationId": { + "type": "string" + } + }, + "required": ["organizationId"], + "additionalProperties": false + }, + "rateLimitEnabled": { + "type": "boolean" + }, + "rateLimitTimeWindow": { + "type": "number" + }, + "rateLimitMax": { + "type": "number" + }, + "remaining": { + "type": "number" + }, + "refillAmount": { + "type": "number" + }, + "refillInterval": { + "type": "number" + } + }, + "required": ["name", "metadata"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.checkUserOrganizations": { + "get": { + "operationId": "user-checkUserOrganizations", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "userId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/user.sendInvitation": { + "post": { + "operationId": "user-sendInvitation", + "tags": ["user"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "invitationId": { + "type": "string", + "minLength": 1 + }, + "notificationId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["invitationId", "notificationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.create": { + "post": { + "operationId": "domain-create", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "host": { + "type": "string", + "minLength": 1 + }, + "path": { + "type": "string", + "minLength": 1, + "nullable": true + }, + "port": { + "type": "number", + "minimum": 1, + "maximum": 65535, + "nullable": true + }, + "https": { + "type": "boolean" + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "certificateType": { + "type": "string", + "enum": ["letsencrypt", "none", "custom"] + }, + "customCertResolver": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "domainType": { + "type": "string", + "enum": ["compose", "application", "preview"], + "nullable": true + }, + "previewDeploymentId": { + "type": "string", + "nullable": true + }, + "internalPath": { + "type": "string", + "nullable": true + }, + "stripPath": { + "type": "boolean" + } + }, + "required": ["host"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.byApplicationId": { + "get": { + "operationId": "domain-byApplicationId", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.byComposeId": { + "get": { + "operationId": "domain-byComposeId", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.generateDomain": { + "post": { + "operationId": "domain-generateDomain", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appName": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": ["appName"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.canGenerateTraefikMeDomains": { + "get": { + "operationId": "domain-canGenerateTraefikMeDomains", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.update": { + "post": { + "operationId": "domain-update", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "host": { + "type": "string", + "minLength": 1 + }, + "path": { + "type": "string", + "minLength": 1, + "nullable": true + }, + "port": { + "type": "number", + "minimum": 1, + "maximum": 65535, + "nullable": true + }, + "https": { + "type": "boolean" + }, + "certificateType": { + "type": "string", + "enum": ["letsencrypt", "none", "custom"] + }, + "customCertResolver": { + "type": "string", + "nullable": true + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "domainType": { + "type": "string", + "enum": ["compose", "application", "preview"], + "nullable": true + }, + "internalPath": { + "type": "string", + "nullable": true + }, + "stripPath": { + "type": "boolean" + }, + "domainId": { + "type": "string" + } + }, + "required": ["host", "domainId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.one": { + "get": { + "operationId": "domain-one", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "domainId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.delete": { + "post": { + "operationId": "domain-delete", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "domainId": { + "type": "string" + } + }, + "required": ["domainId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/domain.validateDomain": { + "post": { + "operationId": "domain-validateDomain", + "tags": ["domain"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "domain": { + "type": "string" + }, + "serverIp": { + "type": "string" + } + }, + "required": ["domain"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.create": { + "post": { + "operationId": "destination-create", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "provider": { + "type": "string", + "nullable": true + }, + "accessKey": { + "type": "string" + }, + "bucket": { + "type": "string" + }, + "region": { + "type": "string" + }, + "endpoint": { + "type": "string" + }, + "secretAccessKey": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": [ + "name", + "provider", + "accessKey", + "bucket", + "region", + "endpoint", + "secretAccessKey" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.testConnection": { + "post": { + "operationId": "destination-testConnection", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "provider": { + "type": "string", + "nullable": true + }, + "accessKey": { + "type": "string" + }, + "bucket": { + "type": "string" + }, + "region": { + "type": "string" + }, + "endpoint": { + "type": "string" + }, + "secretAccessKey": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": [ + "name", + "provider", + "accessKey", + "bucket", + "region", + "endpoint", + "secretAccessKey" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.one": { + "get": { + "operationId": "destination-one", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "destinationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.all": { + "get": { + "operationId": "destination-all", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.remove": { + "post": { + "operationId": "destination-remove", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "destinationId": { + "type": "string" + } + }, + "required": ["destinationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/destination.update": { + "post": { + "operationId": "destination-update", + "tags": ["destination"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "accessKey": { + "type": "string" + }, + "bucket": { + "type": "string" + }, + "region": { + "type": "string" + }, + "endpoint": { + "type": "string" + }, + "secretAccessKey": { + "type": "string" + }, + "destinationId": { + "type": "string" + }, + "provider": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string" + } + }, + "required": [ + "name", + "accessKey", + "bucket", + "region", + "endpoint", + "secretAccessKey", + "destinationId", + "provider" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.create": { + "post": { + "operationId": "backup-create", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "schedule": { + "type": "string" + }, + "enabled": { + "type": "boolean", + "nullable": true + }, + "prefix": { + "type": "string", + "minLength": 1 + }, + "destinationId": { + "type": "string" + }, + "keepLatestCount": { + "type": "number", + "nullable": true + }, + "database": { + "type": "string", + "minLength": 1 + }, + "mariadbId": { + "type": "string", + "nullable": true + }, + "mysqlId": { + "type": "string", + "nullable": true + }, + "postgresId": { + "type": "string", + "nullable": true + }, + "mongoId": { + "type": "string", + "nullable": true + }, + "databaseType": { + "type": "string", + "enum": [ + "postgres", + "mariadb", + "mysql", + "mongo", + "web-server" + ] + }, + "userId": { + "type": "string", + "nullable": true + }, + "backupType": { + "type": "string", + "enum": ["database", "compose"] + }, + "composeId": { + "type": "string", + "nullable": true + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "metadata": { + "nullable": true + } + }, + "required": [ + "schedule", + "prefix", + "destinationId", + "database", + "databaseType" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.one": { + "get": { + "operationId": "backup-one", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "backupId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.update": { + "post": { + "operationId": "backup-update", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "schedule": { + "type": "string" + }, + "enabled": { + "type": "boolean", + "nullable": true + }, + "prefix": { + "type": "string", + "minLength": 1 + }, + "backupId": { + "type": "string" + }, + "destinationId": { + "type": "string" + }, + "database": { + "type": "string", + "minLength": 1 + }, + "keepLatestCount": { + "type": "number", + "nullable": true + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "metadata": { + "nullable": true + }, + "databaseType": { + "type": "string", + "enum": [ + "postgres", + "mariadb", + "mysql", + "mongo", + "web-server" + ] + } + }, + "required": [ + "schedule", + "prefix", + "backupId", + "destinationId", + "database", + "serviceName", + "databaseType" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.remove": { + "post": { + "operationId": "backup-remove", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupPostgres": { + "post": { + "operationId": "backup-manualBackupPostgres", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupMySql": { + "post": { + "operationId": "backup-manualBackupMySql", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupMariadb": { + "post": { + "operationId": "backup-manualBackupMariadb", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupCompose": { + "post": { + "operationId": "backup-manualBackupCompose", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupMongo": { + "post": { + "operationId": "backup-manualBackupMongo", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.manualBackupWebServer": { + "post": { + "operationId": "backup-manualBackupWebServer", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "backupId": { + "type": "string" + } + }, + "required": ["backupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/backup.listBackupFiles": { + "get": { + "operationId": "backup-listBackupFiles", + "tags": ["backup"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "destinationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "search", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/deployment.all": { + "get": { + "operationId": "deployment-all", + "tags": ["deployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/deployment.allByCompose": { + "get": { + "operationId": "deployment-allByCompose", + "tags": ["deployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "composeId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/deployment.allByServer": { + "get": { + "operationId": "deployment-allByServer", + "tags": ["deployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/deployment.allByType": { + "get": { + "operationId": "deployment-allByType", + "tags": ["deployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "type", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "application", + "compose", + "server", + "schedule", + "previewDeployment", + "backup", + "volumeBackup" + ] + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/deployment.killProcess": { + "post": { + "operationId": "deployment-killProcess", + "tags": ["deployment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "deploymentId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["deploymentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/previewDeployment.all": { + "get": { + "operationId": "previewDeployment-all", + "tags": ["previewDeployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/previewDeployment.delete": { + "post": { + "operationId": "previewDeployment-delete", + "tags": ["previewDeployment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "previewDeploymentId": { + "type": "string" + } + }, + "required": ["previewDeploymentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/previewDeployment.one": { + "get": { + "operationId": "previewDeployment-one", + "tags": ["previewDeployment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "previewDeploymentId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mounts.create": { + "post": { + "operationId": "mounts-create", + "tags": ["mounts"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["bind", "volume", "file"] + }, + "hostPath": { + "type": "string", + "nullable": true + }, + "volumeName": { + "type": "string", + "nullable": true + }, + "content": { + "type": "string", + "nullable": true + }, + "mountPath": { + "type": "string", + "minLength": 1 + }, + "serviceType": { + "type": "string", + "enum": [ + "application", + "postgres", + "mysql", + "mariadb", + "mongo", + "redis", + "compose" + ], + "default": "application" + }, + "filePath": { + "type": "string", + "nullable": true + }, + "serviceId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["type", "mountPath", "serviceId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mounts.remove": { + "post": { + "operationId": "mounts-remove", + "tags": ["mounts"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mountId": { + "type": "string" + } + }, + "required": ["mountId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mounts.one": { + "get": { + "operationId": "mounts-one", + "tags": ["mounts"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "mountId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mounts.update": { + "post": { + "operationId": "mounts-update", + "tags": ["mounts"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mountId": { + "type": "string", + "minLength": 1 + }, + "type": { + "type": "string", + "enum": ["bind", "volume", "file"] + }, + "hostPath": { + "type": "string", + "nullable": true + }, + "volumeName": { + "type": "string", + "nullable": true + }, + "filePath": { + "type": "string", + "nullable": true + }, + "content": { + "type": "string", + "nullable": true + }, + "serviceType": { + "type": "string", + "enum": [ + "application", + "postgres", + "mysql", + "mariadb", + "mongo", + "redis", + "compose" + ], + "default": "application" + }, + "mountPath": { + "type": "string", + "minLength": 1 + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "postgresId": { + "type": "string", + "nullable": true + }, + "mariadbId": { + "type": "string", + "nullable": true + }, + "mongoId": { + "type": "string", + "nullable": true + }, + "mysqlId": { + "type": "string", + "nullable": true + }, + "redisId": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + } + }, + "required": ["mountId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/mounts.allNamedByApplicationId": { + "get": { + "operationId": "mounts-allNamedByApplicationId", + "tags": ["mounts"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "applicationId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/certificates.create": { + "post": { + "operationId": "certificates-create", + "tags": ["certificates"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "certificateId": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "certificateData": { + "type": "string", + "minLength": 1 + }, + "privateKey": { + "type": "string", + "minLength": 1 + }, + "certificatePath": { + "type": "string" + }, + "autoRenew": { + "type": "boolean", + "nullable": true + }, + "organizationId": { + "type": "string" + }, + "serverId": { + "type": "string", + "nullable": true + } + }, + "required": [ + "name", + "certificateData", + "privateKey", + "organizationId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/certificates.one": { + "get": { + "operationId": "certificates-one", + "tags": ["certificates"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "certificateId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/certificates.remove": { + "post": { + "operationId": "certificates-remove", + "tags": ["certificates"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "certificateId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["certificateId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/certificates.all": { + "get": { + "operationId": "certificates-all", + "tags": ["certificates"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.reloadServer": { + "post": { + "operationId": "settings-reloadServer", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanRedis": { + "post": { + "operationId": "settings-cleanRedis", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.reloadRedis": { + "post": { + "operationId": "settings-reloadRedis", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.reloadTraefik": { + "post": { + "operationId": "settings-reloadTraefik", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.toggleDashboard": { + "post": { + "operationId": "settings-toggleDashboard", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "enableDashboard": { + "type": "boolean" + }, + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanUnusedImages": { + "post": { + "operationId": "settings-cleanUnusedImages", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanUnusedVolumes": { + "post": { + "operationId": "settings-cleanUnusedVolumes", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanStoppedContainers": { + "post": { + "operationId": "settings-cleanStoppedContainers", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanDockerBuilder": { + "post": { + "operationId": "settings-cleanDockerBuilder", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanDockerPrune": { + "post": { + "operationId": "settings-cleanDockerPrune", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanAll": { + "post": { + "operationId": "settings-cleanAll", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanMonitoring": { + "post": { + "operationId": "settings-cleanMonitoring", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.saveSSHPrivateKey": { + "post": { + "operationId": "settings-saveSSHPrivateKey", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "sshPrivateKey": { + "type": "string", + "nullable": true + } + }, + "required": ["sshPrivateKey"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.assignDomainServer": { + "post": { + "operationId": "settings-assignDomainServer", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "host": { + "type": "string", + "nullable": true + }, + "certificateType": { + "type": "string", + "enum": ["letsencrypt", "none", "custom"] + }, + "letsEncryptEmail": { + "type": "string", + "nullable": true + }, + "https": { + "type": "boolean" + } + }, + "required": ["host", "certificateType"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.cleanSSHPrivateKey": { + "post": { + "operationId": "settings-cleanSSHPrivateKey", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateDockerCleanup": { + "post": { + "operationId": "settings-updateDockerCleanup", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "enableDockerCleanup": { + "type": "boolean" + }, + "serverId": { + "type": "string" + } + }, + "required": ["enableDockerCleanup"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readTraefikConfig": { + "get": { + "operationId": "settings-readTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateTraefikConfig": { + "post": { + "operationId": "settings-updateTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "traefikConfig": { + "type": "string", + "minLength": 1 + } + }, + "required": ["traefikConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readWebServerTraefikConfig": { + "get": { + "operationId": "settings-readWebServerTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateWebServerTraefikConfig": { + "post": { + "operationId": "settings-updateWebServerTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "traefikConfig": { + "type": "string", + "minLength": 1 + } + }, + "required": ["traefikConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readMiddlewareTraefikConfig": { + "get": { + "operationId": "settings-readMiddlewareTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateMiddlewareTraefikConfig": { + "post": { + "operationId": "settings-updateMiddlewareTraefikConfig", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "traefikConfig": { + "type": "string", + "minLength": 1 + } + }, + "required": ["traefikConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getUpdateData": { + "post": { + "operationId": "settings-getUpdateData", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateServer": { + "post": { + "operationId": "settings-updateServer", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getDokployVersion": { + "get": { + "operationId": "settings-getDokployVersion", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getReleaseTag": { + "get": { + "operationId": "settings-getReleaseTag", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readDirectories": { + "get": { + "operationId": "settings-readDirectories", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateTraefikFile": { + "post": { + "operationId": "settings-updateTraefikFile", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "path": { + "type": "string", + "minLength": 1 + }, + "traefikConfig": { + "type": "string", + "minLength": 1 + }, + "serverId": { + "type": "string" + } + }, + "required": ["path", "traefikConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readTraefikFile": { + "get": { + "operationId": "settings-readTraefikFile", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "path", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getIp": { + "get": { + "operationId": "settings-getIp", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getOpenApiDocument": { + "get": { + "operationId": "settings-getOpenApiDocument", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.readTraefikEnv": { + "get": { + "operationId": "settings-readTraefikEnv", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.writeTraefikEnv": { + "post": { + "operationId": "settings-writeTraefikEnv", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "env": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": ["env"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.haveTraefikDashboardPortEnabled": { + "get": { + "operationId": "settings-haveTraefikDashboardPortEnabled", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.haveActivateRequests": { + "get": { + "operationId": "settings-haveActivateRequests", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.toggleRequests": { + "post": { + "operationId": "settings-toggleRequests", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "enable": { + "type": "boolean" + } + }, + "required": ["enable"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.isCloud": { + "get": { + "operationId": "settings-isCloud", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.isUserSubscribed": { + "get": { + "operationId": "settings-isUserSubscribed", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.health": { + "get": { + "operationId": "settings-health", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.setupGPU": { + "post": { + "operationId": "settings-setupGPU", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.checkGPUStatus": { + "get": { + "operationId": "settings-checkGPUStatus", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateTraefikPorts": { + "post": { + "operationId": "settings-updateTraefikPorts", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string" + }, + "additionalPorts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "targetPort": { + "type": "number" + }, + "publishedPort": { + "type": "number" + }, + "protocol": { + "type": "string", + "enum": ["tcp", "udp", "sctp"] + } + }, + "required": ["targetPort", "publishedPort", "protocol"], + "additionalProperties": false + } + } + }, + "required": ["additionalPorts"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getTraefikPorts": { + "get": { + "operationId": "settings-getTraefikPorts", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.updateLogCleanup": { + "post": { + "operationId": "settings-updateLogCleanup", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "cronExpression": { + "type": "string", + "nullable": true + } + }, + "required": ["cronExpression"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getLogCleanupStatus": { + "get": { + "operationId": "settings-getLogCleanupStatus", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/settings.getDokployCloudIps": { + "get": { + "operationId": "settings-getDokployCloudIps", + "tags": ["settings"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/security.create": { + "post": { + "operationId": "security-create", + "tags": ["security"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "applicationId": { + "type": "string" + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + } + }, + "required": ["applicationId", "username", "password"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/security.one": { + "get": { + "operationId": "security-one", + "tags": ["security"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "securityId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/security.delete": { + "post": { + "operationId": "security-delete", + "tags": ["security"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "securityId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["securityId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/security.update": { + "post": { + "operationId": "security-update", + "tags": ["security"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "securityId": { + "type": "string", + "minLength": 1 + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + } + }, + "required": ["securityId", "username", "password"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redirects.create": { + "post": { + "operationId": "redirects-create", + "tags": ["redirects"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "regex": { + "type": "string", + "minLength": 1 + }, + "replacement": { + "type": "string", + "minLength": 1 + }, + "permanent": { + "type": "boolean" + }, + "applicationId": { + "type": "string" + } + }, + "required": [ + "regex", + "replacement", + "permanent", + "applicationId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redirects.one": { + "get": { + "operationId": "redirects-one", + "tags": ["redirects"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "redirectId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redirects.delete": { + "post": { + "operationId": "redirects-delete", + "tags": ["redirects"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redirectId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["redirectId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/redirects.update": { + "post": { + "operationId": "redirects-update", + "tags": ["redirects"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "redirectId": { + "type": "string", + "minLength": 1 + }, + "regex": { + "type": "string", + "minLength": 1 + }, + "replacement": { + "type": "string", + "minLength": 1 + }, + "permanent": { + "type": "boolean" + } + }, + "required": ["redirectId", "regex", "replacement", "permanent"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/port.create": { + "post": { + "operationId": "port-create", + "tags": ["port"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "publishedPort": { + "type": "number" + }, + "publishMode": { + "type": "string", + "enum": ["ingress", "host"], + "default": "ingress" + }, + "targetPort": { + "type": "number" + }, + "protocol": { + "type": "string", + "enum": ["tcp", "udp"], + "default": "tcp" + }, + "applicationId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["publishedPort", "targetPort", "applicationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/port.one": { + "get": { + "operationId": "port-one", + "tags": ["port"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "portId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/port.delete": { + "post": { + "operationId": "port-delete", + "tags": ["port"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "portId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["portId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/port.update": { + "post": { + "operationId": "port-update", + "tags": ["port"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "portId": { + "type": "string", + "minLength": 1 + }, + "publishedPort": { + "type": "number" + }, + "publishMode": { + "type": "string", + "enum": ["ingress", "host"], + "default": "ingress" + }, + "targetPort": { + "type": "number" + }, + "protocol": { + "type": "string", + "enum": ["tcp", "udp"], + "default": "tcp" + } + }, + "required": ["portId", "publishedPort", "targetPort"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.create": { + "post": { + "operationId": "registry-create", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "registryName": { + "type": "string", + "minLength": 1 + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "registryUrl": { + "type": "string" + }, + "registryType": { + "type": "string", + "enum": ["cloud"] + }, + "imagePrefix": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string" + } + }, + "required": [ + "registryName", + "username", + "password", + "registryUrl", + "registryType", + "imagePrefix" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.remove": { + "post": { + "operationId": "registry-remove", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "registryId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["registryId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.update": { + "post": { + "operationId": "registry-update", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "registryId": { + "type": "string", + "minLength": 1 + }, + "registryName": { + "type": "string", + "minLength": 1 + }, + "imagePrefix": { + "type": "string", + "nullable": true + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "registryUrl": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "registryType": { + "type": "string", + "enum": ["cloud"] + }, + "organizationId": { + "type": "string", + "minLength": 1 + }, + "serverId": { + "type": "string" + } + }, + "required": ["registryId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.all": { + "get": { + "operationId": "registry-all", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.one": { + "get": { + "operationId": "registry-one", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "registryId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/registry.testRegistry": { + "post": { + "operationId": "registry-testRegistry", + "tags": ["registry"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "registryName": { + "type": "string" + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "registryUrl": { + "type": "string" + }, + "registryType": { + "type": "string", + "enum": ["cloud"] + }, + "imagePrefix": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string" + } + }, + "required": [ + "username", + "password", + "registryUrl", + "registryType" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/cluster.getNodes": { + "get": { + "operationId": "cluster-getNodes", + "tags": ["cluster"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/cluster.removeWorker": { + "post": { + "operationId": "cluster-removeWorker", + "tags": ["cluster"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "nodeId": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": ["nodeId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/cluster.addWorker": { + "get": { + "operationId": "cluster-addWorker", + "tags": ["cluster"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/cluster.addManager": { + "get": { + "operationId": "cluster-addManager", + "tags": ["cluster"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createSlack": { + "post": { + "operationId": "notification-createSlack", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "channel": { + "type": "string" + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverThreshold", + "webhookUrl", + "channel" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateSlack": { + "post": { + "operationId": "notification-updateSlack", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "channel": { + "type": "string" + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "slackId": { + "type": "string" + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "slackId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testSlackConnection": { + "post": { + "operationId": "notification-testSlackConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "channel": { + "type": "string" + } + }, + "required": ["webhookUrl", "channel"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createTelegram": { + "post": { + "operationId": "notification-createTelegram", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "botToken": { + "type": "string", + "minLength": 1 + }, + "chatId": { + "type": "string", + "minLength": 1 + }, + "messageThreadId": { + "type": "string" + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverThreshold", + "botToken", + "chatId", + "messageThreadId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateTelegram": { + "post": { + "operationId": "notification-updateTelegram", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "botToken": { + "type": "string", + "minLength": 1 + }, + "chatId": { + "type": "string", + "minLength": 1 + }, + "messageThreadId": { + "type": "string" + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "telegramId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "telegramId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testTelegramConnection": { + "post": { + "operationId": "notification-testTelegramConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "botToken": { + "type": "string", + "minLength": 1 + }, + "chatId": { + "type": "string", + "minLength": 1 + }, + "messageThreadId": { + "type": "string" + } + }, + "required": ["botToken", "chatId", "messageThreadId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createDiscord": { + "post": { + "operationId": "notification-createDiscord", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "decoration": { + "type": "boolean" + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverThreshold", + "webhookUrl", + "decoration" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateDiscord": { + "post": { + "operationId": "notification-updateDiscord", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "decoration": { + "type": "boolean" + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "discordId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "discordId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testDiscordConnection": { + "post": { + "operationId": "notification-testDiscordConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "decoration": { + "type": "boolean" + } + }, + "required": ["webhookUrl"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createEmail": { + "post": { + "operationId": "notification-createEmail", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "smtpServer": { + "type": "string", + "minLength": 1 + }, + "smtpPort": { + "type": "number", + "minimum": 1 + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "fromAddress": { + "type": "string", + "minLength": 1 + }, + "toAddresses": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverThreshold", + "smtpServer", + "smtpPort", + "username", + "password", + "fromAddress", + "toAddresses" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateEmail": { + "post": { + "operationId": "notification-updateEmail", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "smtpServer": { + "type": "string", + "minLength": 1 + }, + "smtpPort": { + "type": "number", + "minimum": 1 + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "fromAddress": { + "type": "string", + "minLength": 1 + }, + "toAddresses": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "emailId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "emailId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testEmailConnection": { + "post": { + "operationId": "notification-testEmailConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "smtpServer": { + "type": "string", + "minLength": 1 + }, + "smtpPort": { + "type": "number", + "minimum": 1 + }, + "username": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "minLength": 1 + }, + "toAddresses": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + "fromAddress": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "smtpServer", + "smtpPort", + "username", + "password", + "toAddresses", + "fromAddress" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.remove": { + "post": { + "operationId": "notification-remove", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "notificationId": { + "type": "string" + } + }, + "required": ["notificationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.one": { + "get": { + "operationId": "notification-one", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "notificationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.all": { + "get": { + "operationId": "notification-all", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.receiveNotification": { + "post": { + "operationId": "notification-receiveNotification", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "ServerType": { + "type": "string", + "enum": ["Dokploy", "Remote"], + "default": "Dokploy" + }, + "Type": { + "type": "string", + "enum": ["Memory", "CPU"] + }, + "Value": { + "type": "number" + }, + "Threshold": { + "type": "number" + }, + "Message": { + "type": "string" + }, + "Timestamp": { + "type": "string" + }, + "Token": { + "type": "string" + } + }, + "required": [ + "Type", + "Value", + "Threshold", + "Message", + "Timestamp", + "Token" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createGotify": { + "post": { + "operationId": "notification-createGotify", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "appToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + }, + "decoration": { + "type": "boolean" + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverUrl", + "appToken", + "priority", + "decoration" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateGotify": { + "post": { + "operationId": "notification-updateGotify", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "appToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + }, + "decoration": { + "type": "boolean" + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "gotifyId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "gotifyId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testGotifyConnection": { + "post": { + "operationId": "notification-testGotifyConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "appToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + }, + "decoration": { + "type": "boolean" + } + }, + "required": ["serverUrl", "appToken", "priority"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createNtfy": { + "post": { + "operationId": "notification-createNtfy", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "topic": { + "type": "string", + "minLength": 1 + }, + "accessToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverUrl", + "topic", + "accessToken", + "priority" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateNtfy": { + "post": { + "operationId": "notification-updateNtfy", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "topic": { + "type": "string", + "minLength": 1 + }, + "accessToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "ntfyId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "ntfyId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testNtfyConnection": { + "post": { + "operationId": "notification-testNtfyConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverUrl": { + "type": "string", + "minLength": 1 + }, + "topic": { + "type": "string", + "minLength": 1 + }, + "accessToken": { + "type": "string", + "minLength": 1 + }, + "priority": { + "type": "number", + "minimum": 1 + } + }, + "required": ["serverUrl", "topic", "accessToken", "priority"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.createLark": { + "post": { + "operationId": "notification-createLark", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "appBuildError", + "databaseBackup", + "dokployRestart", + "name", + "appDeploy", + "dockerCleanup", + "serverThreshold", + "webhookUrl" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.updateLark": { + "post": { + "operationId": "notification-updateLark", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "appBuildError": { + "type": "boolean" + }, + "databaseBackup": { + "type": "boolean" + }, + "dokployRestart": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "appDeploy": { + "type": "boolean" + }, + "dockerCleanup": { + "type": "boolean" + }, + "serverThreshold": { + "type": "boolean" + }, + "webhookUrl": { + "type": "string", + "minLength": 1 + }, + "notificationId": { + "type": "string", + "minLength": 1 + }, + "larkId": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["notificationId", "larkId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.testLarkConnection": { + "post": { + "operationId": "notification-testLarkConnection", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "webhookUrl": { + "type": "string", + "minLength": 1 + } + }, + "required": ["webhookUrl"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/notification.getEmailProviders": { + "get": { + "operationId": "notification-getEmailProviders", + "tags": ["notification"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.create": { + "post": { + "operationId": "sshKey-create", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "privateKey": { + "type": "string" + }, + "publicKey": { + "type": "string" + }, + "organizationId": { + "type": "string" + } + }, + "required": [ + "name", + "privateKey", + "publicKey", + "organizationId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.remove": { + "post": { + "operationId": "sshKey-remove", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "sshKeyId": { + "type": "string" + } + }, + "required": ["sshKeyId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.one": { + "get": { + "operationId": "sshKey-one", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "sshKeyId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.all": { + "get": { + "operationId": "sshKey-all", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.generate": { + "post": { + "operationId": "sshKey-generate", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["rsa", "ed25519"] + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/sshKey.update": { + "post": { + "operationId": "sshKey-update", + "tags": ["sshKey"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "lastUsedAt": { + "type": "string", + "nullable": true + }, + "sshKeyId": { + "type": "string" + } + }, + "required": ["sshKeyId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitProvider.getAll": { + "get": { + "operationId": "gitProvider-getAll", + "tags": ["gitProvider"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitProvider.remove": { + "post": { + "operationId": "gitProvider-remove", + "tags": ["gitProvider"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "gitProviderId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["gitProviderId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.create": { + "post": { + "operationId": "gitea-create", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "giteaId": { + "type": "string" + }, + "giteaUrl": { + "type": "string", + "minLength": 1 + }, + "redirectUri": { + "type": "string" + }, + "clientId": { + "type": "string" + }, + "clientSecret": { + "type": "string" + }, + "gitProviderId": { + "type": "string" + }, + "accessToken": { + "type": "string" + }, + "refreshToken": { + "type": "string" + }, + "expiresAt": { + "type": "number" + }, + "scopes": { + "type": "string" + }, + "lastAuthenticatedAt": { + "type": "number" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "giteaUsername": { + "type": "string" + }, + "organizationName": { + "type": "string" + } + }, + "required": ["giteaUrl", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.one": { + "get": { + "operationId": "gitea-one", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "giteaId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.giteaProviders": { + "get": { + "operationId": "gitea-giteaProviders", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.getGiteaRepositories": { + "get": { + "operationId": "gitea-getGiteaRepositories", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "giteaId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.getGiteaBranches": { + "get": { + "operationId": "gitea-getGiteaBranches", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "owner", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "repositoryName", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "giteaId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.testConnection": { + "post": { + "operationId": "gitea-testConnection", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "giteaId": { + "type": "string" + }, + "organizationName": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.update": { + "post": { + "operationId": "gitea-update", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "giteaId": { + "type": "string", + "minLength": 1 + }, + "giteaUrl": { + "type": "string", + "minLength": 1 + }, + "redirectUri": { + "type": "string" + }, + "clientId": { + "type": "string" + }, + "clientSecret": { + "type": "string" + }, + "gitProviderId": { + "type": "string" + }, + "accessToken": { + "type": "string" + }, + "refreshToken": { + "type": "string" + }, + "expiresAt": { + "type": "number" + }, + "scopes": { + "type": "string" + }, + "lastAuthenticatedAt": { + "type": "number" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "giteaUsername": { + "type": "string" + }, + "organizationName": { + "type": "string" + } + }, + "required": ["giteaId", "giteaUrl", "gitProviderId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitea.getGiteaUrl": { + "get": { + "operationId": "gitea-getGiteaUrl", + "tags": ["gitea"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "giteaId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.create": { + "post": { + "operationId": "bitbucket-create", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "bitbucketId": { + "type": "string" + }, + "bitbucketUsername": { + "type": "string" + }, + "bitbucketEmail": { + "type": "string", + "format": "email" + }, + "appPassword": { + "type": "string" + }, + "apiToken": { + "type": "string" + }, + "bitbucketWorkspaceName": { + "type": "string" + }, + "gitProviderId": { + "type": "string" + }, + "authId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + } + }, + "required": ["authId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.one": { + "get": { + "operationId": "bitbucket-one", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "bitbucketId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.bitbucketProviders": { + "get": { + "operationId": "bitbucket-bitbucketProviders", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.getBitbucketRepositories": { + "get": { + "operationId": "bitbucket-getBitbucketRepositories", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "bitbucketId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.getBitbucketBranches": { + "get": { + "operationId": "bitbucket-getBitbucketBranches", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "repo", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "bitbucketId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.testConnection": { + "post": { + "operationId": "bitbucket-testConnection", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "bitbucketId": { + "type": "string", + "minLength": 1 + }, + "bitbucketUsername": { + "type": "string" + }, + "bitbucketEmail": { + "type": "string", + "format": "email" + }, + "workspaceName": { + "type": "string" + }, + "apiToken": { + "type": "string" + }, + "appPassword": { + "type": "string" + } + }, + "required": ["bitbucketId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/bitbucket.update": { + "post": { + "operationId": "bitbucket-update", + "tags": ["bitbucket"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "bitbucketId": { + "type": "string", + "minLength": 1 + }, + "bitbucketUsername": { + "type": "string" + }, + "bitbucketEmail": { + "type": "string", + "format": "email" + }, + "appPassword": { + "type": "string" + }, + "apiToken": { + "type": "string" + }, + "bitbucketWorkspaceName": { + "type": "string" + }, + "gitProviderId": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "organizationId": { + "type": "string" + } + }, + "required": ["bitbucketId", "gitProviderId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.create": { + "post": { + "operationId": "gitlab-create", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "gitlabId": { + "type": "string" + }, + "gitlabUrl": { + "type": "string", + "minLength": 1 + }, + "applicationId": { + "type": "string" + }, + "redirectUri": { + "type": "string" + }, + "secret": { + "type": "string" + }, + "accessToken": { + "type": "string", + "nullable": true + }, + "refreshToken": { + "type": "string", + "nullable": true + }, + "groupName": { + "type": "string" + }, + "expiresAt": { + "type": "number", + "nullable": true + }, + "gitProviderId": { + "type": "string" + }, + "authId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + } + }, + "required": ["gitlabUrl", "authId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.one": { + "get": { + "operationId": "gitlab-one", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "gitlabId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.gitlabProviders": { + "get": { + "operationId": "gitlab-gitlabProviders", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.getGitlabRepositories": { + "get": { + "operationId": "gitlab-getGitlabRepositories", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "gitlabId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.getGitlabBranches": { + "get": { + "operationId": "gitlab-getGitlabBranches", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "query", + "required": false, + "schema": { + "type": "number" + } + }, + { + "name": "owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "repo", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "gitlabId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.testConnection": { + "post": { + "operationId": "gitlab-testConnection", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "gitlabId": { + "type": "string" + }, + "groupName": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/gitlab.update": { + "post": { + "operationId": "gitlab-update", + "tags": ["gitlab"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "gitlabId": { + "type": "string", + "minLength": 1 + }, + "gitlabUrl": { + "type": "string", + "minLength": 1 + }, + "applicationId": { + "type": "string" + }, + "redirectUri": { + "type": "string" + }, + "secret": { + "type": "string" + }, + "accessToken": { + "type": "string", + "nullable": true + }, + "refreshToken": { + "type": "string", + "nullable": true + }, + "groupName": { + "type": "string" + }, + "expiresAt": { + "type": "number", + "nullable": true + }, + "gitProviderId": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + }, + "required": ["gitlabId", "gitlabUrl", "gitProviderId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.one": { + "get": { + "operationId": "github-one", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "githubId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.getGithubRepositories": { + "get": { + "operationId": "github-getGithubRepositories", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "githubId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.getGithubBranches": { + "get": { + "operationId": "github-getGithubBranches", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "repo", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "owner", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "githubId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.githubProviders": { + "get": { + "operationId": "github-githubProviders", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.testConnection": { + "post": { + "operationId": "github-testConnection", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "githubId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["githubId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/github.update": { + "post": { + "operationId": "github-update", + "tags": ["github"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "githubId": { + "type": "string", + "minLength": 1 + }, + "githubAppName": { + "type": "string", + "minLength": 1 + }, + "githubAppId": { + "type": "number", + "nullable": true + }, + "githubClientId": { + "type": "string", + "nullable": true + }, + "githubClientSecret": { + "type": "string", + "nullable": true + }, + "githubInstallationId": { + "type": "string", + "nullable": true + }, + "githubPrivateKey": { + "type": "string", + "nullable": true + }, + "githubWebhookSecret": { + "type": "string", + "nullable": true + }, + "gitProviderId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "githubId", + "githubAppName", + "gitProviderId", + "name" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.create": { + "post": { + "operationId": "server-create", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "ipAddress": { + "type": "string" + }, + "port": { + "type": "number" + }, + "username": { + "type": "string" + }, + "sshKeyId": { + "type": "string", + "nullable": true + }, + "serverType": { + "type": "string", + "enum": ["deploy", "build"] + } + }, + "required": [ + "name", + "ipAddress", + "port", + "username", + "sshKeyId", + "serverType" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.one": { + "get": { + "operationId": "server-one", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.getDefaultCommand": { + "get": { + "operationId": "server-getDefaultCommand", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.all": { + "get": { + "operationId": "server-all", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.count": { + "get": { + "operationId": "server-count", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.withSSHKey": { + "get": { + "operationId": "server-withSSHKey", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.buildServers": { + "get": { + "operationId": "server-buildServers", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.setup": { + "post": { + "operationId": "server-setup", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["serverId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.validate": { + "get": { + "operationId": "server-validate", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.security": { + "get": { + "operationId": "server-security", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.setupMonitoring": { + "post": { + "operationId": "server-setupMonitoring", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string", + "minLength": 1 + }, + "metricsConfig": { + "type": "object", + "properties": { + "server": { + "type": "object", + "properties": { + "refreshRate": { + "type": "number", + "minimum": 2 + }, + "port": { + "type": "number", + "minimum": 1 + }, + "token": { + "type": "string" + }, + "urlCallback": { + "type": "string", + "format": "uri" + }, + "retentionDays": { + "type": "number", + "minimum": 1 + }, + "cronJob": { + "type": "string", + "minLength": 1 + }, + "thresholds": { + "type": "object", + "properties": { + "cpu": { + "type": "number", + "minimum": 0 + }, + "memory": { + "type": "number", + "minimum": 0 + } + }, + "required": ["cpu", "memory"], + "additionalProperties": false + } + }, + "required": [ + "refreshRate", + "port", + "token", + "urlCallback", + "retentionDays", + "cronJob", + "thresholds" + ], + "additionalProperties": false + }, + "containers": { + "type": "object", + "properties": { + "refreshRate": { + "type": "number", + "minimum": 2 + }, + "services": { + "type": "object", + "properties": { + "include": { + "type": "array", + "items": { + "type": "string" + } + }, + "exclude": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } + }, + "required": ["refreshRate", "services"], + "additionalProperties": false + } + }, + "required": ["server", "containers"], + "additionalProperties": false + } + }, + "required": ["serverId", "metricsConfig"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.remove": { + "post": { + "operationId": "server-remove", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "serverId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["serverId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.update": { + "post": { + "operationId": "server-update", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string", + "minLength": 1 + }, + "ipAddress": { + "type": "string" + }, + "port": { + "type": "number" + }, + "username": { + "type": "string" + }, + "sshKeyId": { + "type": "string", + "nullable": true + }, + "serverType": { + "type": "string", + "enum": ["deploy", "build"] + }, + "command": { + "type": "string" + } + }, + "required": [ + "name", + "serverId", + "ipAddress", + "port", + "username", + "sshKeyId", + "serverType" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.publicIp": { + "get": { + "operationId": "server-publicIp", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.getServerTime": { + "get": { + "operationId": "server-getServerTime", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/server.getServerMetrics": { + "get": { + "operationId": "server-getServerMetrics", + "tags": ["server"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "url", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "token", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "dataPoints", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/stripe.getProducts": { + "get": { + "operationId": "stripe-getProducts", + "tags": ["stripe"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/stripe.createCheckoutSession": { + "post": { + "operationId": "stripe-createCheckoutSession", + "tags": ["stripe"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "productId": { + "type": "string" + }, + "serverQuantity": { + "type": "number", + "minimum": 1 + }, + "isAnnual": { + "type": "boolean" + } + }, + "required": ["productId", "serverQuantity", "isAnnual"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/stripe.createCustomerPortalSession": { + "post": { + "operationId": "stripe-createCustomerPortalSession", + "tags": ["stripe"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/stripe.canCreateMoreServers": { + "get": { + "operationId": "stripe-canCreateMoreServers", + "tags": ["stripe"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/swarm.getNodes": { + "get": { + "operationId": "swarm-getNodes", + "tags": ["swarm"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/swarm.getNodeInfo": { + "get": { + "operationId": "swarm-getNodeInfo", + "tags": ["swarm"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "nodeId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/swarm.getNodeApps": { + "get": { + "operationId": "swarm-getNodeApps", + "tags": ["swarm"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "serverId", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.one": { + "get": { + "operationId": "ai-one", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "aiId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.getModels": { + "get": { + "operationId": "ai-getModels", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "apiUrl", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "apiKey", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.create": { + "post": { + "operationId": "ai-create", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "apiUrl": { + "type": "string", + "format": "uri" + }, + "apiKey": { + "type": "string" + }, + "model": { + "type": "string", + "minLength": 1 + }, + "isEnabled": { + "type": "boolean" + } + }, + "required": ["name", "apiUrl", "apiKey", "model", "isEnabled"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.update": { + "post": { + "operationId": "ai-update", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "aiId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "apiUrl": { + "type": "string", + "format": "uri" + }, + "apiKey": { + "type": "string" + }, + "model": { + "type": "string", + "minLength": 1 + }, + "isEnabled": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + } + }, + "required": ["aiId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.getAll": { + "get": { + "operationId": "ai-getAll", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.get": { + "get": { + "operationId": "ai-get", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "aiId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.delete": { + "post": { + "operationId": "ai-delete", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "aiId": { + "type": "string" + } + }, + "required": ["aiId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.suggest": { + "post": { + "operationId": "ai-suggest", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "aiId": { + "type": "string" + }, + "input": { + "type": "string" + }, + "serverId": { + "type": "string" + } + }, + "required": ["aiId", "input"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/ai.deploy": { + "post": { + "operationId": "ai-deploy", + "tags": ["ai"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "environmentId": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "string", + "minLength": 1 + }, + "dockerCompose": { + "type": "string", + "minLength": 1 + }, + "envVariables": { + "type": "string" + }, + "serverId": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string" + }, + "domains": { + "type": "array", + "items": { + "type": "object", + "properties": { + "host": { + "type": "string", + "minLength": 1 + }, + "port": { + "type": "number", + "minimum": 1 + }, + "serviceName": { + "type": "string", + "minLength": 1 + } + }, + "required": ["host", "port", "serviceName"], + "additionalProperties": false + } + }, + "configFiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "filePath": { + "type": "string", + "minLength": 1 + }, + "content": { + "type": "string", + "minLength": 1 + } + }, + "required": ["filePath", "content"], + "additionalProperties": false + } + } + }, + "required": [ + "environmentId", + "id", + "dockerCompose", + "envVariables", + "name", + "description" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.create": { + "post": { + "operationId": "organization-create", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "logo": { + "type": "string" + } + }, + "required": ["name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.all": { + "get": { + "operationId": "organization-all", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.one": { + "get": { + "operationId": "organization-one", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "organizationId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.update": { + "post": { + "operationId": "organization-update", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "organizationId": { + "type": "string" + }, + "name": { + "type": "string" + }, + "logo": { + "type": "string" + } + }, + "required": ["organizationId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.delete": { + "post": { + "operationId": "organization-delete", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "organizationId": { + "type": "string" + } + }, + "required": ["organizationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.allInvitations": { + "get": { + "operationId": "organization-allInvitations", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.removeInvitation": { + "post": { + "operationId": "organization-removeInvitation", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "invitationId": { + "type": "string" + } + }, + "required": ["invitationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/organization.setDefault": { + "post": { + "operationId": "organization-setDefault", + "tags": ["organization"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "organizationId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["organizationId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.create": { + "post": { + "operationId": "schedule-create", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "scheduleId": { + "type": "string" + }, + "name": { + "type": "string" + }, + "cronExpression": { + "type": "string" + }, + "appName": { + "type": "string" + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "shellType": { + "type": "string", + "enum": ["bash", "sh"] + }, + "scheduleType": { + "type": "string", + "enum": [ + "application", + "compose", + "server", + "dokploy-server" + ] + }, + "command": { + "type": "string" + }, + "script": { + "type": "string", + "nullable": true + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string", + "nullable": true + }, + "userId": { + "type": "string", + "nullable": true + }, + "enabled": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + } + }, + "required": ["name", "cronExpression", "command"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.update": { + "post": { + "operationId": "schedule-update", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "scheduleId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string" + }, + "cronExpression": { + "type": "string" + }, + "appName": { + "type": "string" + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "shellType": { + "type": "string", + "enum": ["bash", "sh"] + }, + "scheduleType": { + "type": "string", + "enum": [ + "application", + "compose", + "server", + "dokploy-server" + ] + }, + "command": { + "type": "string" + }, + "script": { + "type": "string", + "nullable": true + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + }, + "serverId": { + "type": "string", + "nullable": true + }, + "userId": { + "type": "string", + "nullable": true + }, + "enabled": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + } + }, + "required": ["scheduleId", "name", "cronExpression", "command"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.delete": { + "post": { + "operationId": "schedule-delete", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "scheduleId": { + "type": "string" + } + }, + "required": ["scheduleId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.list": { + "get": { + "operationId": "schedule-list", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "scheduleType", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": ["application", "compose", "server", "dokploy-server"] + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.one": { + "get": { + "operationId": "schedule-one", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "scheduleId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/schedule.runManually": { + "post": { + "operationId": "schedule-runManually", + "tags": ["schedule"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "scheduleId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["scheduleId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/rollback.delete": { + "post": { + "operationId": "rollback-delete", + "tags": ["rollback"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "rollbackId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["rollbackId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/rollback.rollback": { + "post": { + "operationId": "rollback-rollback", + "tags": ["rollback"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "rollbackId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["rollbackId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.list": { + "get": { + "operationId": "volumeBackups-list", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "volumeBackupType", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "application", + "postgres", + "mysql", + "mariadb", + "mongo", + "redis", + "compose" + ] + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.create": { + "post": { + "operationId": "volumeBackups-create", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "volumeName": { + "type": "string" + }, + "prefix": { + "type": "string" + }, + "serviceType": { + "type": "string", + "enum": [ + "application", + "postgres", + "mysql", + "mariadb", + "mongo", + "redis", + "compose" + ] + }, + "appName": { + "type": "string" + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "turnOff": { + "type": "boolean" + }, + "cronExpression": { + "type": "string" + }, + "keepLatestCount": { + "type": "number", + "nullable": true + }, + "enabled": { + "type": "boolean", + "nullable": true + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "postgresId": { + "type": "string", + "nullable": true + }, + "mariadbId": { + "type": "string", + "nullable": true + }, + "mongoId": { + "type": "string", + "nullable": true + }, + "mysqlId": { + "type": "string", + "nullable": true + }, + "redisId": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "destinationId": { + "type": "string" + } + }, + "required": [ + "name", + "volumeName", + "prefix", + "cronExpression", + "destinationId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.one": { + "get": { + "operationId": "volumeBackups-one", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "volumeBackupId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.delete": { + "post": { + "operationId": "volumeBackups-delete", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "volumeBackupId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["volumeBackupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.update": { + "post": { + "operationId": "volumeBackups-update", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "volumeName": { + "type": "string" + }, + "prefix": { + "type": "string" + }, + "serviceType": { + "type": "string", + "enum": [ + "application", + "postgres", + "mysql", + "mariadb", + "mongo", + "redis", + "compose" + ] + }, + "appName": { + "type": "string" + }, + "serviceName": { + "type": "string", + "nullable": true + }, + "turnOff": { + "type": "boolean" + }, + "cronExpression": { + "type": "string" + }, + "keepLatestCount": { + "type": "number", + "nullable": true + }, + "enabled": { + "type": "boolean", + "nullable": true + }, + "applicationId": { + "type": "string", + "nullable": true + }, + "postgresId": { + "type": "string", + "nullable": true + }, + "mariadbId": { + "type": "string", + "nullable": true + }, + "mongoId": { + "type": "string", + "nullable": true + }, + "mysqlId": { + "type": "string", + "nullable": true + }, + "redisId": { + "type": "string", + "nullable": true + }, + "composeId": { + "type": "string", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "destinationId": { + "type": "string" + }, + "volumeBackupId": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "name", + "volumeName", + "prefix", + "cronExpression", + "destinationId", + "volumeBackupId" + ], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/volumeBackups.runManually": { + "post": { + "operationId": "volumeBackups-runManually", + "tags": ["volumeBackups"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "volumeBackupId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["volumeBackupId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.create": { + "post": { + "operationId": "environment-create", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "projectId": { + "type": "string" + } + }, + "required": ["name", "projectId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.one": { + "get": { + "operationId": "environment-one", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "environmentId", + "in": "query", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.byProjectId": { + "get": { + "operationId": "environment-byProjectId", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "name": "projectId", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.remove": { + "post": { + "operationId": "environment-remove", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "environmentId": { + "type": "string", + "minLength": 1 + } + }, + "required": ["environmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.update": { + "post": { + "operationId": "environment-update", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "environmentId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "createdAt": { + "type": "string" + }, + "env": { + "type": "string" + }, + "projectId": { + "type": "string" + } + }, + "required": ["environmentId"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/environment.duplicate": { + "post": { + "operationId": "environment-duplicate", + "tags": ["environment"], + "security": [ + { + "Authorization": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "environmentId": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + } + }, + "required": ["environmentId", "name"], + "additionalProperties": false + } + } + } + }, + "parameters": [], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": {} + } + }, + "default": { + "$ref": "#/components/responses/error" + } + } + } + } + }, + "components": { + "securitySchemes": { + "apiKey": { + "type": "apiKey", + "in": "header", + "name": "x-api-key", + "description": "API key authentication. Generate an API key from your Dokploy dashboard under Settings > API Keys." + } + }, + "responses": { + "error": { + "description": "Error response", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "code": { + "type": "string" + }, + "issues": { + "type": "array", + "items": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": ["message"], + "additionalProperties": false + } + } + }, + "required": ["message", "code"], + "additionalProperties": false + } + } + } + } + } + }, + "tags": [ + { + "name": "admin" + }, + { + "name": "docker" + }, + { + "name": "compose" + }, + { + "name": "registry" + }, + { + "name": "cluster" + }, + { + "name": "user" + }, + { + "name": "domain" + }, + { + "name": "destination" + }, + { + "name": "backup" + }, + { + "name": "deployment" + }, + { + "name": "mounts" + }, + { + "name": "certificates" + }, + { + "name": "settings" + }, + { + "name": "security" + }, + { + "name": "redirects" + }, + { + "name": "port" + }, + { + "name": "project" + }, + { + "name": "application" + }, + { + "name": "mysql" + }, + { + "name": "postgres" + }, + { + "name": "redis" + }, + { + "name": "mongo" + }, + { + "name": "mariadb" + }, + { + "name": "sshRouter" + }, + { + "name": "gitProvider" + }, + { + "name": "bitbucket" + }, + { + "name": "github" + }, + { + "name": "gitlab" + }, + { + "name": "gitea" + }, + { + "name": "server" + }, + { + "name": "swarm" + }, + { + "name": "ai" + }, + { + "name": "organization" + }, + { + "name": "schedule" + }, + { + "name": "rollback" + }, + { + "name": "volumeBackups" + }, + { + "name": "environment" + } + ], + "externalDocs": { + "description": "Full documentation", + "url": "https://docs.dokploy.com" + }, + "security": [ + { + "apiKey": [] + } + ] +} diff --git a/package.json b/package.json index 684e40405..4ce1089eb 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "build": "pnpm -r run build", "format-and-lint": "biome check .", "check": "biome check --write --no-errors-on-unmatched --files-ignore-unknown=true", - "format-and-lint:fix": "biome check . --write" + "format-and-lint:fix": "biome check . --write", + "generate:openapi": "pnpm --filter=dokploy run generate:openapi" }, "devDependencies": { "@biomejs/biome": "2.1.1", diff --git a/packages/server/auth-schema.ts b/packages/server/auth-schema.ts index a58290467..517c71b41 100644 --- a/packages/server/auth-schema.ts +++ b/packages/server/auth-schema.ts @@ -6,7 +6,7 @@ // boolean, // } from "drizzle-orm/pg-core"; -// export const users_temp = pgTable("users_temp", { +// export const user = pgTable("user", { // id: text("id").primaryKey(), // name: text("name").notNull(), // email: text("email").notNull().unique(), @@ -29,7 +29,7 @@ // userAgent: text("user_agent"), // userId: text("user_id") // .notNull() -// .references(() => users_temp.id, { onDelete: "cascade" }), +// .references(() => user.id, { onDelete: "cascade" }), // activeOrganizationId: text("active_organization_id"), // }); @@ -39,7 +39,7 @@ // providerId: text("provider_id").notNull(), // userId: text("user_id") // .notNull() -// .references(() => users_temp.id, { onDelete: "cascade" }), +// .references(() => user.id, { onDelete: "cascade" }), // accessToken: text("access_token"), // refreshToken: text("refresh_token"), // idToken: text("id_token"), diff --git a/packages/server/package.json b/packages/server/package.json index 4d0f2e804..6a9b84f77 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -61,7 +61,7 @@ "lodash": "4.17.21", "micromatch": "4.0.8", "nanoid": "3.3.11", - "node-os-utils": "1.3.7", + "node-os-utils": "2.0.1", "node-pty": "1.0.0", "node-schedule": "2.1.1", "nodemailer": "6.9.14", @@ -75,6 +75,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "rotating-file-stream": "3.2.3", + "shell-quote": "^1.8.1", "slugify": "^1.6.6", "ssh2": "1.15.0", "toml": "3.0.0", @@ -88,12 +89,12 @@ "@types/lodash": "4.17.4", "@types/micromatch": "4.0.9", "@types/node": "^18.19.104", - "@types/node-os-utils": "1.3.4", "@types/node-schedule": "2.1.6", "@types/nodemailer": "^6.4.17", "@types/qrcode": "^1.5.5", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", + "@types/shell-quote": "^1.7.5", "@types/ssh2": "1.15.1", "@types/ws": "8.5.10", "drizzle-kit": "^0.30.6", diff --git a/packages/server/src/db/schema/account.ts b/packages/server/src/db/schema/account.ts index 3eb57b552..40789a4a3 100644 --- a/packages/server/src/db/schema/account.ts +++ b/packages/server/src/db/schema/account.ts @@ -9,7 +9,7 @@ import { import { nanoid } from "nanoid"; import { projects } from "./project"; import { server } from "./server"; -import { users_temp } from "./user"; +import { user } from "./user"; export const account = pgTable("account", { id: text("id") @@ -21,7 +21,7 @@ export const account = pgTable("account", { providerId: text("provider_id").notNull(), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), accessToken: text("access_token"), refreshToken: text("refresh_token"), idToken: text("id_token"), @@ -39,9 +39,9 @@ export const account = pgTable("account", { }); export const accountRelations = relations(account, ({ one }) => ({ - user: one(users_temp, { + user: one(user, { fields: [account.userId], - references: [users_temp.id], + references: [user.id], }), })); @@ -65,15 +65,15 @@ export const organization = pgTable("organization", { metadata: text("metadata"), ownerId: text("owner_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const organizationRelations = relations( organization, ({ one, many }) => ({ - owner: one(users_temp, { + owner: one(user, { fields: [organization.ownerId], - references: [users_temp.id], + references: [user.id], }), servers: many(server), projects: many(projects), @@ -90,10 +90,11 @@ export const member = pgTable("member", { .references(() => organization.id, { onDelete: "cascade" }), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), role: text("role").notNull().$type<"owner" | "member" | "admin">(), createdAt: timestamp("created_at").notNull(), teamId: text("team_id"), + isDefault: boolean("is_default").notNull().default(false), // Permissions canCreateProjects: boolean("canCreateProjects").notNull().default(false), canAccessToSSHKeys: boolean("canAccessToSSHKeys").notNull().default(false), @@ -108,6 +109,12 @@ export const member = pgTable("member", { canAccessToTraefikFiles: boolean("canAccessToTraefikFiles") .notNull() .default(false), + canDeleteEnvironments: boolean("canDeleteEnvironments") + .notNull() + .default(false), + canCreateEnvironments: boolean("canCreateEnvironments") + .notNull() + .default(false), accessedProjects: text("accesedProjects") .array() .notNull() @@ -127,9 +134,9 @@ export const memberRelations = relations(member, ({ one }) => ({ fields: [member.organizationId], references: [organization.id], }), - user: one(users_temp, { + user: one(user, { fields: [member.userId], - references: [users_temp.id], + references: [user.id], }), })); @@ -144,7 +151,7 @@ export const invitation = pgTable("invitation", { expiresAt: timestamp("expires_at").notNull(), inviterId: text("inviter_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), teamId: text("team_id"), }); @@ -161,7 +168,7 @@ export const twoFactor = pgTable("two_factor", { backupCodes: text("backup_codes").notNull(), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const apikey = pgTable("apikey", { @@ -172,7 +179,7 @@ export const apikey = pgTable("apikey", { key: text("key").notNull(), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), refillInterval: integer("refill_interval"), refillAmount: integer("refill_amount"), lastRefillAt: timestamp("last_refill_at"), @@ -191,8 +198,8 @@ export const apikey = pgTable("apikey", { }); export const apikeyRelations = relations(apikey, ({ one }) => ({ - user: one(users_temp, { + user: one(user, { fields: [apikey.userId], - references: [users_temp.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/application.ts b/packages/server/src/db/schema/application.ts index 6d176e737..11f2907f8 100644 --- a/packages/server/src/db/schema/application.ts +++ b/packages/server/src/db/schema/application.ts @@ -1,5 +1,6 @@ import { relations } from "drizzle-orm"; import { + bigint, boolean, integer, json, @@ -20,7 +21,6 @@ import { gitlab } from "./gitlab"; import { mounts } from "./mount"; import { ports } from "./port"; import { previewDeployments } from "./preview-deployments"; -import { projects } from "./project"; import { redirects } from "./redirects"; import { registry } from "./registry"; import { security } from "./security"; @@ -28,6 +28,8 @@ import { server } from "./server"; import { applicationStatus, certificateType, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -80,6 +82,7 @@ export const applications = pgTable("application", { previewEnv: text("previewEnv"), watchPaths: text("watchPaths").array(), previewBuildArgs: text("previewBuildArgs"), + previewBuildSecrets: text("previewBuildSecrets"), previewLabels: text("previewLabels").array(), previewWildcard: text("previewWildcard"), previewPort: integer("previewPort").default(3000), @@ -99,6 +102,7 @@ export const applications = pgTable("application", { ).default(true), rollbackActive: boolean("rollbackActive").default(false), buildArgs: text("buildArgs"), + buildSecrets: text("buildSecrets"), memoryReservation: text("memoryReservation"), memoryLimit: text("memoryLimit"), cpuReservation: text("cpuReservation"), @@ -107,6 +111,7 @@ export const applications = pgTable("application", { enabled: boolean("enabled"), subtitle: text("subtitle"), command: text("command"), + args: text("args").array(), refreshToken: text("refreshToken").$defaultFn(() => nanoid()), sourceType: sourceType("sourceType").notNull().default("github"), cleanCache: boolean("cleanCache").default(false), @@ -164,6 +169,8 @@ export const applications = pgTable("application", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), // replicas: integer("replicas").default(1).notNull(), applicationStatus: applicationStatus("applicationStatus") @@ -198,6 +205,15 @@ export const applications = pgTable("application", { serverId: text("serverId").references(() => server.serverId, { onDelete: "cascade", }), + buildServerId: text("buildServerId").references(() => server.serverId, { + onDelete: "set null", + }), + buildRegistryId: text("buildRegistryId").references( + () => registry.registryId, + { + onDelete: "set null", + }, + ), }); export const applicationsRelations = relations( @@ -220,6 +236,7 @@ export const applicationsRelations = relations( registry: one(registry, { fields: [applications.registryId], references: [registry.registryId], + relationName: "applicationRegistry", }), github: one(github, { fields: [applications.githubId], @@ -240,6 +257,17 @@ export const applicationsRelations = relations( server: one(server, { fields: [applications.serverId], references: [server.serverId], + relationName: "applicationServer", + }), + buildServer: one(server, { + fields: [applications.buildServerId], + references: [server.serverId], + relationName: "applicationBuildServer", + }), + buildRegistry: one(registry, { + fields: [applications.buildRegistryId], + references: [registry.registryId], + relationName: "applicationBuildRegistry", }), previewDeployments: many(previewDeployments), }), @@ -252,6 +280,7 @@ const createSchema = createInsertSchema(applications, { autoDeploy: z.boolean(), env: z.string().optional(), buildArgs: z.string().optional(), + buildSecrets: z.string().optional(), name: z.string().min(1), description: z.string().optional(), memoryReservation: z.string().optional(), @@ -265,6 +294,7 @@ const createSchema = createInsertSchema(applications, { username: z.string().optional(), isPreviewDeploymentsActive: z.boolean().optional(), password: z.string().optional(), + args: z.array(z.string()).optional(), registryUrl: z.string().optional(), customGitSSHKeyId: z.string().optional(), repository: z.string().optional(), @@ -303,6 +333,7 @@ const createSchema = createInsertSchema(applications, { previewPort: z.number().optional(), previewEnv: z.string().optional(), previewBuildArgs: z.string().optional(), + previewBuildSecrets: z.string().optional(), previewWildcard: z.string().optional(), previewLimit: z.number().optional(), previewHttps: z.boolean().optional(), @@ -312,6 +343,8 @@ const createSchema = createInsertSchema(applications, { watchPaths: z.array(z.string()).optional(), previewLabels: z.array(z.string()).optional(), cleanCache: z.boolean().optional(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreateApplication = createSchema.pick({ @@ -456,6 +489,7 @@ export const apiSaveEnvironmentVariables = createSchema applicationId: true, env: true, buildArgs: true, + buildSecrets: true, }) .required(); diff --git a/packages/server/src/db/schema/backups.ts b/packages/server/src/db/schema/backups.ts index 2359a40ad..9b4881924 100644 --- a/packages/server/src/db/schema/backups.ts +++ b/packages/server/src/db/schema/backups.ts @@ -19,7 +19,7 @@ import { mariadb } from "./mariadb"; import { mongo } from "./mongo"; import { mysql } from "./mysql"; import { postgres } from "./postgres"; -import { users_temp } from "./user"; +import { user } from "./user"; export const databaseType = pgEnum("databaseType", [ "postgres", "mariadb", @@ -74,7 +74,7 @@ export const backups = pgTable("backup", { mongoId: text("mongoId").references((): AnyPgColumn => mongo.mongoId, { onDelete: "cascade", }), - userId: text("userId").references(() => users_temp.id), + userId: text("userId").references(() => user.id), // Only for compose backups metadata: jsonb("metadata").$type< | { @@ -118,9 +118,9 @@ export const backupsRelations = relations(backups, ({ one, many }) => ({ fields: [backups.mongoId], references: [mongo.mongoId], }), - user: one(users_temp, { + user: one(user, { fields: [backups.userId], - references: [users_temp.id], + references: [user.id], }), compose: one(compose, { fields: [backups.composeId], diff --git a/packages/server/src/db/schema/compose.ts b/packages/server/src/db/schema/compose.ts index 958c2c32c..7b8e93c7a 100644 --- a/packages/server/src/db/schema/compose.ts +++ b/packages/server/src/db/schema/compose.ts @@ -12,7 +12,6 @@ import { gitea } from "./gitea"; import { github } from "./github"; import { gitlab } from "./gitlab"; import { mounts } from "./mount"; -import { projects } from "./project"; import { schedules } from "./schedule"; import { server } from "./server"; import { applicationStatus, triggerType } from "./shared"; diff --git a/packages/server/src/db/schema/deployment.ts b/packages/server/src/db/schema/deployment.ts index d6b0ddbcc..b950703c8 100644 --- a/packages/server/src/db/schema/deployment.ts +++ b/packages/server/src/db/schema/deployment.ts @@ -70,6 +70,9 @@ export const deployments = pgTable("deployment", { (): AnyPgColumn => volumeBackups.volumeBackupId, { onDelete: "cascade" }, ), + buildServerId: text("buildServerId").references(() => server.serverId, { + onDelete: "cascade", + }), }); export const deploymentsRelations = relations(deployments, ({ one }) => ({ @@ -84,6 +87,12 @@ export const deploymentsRelations = relations(deployments, ({ one }) => ({ server: one(server, { fields: [deployments.serverId], references: [server.serverId], + relationName: "deploymentServer", + }), + buildServer: one(server, { + fields: [deployments.buildServerId], + references: [server.serverId], + relationName: "deploymentBuildServer", }), previewDeployment: one(previewDeployments, { fields: [deployments.previewDeploymentId], @@ -115,6 +124,7 @@ const schema = createInsertSchema(deployments, { composeId: z.string(), description: z.string().optional(), previewDeploymentId: z.string(), + buildServerId: z.string(), }); export const apiCreateDeployment = schema diff --git a/packages/server/src/db/schema/git-provider.ts b/packages/server/src/db/schema/git-provider.ts index dafbc2dac..3d2c7027c 100644 --- a/packages/server/src/db/schema/git-provider.ts +++ b/packages/server/src/db/schema/git-provider.ts @@ -8,7 +8,7 @@ import { bitbucket } from "./bitbucket"; import { gitea } from "./gitea"; import { github } from "./github"; import { gitlab } from "./gitlab"; -import { users_temp } from "./user"; +import { user } from "./user"; export const gitProviderType = pgEnum("gitProviderType", [ "github", @@ -32,7 +32,7 @@ export const gitProvider = pgTable("git_provider", { .references(() => organization.id, { onDelete: "cascade" }), userId: text("userId") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const gitProviderRelations = relations(gitProvider, ({ one }) => ({ @@ -56,9 +56,9 @@ export const gitProviderRelations = relations(gitProvider, ({ one }) => ({ fields: [gitProvider.organizationId], references: [organization.id], }), - user: one(users_temp, { + user: one(user, { fields: [gitProvider.userId], - references: [users_temp.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/mariadb.ts b/packages/server/src/db/schema/mariadb.ts index 416c66e1c..c143a5547 100644 --- a/packages/server/src/db/schema/mariadb.ts +++ b/packages/server/src/db/schema/mariadb.ts @@ -1,5 +1,5 @@ import { relations } from "drizzle-orm"; -import { integer, json, pgTable, text } from "drizzle-orm/pg-core"; +import { bigint, integer, json, pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; @@ -9,6 +9,8 @@ import { mounts } from "./mount"; import { server } from "./server"; import { applicationStatus, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -43,6 +45,7 @@ export const mariadb = pgTable("mariadb", { databaseRootPassword: text("rootPassword").notNull(), dockerImage: text("dockerImage").notNull(), command: text("command"), + args: text("args").array(), env: text("env"), // RESOURCES memoryReservation: text("memoryReservation"), @@ -62,6 +65,8 @@ export const mariadb = pgTable("mariadb", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), createdAt: text("createdAt") .notNull() @@ -110,6 +115,7 @@ const createSchema = createInsertSchema(mariadb, { .optional(), dockerImage: z.string().default("mariadb:6"), command: z.string().optional(), + args: z.array(z.string()).optional(), env: z.string().optional(), memoryReservation: z.string().optional(), memoryLimit: z.string().optional(), @@ -128,6 +134,8 @@ const createSchema = createInsertSchema(mariadb, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreateMariaDB = createSchema diff --git a/packages/server/src/db/schema/mongo.ts b/packages/server/src/db/schema/mongo.ts index eb4661066..e760a880a 100644 --- a/packages/server/src/db/schema/mongo.ts +++ b/packages/server/src/db/schema/mongo.ts @@ -1,5 +1,12 @@ import { relations } from "drizzle-orm"; -import { boolean, integer, json, pgTable, text } from "drizzle-orm/pg-core"; +import { + bigint, + boolean, + integer, + json, + pgTable, + text, +} from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; @@ -9,6 +16,8 @@ import { mounts } from "./mount"; import { server } from "./server"; import { applicationStatus, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -41,6 +50,7 @@ export const mongo = pgTable("mongo", { databasePassword: text("databasePassword").notNull(), dockerImage: text("dockerImage").notNull(), command: text("command"), + args: text("args").array(), env: text("env"), memoryReservation: text("memoryReservation"), memoryLimit: text("memoryLimit"), @@ -58,6 +68,8 @@ export const mongo = pgTable("mongo", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), createdAt: text("createdAt") .notNull() @@ -99,6 +111,7 @@ const createSchema = createInsertSchema(mongo, { databaseUser: z.string().min(1), dockerImage: z.string().default("mongo:15"), command: z.string().optional(), + args: z.array(z.string()).optional(), env: z.string().optional(), memoryReservation: z.string().optional(), memoryLimit: z.string().optional(), @@ -118,6 +131,8 @@ const createSchema = createInsertSchema(mongo, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreateMongo = createSchema diff --git a/packages/server/src/db/schema/mysql.ts b/packages/server/src/db/schema/mysql.ts index 8f87bff1e..3e5c14b5e 100644 --- a/packages/server/src/db/schema/mysql.ts +++ b/packages/server/src/db/schema/mysql.ts @@ -1,5 +1,5 @@ import { relations } from "drizzle-orm"; -import { integer, json, pgTable, text } from "drizzle-orm/pg-core"; +import { bigint, integer, json, pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; @@ -9,6 +9,8 @@ import { mounts } from "./mount"; import { server } from "./server"; import { applicationStatus, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -43,6 +45,7 @@ export const mysql = pgTable("mysql", { databaseRootPassword: text("rootPassword").notNull(), dockerImage: text("dockerImage").notNull(), command: text("command"), + args: text("args").array(), env: text("env"), memoryReservation: text("memoryReservation"), memoryLimit: text("memoryLimit"), @@ -60,6 +63,8 @@ export const mysql = pgTable("mysql", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), createdAt: text("createdAt") .notNull() @@ -108,6 +113,7 @@ const createSchema = createInsertSchema(mysql, { .optional(), dockerImage: z.string().default("mysql:8"), command: z.string().optional(), + args: z.array(z.string()).optional(), env: z.string().optional(), memoryReservation: z.string().optional(), memoryLimit: z.string().optional(), @@ -125,6 +131,8 @@ const createSchema = createInsertSchema(mysql, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreateMySql = createSchema diff --git a/packages/server/src/db/schema/notification.ts b/packages/server/src/db/schema/notification.ts index b5e871c35..f7818b4cf 100644 --- a/packages/server/src/db/schema/notification.ts +++ b/packages/server/src/db/schema/notification.ts @@ -12,6 +12,7 @@ export const notificationType = pgEnum("notificationType", [ "email", "gotify", "ntfy", + "lark", ]); export const notifications = pgTable("notification", { @@ -48,6 +49,9 @@ export const notifications = pgTable("notification", { ntfyId: text("ntfyId").references(() => ntfy.ntfyId, { onDelete: "cascade", }), + larkId: text("larkId").references(() => lark.larkId, { + onDelete: "cascade", + }), organizationId: text("organizationId") .notNull() .references(() => organization.id, { onDelete: "cascade" }), @@ -116,6 +120,14 @@ export const ntfy = pgTable("ntfy", { priority: integer("priority").notNull().default(3), }); +export const lark = pgTable("lark", { + larkId: text("larkId") + .notNull() + .primaryKey() + .$defaultFn(() => nanoid()), + webhookUrl: text("webhookUrl").notNull(), +}); + export const notificationsRelations = relations(notifications, ({ one }) => ({ slack: one(slack, { fields: [notifications.slackId], @@ -141,6 +153,10 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({ fields: [notifications.ntfyId], references: [ntfy.ntfyId], }), + lark: one(lark, { + fields: [notifications.larkId], + references: [lark.larkId], + }), organization: one(organization, { fields: [notifications.organizationId], references: [organization.id], @@ -339,6 +355,31 @@ export const apiFindOneNotification = notificationsSchema }) .required(); +export const apiCreateLark = notificationsSchema + .pick({ + appBuildError: true, + databaseBackup: true, + dokployRestart: true, + name: true, + appDeploy: true, + dockerCleanup: true, + serverThreshold: true, + }) + .extend({ + webhookUrl: z.string().min(1), + }) + .required(); + +export const apiUpdateLark = apiCreateLark.partial().extend({ + notificationId: z.string().min(1), + larkId: z.string().min(1), + organizationId: z.string().optional(), +}); + +export const apiTestLarkConnection = apiCreateLark.pick({ + webhookUrl: true, +}); + export const apiSendTest = notificationsSchema .extend({ botToken: z.string(), diff --git a/packages/server/src/db/schema/postgres.ts b/packages/server/src/db/schema/postgres.ts index 961371b5c..d4ad7ad83 100644 --- a/packages/server/src/db/schema/postgres.ts +++ b/packages/server/src/db/schema/postgres.ts @@ -1,5 +1,5 @@ import { relations } from "drizzle-orm"; -import { integer, json, pgTable, text } from "drizzle-orm/pg-core"; +import { bigint, integer, json, pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; @@ -9,6 +9,8 @@ import { mounts } from "./mount"; import { server } from "./server"; import { applicationStatus, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -42,6 +44,7 @@ export const postgres = pgTable("postgres", { description: text("description"), dockerImage: text("dockerImage").notNull(), command: text("command"), + args: text("args").array(), env: text("env"), memoryReservation: text("memoryReservation"), externalPort: integer("externalPort"), @@ -60,6 +63,8 @@ export const postgres = pgTable("postgres", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), createdAt: text("createdAt") .notNull() @@ -99,6 +104,7 @@ const createSchema = createInsertSchema(postgres, { databaseUser: z.string().min(1), dockerImage: z.string().default("postgres:15"), command: z.string().optional(), + args: z.array(z.string()).optional(), env: z.string().optional(), memoryReservation: z.string().optional(), memoryLimit: z.string().optional(), @@ -118,6 +124,8 @@ const createSchema = createInsertSchema(postgres, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreatePostgres = createSchema diff --git a/packages/server/src/db/schema/redis.ts b/packages/server/src/db/schema/redis.ts index 29e40282d..a7528745d 100644 --- a/packages/server/src/db/schema/redis.ts +++ b/packages/server/src/db/schema/redis.ts @@ -1,14 +1,15 @@ import { relations } from "drizzle-orm"; -import { integer, json, pgTable, text } from "drizzle-orm/pg-core"; +import { bigint, integer, json, pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; import { environments } from "./environment"; import { mounts } from "./mount"; -import { projects } from "./project"; import { server } from "./server"; import { applicationStatus, + type EndpointSpecSwarm, + EndpointSpecSwarmSchema, type HealthCheckSwarm, HealthCheckSwarmSchema, type LabelsSwarm, @@ -40,6 +41,7 @@ export const redis = pgTable("redis", { databasePassword: text("password").notNull(), dockerImage: text("dockerImage").notNull(), command: text("command"), + args: text("args").array(), env: text("env"), memoryReservation: text("memoryReservation"), memoryLimit: text("memoryLimit"), @@ -60,6 +62,8 @@ export const redis = pgTable("redis", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), environmentId: text("environmentId") @@ -90,6 +94,7 @@ const createSchema = createInsertSchema(redis, { databasePassword: z.string(), dockerImage: z.string().default("redis:8"), command: z.string().optional(), + args: z.array(z.string()).optional(), env: z.string().optional(), memoryReservation: z.string().optional(), memoryLimit: z.string().optional(), @@ -108,6 +113,8 @@ const createSchema = createInsertSchema(redis, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), + endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); export const apiCreateRedis = createSchema diff --git a/packages/server/src/db/schema/registry.ts b/packages/server/src/db/schema/registry.ts index b18747095..6fe1d5285 100644 --- a/packages/server/src/db/schema/registry.ts +++ b/packages/server/src/db/schema/registry.ts @@ -33,7 +33,12 @@ export const registry = pgTable("registry", { }); export const registryRelations = relations(registry, ({ many }) => ({ - applications: many(applications), + applications: many(applications, { + relationName: "applicationRegistry", + }), + buildApplications: many(applications, { + relationName: "applicationBuildRegistry", + }), })); const createSchema = createInsertSchema(registry, { diff --git a/packages/server/src/db/schema/schedule.ts b/packages/server/src/db/schema/schedule.ts index 0f078ae79..80abc3524 100644 --- a/packages/server/src/db/schema/schedule.ts +++ b/packages/server/src/db/schema/schedule.ts @@ -7,7 +7,7 @@ import { applications } from "./application"; import { compose } from "./compose"; import { deployments } from "./deployment"; import { server } from "./server"; -import { users_temp } from "./user"; +import { user } from "./user"; import { generateAppName } from "./utils"; export const shellTypes = pgEnum("shellType", ["bash", "sh"]); @@ -45,7 +45,7 @@ export const schedules = pgTable("schedule", { serverId: text("serverId").references(() => server.serverId, { onDelete: "cascade", }), - userId: text("userId").references(() => users_temp.id, { + userId: text("userId").references(() => user.id, { onDelete: "cascade", }), enabled: boolean("enabled").notNull().default(true), @@ -69,9 +69,9 @@ export const schedulesRelations = relations(schedules, ({ one, many }) => ({ fields: [schedules.serverId], references: [server.serverId], }), - user: one(users_temp, { + user: one(user, { fields: [schedules.userId], - references: [users_temp.id], + references: [user.id], }), deployments: many(deployments), })); diff --git a/packages/server/src/db/schema/server.ts b/packages/server/src/db/schema/server.ts index 4313e95dd..176f35948 100644 --- a/packages/server/src/db/schema/server.ts +++ b/packages/server/src/db/schema/server.ts @@ -24,6 +24,7 @@ import { schedules } from "./schedule"; import { sshKeys } from "./ssh-key"; import { generateAppName } from "./utils"; export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]); +export const serverType = pgEnum("serverType", ["deploy", "build"]); export const server = pgTable("server", { serverId: text("serverId") @@ -44,6 +45,7 @@ export const server = pgTable("server", { .notNull() .references(() => organization.id, { onDelete: "cascade" }), serverStatus: serverStatus("serverStatus").notNull().default("active"), + serverType: serverType("serverType").notNull().default("deploy"), command: text("command").notNull().default(""), sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, { onDelete: "set null", @@ -97,12 +99,22 @@ export const server = pgTable("server", { }); export const serverRelations = relations(server, ({ one, many }) => ({ - deployments: many(deployments), + deployments: many(deployments, { + relationName: "deploymentServer", + }), + buildDeployments: many(deployments, { + relationName: "deploymentBuildServer", + }), sshKey: one(sshKeys, { fields: [server.sshKeyId], references: [sshKeys.sshKeyId], }), - applications: many(applications), + applications: many(applications, { + relationName: "applicationServer", + }), + buildApplications: many(applications, { + relationName: "applicationBuildServer", + }), compose: many(compose), redis: many(redis), mariadb: many(mariadb), @@ -131,6 +143,7 @@ export const apiCreateServer = createSchema port: true, username: true, sshKeyId: true, + serverType: true, }) .required(); @@ -155,6 +168,7 @@ export const apiUpdateServer = createSchema port: true, username: true, sshKeyId: true, + serverType: true, }) .required() .extend({ diff --git a/packages/server/src/db/schema/session.ts b/packages/server/src/db/schema/session.ts index f7c12dae0..971bb25bd 100644 --- a/packages/server/src/db/schema/session.ts +++ b/packages/server/src/db/schema/session.ts @@ -1,5 +1,5 @@ import { pgTable, text, timestamp } from "drizzle-orm/pg-core"; -import { users_temp } from "./user"; +import { user } from "./user"; // OLD TABLE export const session = pgTable("session_temp", { @@ -12,7 +12,7 @@ export const session = pgTable("session_temp", { userAgent: text("user_agent"), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), impersonatedBy: text("impersonated_by"), activeOrganizationId: text("active_organization_id"), }); diff --git a/packages/server/src/db/schema/shared.ts b/packages/server/src/db/schema/shared.ts index ab42aa1c1..600593d7a 100644 --- a/packages/server/src/db/schema/shared.ts +++ b/packages/server/src/db/schema/shared.ts @@ -74,6 +74,18 @@ export interface LabelsSwarm { [name: string]: string; } +export interface EndpointPortConfigSwarm { + Protocol?: string | undefined; + TargetPort?: number | undefined; + PublishedPort?: number | undefined; + PublishMode?: string | undefined; +} + +export interface EndpointSpecSwarm { + Mode?: string | undefined; + Ports?: EndpointPortConfigSwarm[] | undefined; +} + export const HealthCheckSwarmSchema = z .object({ Test: z.array(z.string()).optional(), @@ -161,3 +173,19 @@ export const NetworkSwarmSchema = z.array( ); export const LabelsSwarmSchema = z.record(z.string()); + +export const EndpointPortConfigSwarmSchema = z + .object({ + Protocol: z.string().optional(), + TargetPort: z.number().optional(), + PublishedPort: z.number().optional(), + PublishMode: z.string().optional(), + }) + .strict(); + +export const EndpointSpecSwarmSchema = z + .object({ + Mode: z.string().optional(), + Ports: z.array(EndpointPortConfigSwarmSchema).optional(), + }) + .strict(); diff --git a/packages/server/src/db/schema/user.ts b/packages/server/src/db/schema/user.ts index ca92f50e8..6627782df 100644 --- a/packages/server/src/db/schema/user.ts +++ b/packages/server/src/db/schema/user.ts @@ -26,7 +26,7 @@ import { certificateType } from "./shared"; // OLD TABLE // TEMP -export const users_temp = pgTable("user_temp", { +export const user = pgTable("user", { id: text("id") .notNull() .primaryKey() @@ -122,9 +122,9 @@ export const users_temp = pgTable("user_temp", { serversQuantity: integer("serversQuantity").notNull().default(0), }); -export const usersRelations = relations(users_temp, ({ one, many }) => ({ +export const usersRelations = relations(user, ({ one, many }) => ({ account: one(account, { - fields: [users_temp.id], + fields: [user.id], references: [account.userId], }), organizations: many(organization), @@ -134,7 +134,7 @@ export const usersRelations = relations(users_temp, ({ one, many }) => ({ schedules: many(schedules), })); -const createSchema = createInsertSchema(users_temp, { +const createSchema = createInsertSchema(user, { id: z.string().min(1), isRegistered: z.boolean().optional(), }).omit({ @@ -186,6 +186,8 @@ export const apiAssignPermissions = createSchema canAccessToAPI: z.boolean().optional(), canAccessToSSHKeys: z.boolean().optional(), canAccessToGitProviders: z.boolean().optional(), + canDeleteEnvironments: z.boolean().optional(), + canCreateEnvironments: z.boolean().optional(), }) .required(); diff --git a/packages/server/src/db/validations/domain.ts b/packages/server/src/db/validations/domain.ts index a10c96dcc..c032841e3 100644 --- a/packages/server/src/db/validations/domain.ts +++ b/packages/server/src/db/validations/domain.ts @@ -2,7 +2,13 @@ import { z } from "zod"; export const domain = z .object({ - host: z.string().min(1, { message: "Add a hostname" }), + host: z + .string() + .min(1, { message: "Add a hostname" }) + .refine((val) => val === val.trim(), { + message: "Domain name cannot have leading or trailing spaces", + }) + .transform((val) => val.trim()), path: z.string().min(1).optional(), internalPath: z.string().optional(), stripPath: z.boolean().optional(), @@ -58,7 +64,13 @@ export const domain = z export const domainCompose = z .object({ - host: z.string().min(1, { message: "Host is required" }), + host: z + .string() + .min(1, { message: "Add a hostname" }) + .refine((val) => val === val.trim(), { + message: "Domain name cannot have leading or trailing spaces", + }) + .transform((val) => val.trim()), path: z.string().min(1).optional(), internalPath: z.string().optional(), stripPath: z.boolean().optional(), diff --git a/packages/server/src/emails/emails/build-success.tsx b/packages/server/src/emails/emails/build-success.tsx index d9e500ab9..e5e1d1bb4 100644 --- a/packages/server/src/emails/emails/build-success.tsx +++ b/packages/server/src/emails/emails/build-success.tsx @@ -19,6 +19,7 @@ export type TemplateProps = { applicationType: string; buildLink: string; date: string; + environmentName: string; }; export const BuildSuccessEmail = ({ @@ -27,6 +28,7 @@ export const BuildSuccessEmail = ({ applicationType = "application", buildLink = "https://dokploy.com/projects/dokploy-test/applications/dokploy-test", date = "2023-05-01T00:00:00.000Z", + environmentName = "production", }: TemplateProps) => { const previewText = `Build success for ${applicationName}`; return ( @@ -74,6 +76,9 @@ export const BuildSuccessEmail = ({ Application Name: {applicationName} + + Environment: {environmentName} + Application Type: {applicationType} diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index a0dac2e00..e6d753293 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -68,7 +68,6 @@ export * from "./utils/backups/postgres"; export * from "./utils/backups/utils"; export * from "./utils/backups/web-server"; export * from "./utils/builders/compose"; -export * from "./utils/startup/cancell-deployments"; export * from "./utils/builders/docker-file"; export * from "./utils/builders/drop"; export * from "./utils/builders/heroku"; @@ -77,7 +76,6 @@ export * from "./utils/builders/nixpacks"; export * from "./utils/builders/paketo"; export * from "./utils/builders/static"; export * from "./utils/builders/utils"; - export * from "./utils/cluster/upload"; export * from "./utils/databases/rebuild"; export * from "./utils/docker/collision"; @@ -113,6 +111,8 @@ export * from "./utils/providers/raw"; export * from "./utils/schedules/index"; export * from "./utils/schedules/utils"; export * from "./utils/servers/remote-docker"; +export * from "./utils/startup/cancell-deployments"; +export * from "./utils/tracking/hubspot"; export * from "./utils/traefik/application"; export * from "./utils/traefik/domain"; export * from "./utils/traefik/file-types"; diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index 1561c6a2b..3ce060c58 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -10,6 +10,7 @@ import { db } from "../db"; import * as schema from "../db/schema"; import { getUserByToken } from "../services/admin"; import { updateUser } from "../services/user"; +import { getHubSpotUTK, submitToHubSpot } from "../utils/tracking/hubspot"; import { sendEmail } from "../verification/send-verification-email"; import { getPublicIpWithFallback } from "../wss/utils"; @@ -115,7 +116,7 @@ const { handler, api } = betterAuth({ } } }, - after: async (user) => { + after: async (user, context) => { const isAdminPresent = await db.query.member.findFirst({ where: eq(schema.member.role, "owner"), }); @@ -126,6 +127,27 @@ const { handler, api } = betterAuth({ }); } + if (IS_CLOUD) { + try { + const hutk = getHubSpotUTK( + context?.request?.headers?.get("cookie") || undefined, + ); + const hubspotSuccess = await submitToHubSpot( + { + email: user.email, + firstName: user.name, + lastName: user.name, + }, + hutk, + ); + if (!hubspotSuccess) { + console.error("Failed to submit to HubSpot"); + } + } catch (error) { + console.error("Error submitting to HubSpot", error); + } + } + if (IS_CLOUD || !isAdminPresent) { await db.transaction(async (tx) => { const organization = await tx @@ -143,6 +165,7 @@ const { handler, api } = betterAuth({ organizationId: organization?.id || "", role: "owner", createdAt: new Date(), + isDefault: true, // Mark first organization as default }); }); } @@ -152,9 +175,14 @@ const { handler, api } = betterAuth({ session: { create: { before: async (session) => { + // Find the default organization for this user + // Priority: 1) isDefault=true, 2) most recently created const member = await db.query.member.findFirst({ where: eq(schema.member.userId, session.userId), - orderBy: desc(schema.member.createdAt), + orderBy: [ + desc(schema.member.isDefault), + desc(schema.member.createdAt), + ], with: { organization: true, }, @@ -175,7 +203,7 @@ const { handler, api } = betterAuth({ updateAge: 60 * 60 * 24, }, user: { - modelName: "users_temp", + modelName: "user", additionalFields: { role: { type: "string", diff --git a/packages/server/src/monitoring/utils.ts b/packages/server/src/monitoring/utils.ts index 11ebb6169..2c42b99a6 100644 --- a/packages/server/src/monitoring/utils.ts +++ b/packages/server/src/monitoring/utils.ts @@ -1,5 +1,5 @@ import { promises } from "node:fs"; -import osUtils from "node-os-utils"; +import { OSUtils } from "node-os-utils"; import { paths } from "../constants"; export interface Container { @@ -38,22 +38,122 @@ export const recordAdvancedStats = async ( }); if (appName === "dokploy") { - const disk = await osUtils.drive.info("/"); + const osutils = new OSUtils(); + const diskResult = await osutils.disk.usageByMountPoint("/"); - const diskUsage = disk.usedGb; - const diskTotal = disk.totalGb; - const diskUsedPercentage = disk.usedPercentage; - const diskFree = disk.freeGb; + if (diskResult.success && diskResult.data) { + const disk = diskResult.data; + const diskUsage = disk.used.toGB().toFixed(2); + const diskTotal = disk.total.toGB().toFixed(2); + const diskUsedPercentage = disk.usagePercentage; + const diskFree = disk.available.toGB().toFixed(2); - await updateStatsFile(appName, "disk", { - diskTotal: +diskTotal, - diskUsedPercentage: +diskUsedPercentage, - diskUsage: +diskUsage, - diskFree: +diskFree, - }); + await updateStatsFile(appName, "disk", { + diskTotal: +diskTotal, + diskUsedPercentage: +diskUsedPercentage, + diskUsage: +diskUsage, + diskFree: +diskFree, + }); + } } }; +/** + * Get host system statistics using node-os-utils + * This is used when monitoring "dokploy" to show host stats instead of container stats + */ +export const getHostSystemStats = async (): Promise => { + const osutils = new OSUtils({ + disk: { + includeStats: true, // Enable disk I/O statistics + }, + }); + + // Get CPU usage + const cpuResult = await osutils.cpu.usage(); + const cpuUsage = cpuResult.success ? cpuResult.data : 0; + + // Get memory info + const memResult = await osutils.memory.info(); + let memUsedGB = 0; + let memTotalGB = 0; + let memUsedPercent = 0; + if (memResult.success) { + memTotalGB = memResult.data.total.toGB(); + memUsedGB = memResult.data.used.toGB(); + memUsedPercent = memResult.data.usagePercentage; + } + + // Get network stats from network.overview() + let netInputBytes = 0; + let netOutputBytes = 0; + const networkOverview = await osutils.network.overview(); + if (networkOverview.success) { + netInputBytes = networkOverview.data.totalRxBytes.toBytes(); + netOutputBytes = networkOverview.data.totalTxBytes.toBytes(); + } + + // Get Block I/O from disk.stats() + let blockReadBytes = 0; + let blockWriteBytes = 0; + const diskStats = await osutils.disk.stats(); + if (diskStats.success && diskStats.data.length > 0) { + // Filter out virtual devices (loop, ram, sr, etc.) - only include real disk devices + const excludePatterns = [/^loop/, /^ram/, /^sr\d+$/, /^fd\d+$/]; + for (const stat of diskStats.data) { + // Skip virtual devices + if ( + stat.device && + excludePatterns.some((pattern) => pattern.test(stat.device)) + ) { + continue; + } + // readBytes and writeBytes are DataSize objects with .toBytes() method + blockReadBytes += stat.readBytes.toBytes(); + blockWriteBytes += stat.writeBytes.toBytes(); + } + } + + // Format values similar to docker stats + const formatBytes = (bytes: number): string => { + if (bytes >= 1024 * 1024 * 1024) { + return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)}GiB`; + } + if (bytes >= 1024 * 1024) { + return `${(bytes / (1024 * 1024)).toFixed(2)}MiB`; + } + if (bytes >= 1024) { + return `${(bytes / 1024).toFixed(2)}KiB`; + } + return `${bytes}B`; + }; + + // Format memory usage similar to docker stats format: "used / total" + const memUsedFormatted = `${memUsedGB.toFixed(2)}GiB`; + const memTotalFormatted = `${memTotalGB.toFixed(2)}GiB`; + const memUsageFormatted = `${memUsedFormatted} / ${memTotalFormatted}`; + + // Format network I/O + const netInputMb = netInputBytes / (1024 * 1024); + const netOutputMb = netOutputBytes / (1024 * 1024); + const netIOFormatted = `${netInputMb.toFixed(2)}MB / ${netOutputMb.toFixed(2)}MB`; + + // Format Block I/O + const blockIOFormatted = `${formatBytes(blockReadBytes)} / ${formatBytes(blockWriteBytes)}`; + + // Create a stat object compatible with recordAdvancedStats + return { + CPUPerc: `${cpuUsage.toFixed(2)}%`, + MemPerc: `${memUsedPercent.toFixed(2)}%`, + MemUsage: memUsageFormatted, + BlockIO: blockIOFormatted, + NetIO: netIOFormatted, + Container: "dokploy", + ID: "host-system", + Name: "dokploy", + }; +}; + export const getAdvancedStats = async (appName: string) => { return { cpu: await readStatsFile(appName, "cpu"), diff --git a/packages/server/src/services/admin.ts b/packages/server/src/services/admin.ts index f6ce9614f..0cbb20785 100644 --- a/packages/server/src/services/admin.ts +++ b/packages/server/src/services/admin.ts @@ -3,26 +3,26 @@ import { invitation, member, organization, - users_temp, + user, } from "@dokploy/server/db/schema"; import { TRPCError } from "@trpc/server"; import { eq } from "drizzle-orm"; import { IS_CLOUD } from "../constants"; export const findUserById = async (userId: string) => { - const user = await db.query.users_temp.findFirst({ - where: eq(users_temp.id, userId), + const userResult = await db.query.user.findFirst({ + where: eq(user.id, userId), // with: { // account: true, // }, }); - if (!user) { + if (!userResult) { throw new TRPCError({ code: "NOT_FOUND", message: "User not found", }); } - return user; + return userResult; }; export const findOrganizationById = async (organizationId: string) => { @@ -64,7 +64,7 @@ export const findAdmin = async () => { }; export const getUserByToken = async (token: string) => { - const user = await db.query.invitation.findFirst({ + const userResult = await db.query.invitation.findFirst({ where: eq(invitation.id, token), columns: { id: true, @@ -76,29 +76,29 @@ export const getUserByToken = async (token: string) => { }, }); - if (!user) { + if (!userResult) { throw new TRPCError({ code: "NOT_FOUND", message: "Invitation not found", }); } - const userAlreadyExists = await db.query.users_temp.findFirst({ - where: eq(users_temp.email, user?.email || ""), + const userAlreadyExists = await db.query.user.findFirst({ + where: eq(user.email, userResult?.email || ""), }); - const { expiresAt, ...rest } = user; + const { expiresAt, ...rest } = userResult; return { ...rest, - isExpired: user.expiresAt < new Date(), + isExpired: userResult.expiresAt < new Date(), userAlreadyExists: !!userAlreadyExists, }; }; export const removeUserById = async (userId: string) => { await db - .delete(users_temp) - .where(eq(users_temp.id, userId)) + .delete(user) + .where(eq(user.id, userId)) .returning() .then((res) => res[0]); }; @@ -110,7 +110,8 @@ export const getDokployUrl = async () => { const admin = await findAdmin(); if (admin.user.host) { - return `https://${admin.user.host}`; + const protocol = admin.user.https ? "https" : "http"; + return `${protocol}://${admin.user.host}`; } return `http://${admin.user.serverIp}:${process.env.PORT}`; }; diff --git a/packages/server/src/services/application.ts b/packages/server/src/services/application.ts index e9cde27c5..c9c0bb765 100644 --- a/packages/server/src/services/application.ts +++ b/packages/server/src/services/application.ts @@ -7,37 +7,25 @@ import { } from "@dokploy/server/db/schema"; import { getAdvancedStats } from "@dokploy/server/monitoring/utils"; import { - buildApplication, getBuildCommand, mechanizeDockerContainer, } from "@dokploy/server/utils/builders"; import { sendBuildErrorNotifications } from "@dokploy/server/utils/notifications/build-error"; import { sendBuildSuccessNotifications } from "@dokploy/server/utils/notifications/build-success"; -import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync"; import { - cloneBitbucketRepository, - getBitbucketCloneCommand, -} from "@dokploy/server/utils/providers/bitbucket"; -import { - buildDocker, - buildRemoteDocker, -} from "@dokploy/server/utils/providers/docker"; + ExecError, + execAsync, + execAsyncRemote, +} from "@dokploy/server/utils/process/execAsync"; +import { cloneBitbucketRepository } from "@dokploy/server/utils/providers/bitbucket"; +import { buildRemoteDocker } from "@dokploy/server/utils/providers/docker"; import { cloneGitRepository, - getCustomGitCloneCommand, + getGitCommitInfo, } from "@dokploy/server/utils/providers/git"; -import { - cloneGiteaRepository, - getGiteaCloneCommand, -} from "@dokploy/server/utils/providers/gitea"; -import { - cloneGithubRepository, - getGithubCloneCommand, -} from "@dokploy/server/utils/providers/github"; -import { - cloneGitlabRepository, - getGitlabCloneCommand, -} from "@dokploy/server/utils/providers/gitlab"; +import { cloneGiteaRepository } from "@dokploy/server/utils/providers/gitea"; +import { cloneGithubRepository } from "@dokploy/server/utils/providers/github"; +import { cloneGitlabRepository } from "@dokploy/server/utils/providers/gitlab"; import { createTraefikConfig } from "@dokploy/server/utils/traefik/application"; import { TRPCError } from "@trpc/server"; import { eq } from "drizzle-orm"; @@ -46,6 +34,7 @@ import { getDokployUrl } from "./admin"; import { createDeployment, createDeploymentPreview, + updateDeployment, updateDeploymentStatus, } from "./deployment"; import { type Domain, getDomainHost } from "./domain"; @@ -123,6 +112,7 @@ export const findApplicationById = async (applicationId: string) => { gitea: true, server: true, previewDeployments: true, + buildRegistry: true, }, }); if (!application) { @@ -183,6 +173,7 @@ export const deployApplication = async ({ descriptionLog: string; }) => { const application = await findApplicationById(applicationId); + const serverId = application.buildServerId || application.serverId; const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`; const deployment = await createDeployment({ @@ -192,30 +183,31 @@ export const deployApplication = async ({ }); try { + let command = "set -e;"; if (application.sourceType === "github") { - await cloneGithubRepository({ - ...application, - logPath: deployment.logPath, - }); - await buildApplication(application, deployment.logPath); + command += await cloneGithubRepository(application); } else if (application.sourceType === "gitlab") { - await cloneGitlabRepository(application, deployment.logPath); - await buildApplication(application, deployment.logPath); + command += await cloneGitlabRepository(application); } else if (application.sourceType === "gitea") { - await cloneGiteaRepository(application, deployment.logPath); - await buildApplication(application, deployment.logPath); + command += await cloneGiteaRepository(application); } else if (application.sourceType === "bitbucket") { - await cloneBitbucketRepository(application, deployment.logPath); - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "docker") { - await buildDocker(application, deployment.logPath); + command += await cloneBitbucketRepository(application); } else if (application.sourceType === "git") { - await cloneGitRepository(application, deployment.logPath); - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "drop") { - await buildApplication(application, deployment.logPath); + command += await cloneGitRepository(application); + } else if (application.sourceType === "docker") { + command += await buildRemoteDocker(application); } + command += getBuildCommand(application); + + const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; + if (serverId) { + await execAsyncRemote(serverId, commandWithLog); + } else { + await execAsync(commandWithLog); + } + + await mechanizeDockerContainer(application); await updateDeploymentStatus(deployment.deploymentId, "done"); await updateApplicationStatus(applicationId, "done"); @@ -237,8 +229,24 @@ export const deployApplication = async ({ buildLink, organizationId: application.environment.project.organizationId, domains: application.domains, + environmentName: application.environment.name, }); } catch (error) { + let command = ""; + + // Only log details for non-ExecError errors + if (!(error instanceof ExecError)) { + const message = error instanceof Error ? error.message : String(error); + const encodedMessage = encodeBase64(message); + command += `echo "${encodedMessage}" | base64 -d >> "${deployment.logPath}";`; + } + + command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; + if (serverId) { + await execAsyncRemote(serverId, command); + } else { + await execAsync(command); + } await updateDeploymentStatus(deployment.deploymentId, "error"); await updateApplicationStatus(applicationId, "error"); @@ -253,8 +261,19 @@ export const deployApplication = async ({ }); throw error; - } + } finally { + // Only extract commit info for non-docker sources + if (application.sourceType !== "docker") { + const commitInfo = await getGitCommitInfo(application); + if (commitInfo) { + await updateDeployment(deployment.deploymentId, { + title: commitInfo.message, + description: `Commit: ${commitInfo.hash}`, + }); + } + } + } return true; }; @@ -268,50 +287,9 @@ export const rebuildApplication = async ({ descriptionLog: string; }) => { const application = await findApplicationById(applicationId); - - const deployment = await createDeployment({ - applicationId: applicationId, - title: titleLog, - description: descriptionLog, - }); - - try { - if (application.sourceType === "github") { - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "gitlab") { - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "bitbucket") { - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "docker") { - await buildDocker(application, deployment.logPath); - } else if (application.sourceType === "git") { - await buildApplication(application, deployment.logPath); - } else if (application.sourceType === "drop") { - await buildApplication(application, deployment.logPath); - } - await updateDeploymentStatus(deployment.deploymentId, "done"); - await updateApplicationStatus(applicationId, "done"); - } catch (error) { - await updateDeploymentStatus(deployment.deploymentId, "error"); - await updateApplicationStatus(applicationId, "error"); - throw error; - } - - return true; -}; - -export const deployRemoteApplication = async ({ - applicationId, - titleLog = "Manual deployment", - descriptionLog = "", -}: { - applicationId: string; - titleLog: string; - descriptionLog: string; -}) => { - const application = await findApplicationById(applicationId); - + const serverId = application.buildServerId || application.serverId; const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`; + const deployment = await createDeployment({ applicationId: applicationId, title: titleLog, @@ -319,39 +297,16 @@ export const deployRemoteApplication = async ({ }); try { - if (application.serverId) { - let command = "set -e;"; - if (application.sourceType === "github") { - command += await getGithubCloneCommand({ - ...application, - serverId: application.serverId, - logPath: deployment.logPath, - }); - } else if (application.sourceType === "gitlab") { - command += await getGitlabCloneCommand(application, deployment.logPath); - } else if (application.sourceType === "bitbucket") { - command += await getBitbucketCloneCommand( - application, - deployment.logPath, - ); - } else if (application.sourceType === "gitea") { - command += await getGiteaCloneCommand(application, deployment.logPath); - } else if (application.sourceType === "git") { - command += await getCustomGitCloneCommand( - application, - deployment.logPath, - ); - } else if (application.sourceType === "docker") { - command += await buildRemoteDocker(application, deployment.logPath); - } - - if (application.sourceType !== "docker") { - command += getBuildCommand(application, deployment.logPath); - } - await execAsyncRemote(application.serverId, command); - await mechanizeDockerContainer(application); + let command = "set -e;"; + // Check case for docker only + command += getBuildCommand(application); + const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; + if (serverId) { + await execAsyncRemote(serverId, commandWithLog); + } else { + await execAsync(commandWithLog); } - + await mechanizeDockerContainer(application); await updateDeploymentStatus(deployment.deploymentId, "done"); await updateApplicationStatus(applicationId, "done"); @@ -373,32 +328,26 @@ export const deployRemoteApplication = async ({ buildLink, organizationId: application.environment.project.organizationId, domains: application.domains, + environmentName: application.environment.name, }); } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + let command = ""; - const encodedContent = encodeBase64(errorMessage); - - await execAsyncRemote( - application.serverId, - ` - echo "\n\n===================================EXTRA LOGS============================================" >> ${deployment.logPath}; - echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath}; - echo "${encodedContent}" | base64 -d >> "${deployment.logPath}";`, - ); + // Only log details for non-ExecError errors + if (!(error instanceof ExecError)) { + const message = error instanceof Error ? error.message : String(error); + const encodedMessage = encodeBase64(message); + command += `echo "${encodedMessage}" | base64 -d >> "${deployment.logPath}";`; + } + command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; + if (serverId) { + await execAsyncRemote(serverId, command); + } else { + await execAsync(command); + } await updateDeploymentStatus(deployment.deploymentId, "error"); await updateApplicationStatus(applicationId, "error"); - - await sendBuildErrorNotifications({ - projectName: application.environment.project.name, - applicationName: application.name, - applicationType: "application", - errorMessage: `Please check the logs for details: ${errorMessage}`, - buildLink, - organizationId: application.environment.project.organizationId, - }); - throw error; } @@ -472,16 +421,25 @@ export const deployPreviewApplication = async ({ }); application.appName = previewDeployment.appName; application.env = `${application.previewEnv}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`; - application.buildArgs = application.previewBuildArgs; + application.buildArgs = `${application.previewBuildArgs}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`; + application.buildSecrets = `${application.previewBuildSecrets}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`; + let command = "set -e;"; if (application.sourceType === "github") { - await cloneGithubRepository({ + command += await cloneGithubRepository({ ...application, appName: previewDeployment.appName, branch: previewDeployment.branch, - logPath: deployment.logPath, }); - await buildApplication(application, deployment.logPath); + command += getBuildCommand(application); + + const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; + if (application.serverId) { + await execAsyncRemote(application.serverId, commandWithLog); + } else { + await execAsync(commandWithLog); + } + await mechanizeDockerContainer(application); } const successComment = getIssueComment( application.name, @@ -512,170 +470,10 @@ export const deployPreviewApplication = async ({ return true; }; -export const deployRemotePreviewApplication = async ({ - applicationId, - titleLog = "Preview Deployment", - descriptionLog = "", - previewDeploymentId, -}: { - applicationId: string; - titleLog: string; - descriptionLog: string; - previewDeploymentId: string; -}) => { - const application = await findApplicationById(applicationId); - - const deployment = await createDeploymentPreview({ - title: titleLog, - description: descriptionLog, - previewDeploymentId: previewDeploymentId, - }); - - const previewDeployment = - await findPreviewDeploymentById(previewDeploymentId); - - await updatePreviewDeployment(previewDeploymentId, { - createdAt: new Date().toISOString(), - }); - - const previewDomain = getDomainHost(previewDeployment?.domain as Domain); - const issueParams = { - owner: application?.owner || "", - repository: application?.repository || "", - issue_number: previewDeployment.pullRequestNumber, - comment_id: Number.parseInt(previewDeployment.pullRequestCommentId), - githubId: application?.githubId || "", - }; - try { - const commentExists = await issueCommentExists({ - ...issueParams, - }); - if (!commentExists) { - const result = await createPreviewDeploymentComment({ - ...issueParams, - previewDomain, - appName: previewDeployment.appName, - githubId: application?.githubId || "", - previewDeploymentId, - }); - - if (!result) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Pull request comment not found", - }); - } - - issueParams.comment_id = Number.parseInt(result?.pullRequestCommentId); - } - const buildingComment = getIssueComment( - application.name, - "running", - previewDomain, - ); - await updateIssueComment({ - ...issueParams, - body: `### Dokploy Preview Deployment\n\n${buildingComment}`, - }); - application.appName = previewDeployment.appName; - application.env = `${application.previewEnv}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`; - application.buildArgs = application.previewBuildArgs; - - if (application.serverId) { - let command = "set -e;"; - if (application.sourceType === "github") { - command += await getGithubCloneCommand({ - ...application, - appName: previewDeployment.appName, - branch: previewDeployment.branch, - serverId: application.serverId, - logPath: deployment.logPath, - }); - } - - command += getBuildCommand(application, deployment.logPath); - await execAsyncRemote(application.serverId, command); - await mechanizeDockerContainer(application); - } - - const successComment = getIssueComment( - application.name, - "success", - previewDomain, - ); - await updateIssueComment({ - ...issueParams, - body: `### Dokploy Preview Deployment\n\n${successComment}`, - }); - await updateDeploymentStatus(deployment.deploymentId, "done"); - await updatePreviewDeployment(previewDeploymentId, { - previewStatus: "done", - }); - } catch (error) { - const comment = getIssueComment(application.name, "error", previewDomain); - await updateIssueComment({ - ...issueParams, - body: `### Dokploy Preview Deployment\n\n${comment}`, - }); - await updateDeploymentStatus(deployment.deploymentId, "error"); - await updatePreviewDeployment(previewDeploymentId, { - previewStatus: "error", - }); - throw error; - } - - return true; -}; - -export const rebuildRemoteApplication = async ({ - applicationId, - titleLog = "Rebuild deployment", - descriptionLog = "", -}: { - applicationId: string; - titleLog: string; - descriptionLog: string; -}) => { - const application = await findApplicationById(applicationId); - - const deployment = await createDeployment({ - applicationId: applicationId, - title: titleLog, - description: descriptionLog, - }); - - try { - if (application.serverId) { - if (application.sourceType !== "docker") { - let command = "set -e;"; - command += getBuildCommand(application, deployment.logPath); - await execAsyncRemote(application.serverId, command); - } - await mechanizeDockerContainer(application); - } - await updateDeploymentStatus(deployment.deploymentId, "done"); - await updateApplicationStatus(applicationId, "done"); - } catch (error) { - // @ts-ignore - const encodedContent = encodeBase64(error?.message); - - await execAsyncRemote( - application.serverId, - ` - echo "\n\n===================================EXTRA LOGS============================================" >> ${deployment.logPath}; - echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath}; - echo "${encodedContent}" | base64 -d >> "${deployment.logPath}";`, - ); - - await updateDeploymentStatus(deployment.deploymentId, "error"); - await updateApplicationStatus(applicationId, "error"); - throw error; - } - - return true; -}; - export const getApplicationStats = async (appName: string) => { + if (appName === "dokploy") { + return await getAdvancedStats(appName); + } const filter = { status: ["running"], label: [`com.docker.swarm.service.name=${appName}`], diff --git a/packages/server/src/services/cdn.ts b/packages/server/src/services/cdn.ts index 1e19652c1..4d16531f1 100644 --- a/packages/server/src/services/cdn.ts +++ b/packages/server/src/services/cdn.ts @@ -78,7 +78,6 @@ const BUNNY_CDN_IPS = new Set([ "89.187.188.227", "89.187.188.228", "139.180.134.196", - "89.38.96.158", "89.187.162.249", "89.187.162.242", "185.102.217.65", @@ -106,12 +105,9 @@ const BUNNY_CDN_IPS = new Set([ "200.25.38.69", "200.25.42.70", "200.25.36.166", - "195.206.229.106", "194.242.11.186", - "185.164.35.8", "94.20.154.22", "185.93.1.244", - "156.59.145.154", "143.244.49.177", "138.199.46.66", "138.199.37.227", @@ -136,7 +132,6 @@ const BUNNY_CDN_IPS = new Set([ "84.17.59.115", "89.187.165.194", "138.199.15.193", - "89.35.237.170", "37.19.216.130", "185.93.1.247", "185.93.3.244", @@ -150,6 +145,7 @@ const BUNNY_CDN_IPS = new Set([ "84.17.63.178", "200.25.32.131", "37.19.207.34", + "37.19.207.38", "192.189.65.146", "143.244.45.177", "185.93.1.249", @@ -168,9 +164,7 @@ const BUNNY_CDN_IPS = new Set([ "129.227.217.178", "129.227.217.179", "200.25.69.94", - "128.1.52.179", "200.25.16.103", - "15.235.54.226", "102.67.138.155", "156.146.43.65", "195.181.163.203", @@ -278,13 +272,11 @@ const BUNNY_CDN_IPS = new Set([ "107.155.47.146", "193.201.190.174", "156.59.95.218", - "213.170.143.139", "129.227.186.154", "195.238.127.98", "200.25.22.6", "204.16.244.92", "200.25.70.101", - "200.25.66.100", "139.180.209.182", "103.108.231.41", "103.108.229.5", @@ -387,46 +379,13 @@ const BUNNY_CDN_IPS = new Set([ "38.54.5.37", "38.54.3.92", "185.165.170.74", - "207.121.80.118", - "207.121.46.228", - "207.121.46.236", - "207.121.46.244", - "207.121.46.252", - "216.202.235.164", - "207.121.46.220", "207.121.75.132", "207.121.80.12", "207.121.80.172", "207.121.90.60", - "207.121.90.68", - "207.121.97.204", - "207.121.90.252", - "207.121.97.236", - "207.121.99.12", "138.199.24.219", "185.93.2.251", "138.199.46.65", - "207.121.41.196", - "207.121.99.20", - "207.121.99.36", - "207.121.99.44", - "207.121.99.52", - "207.121.99.60", - "207.121.23.68", - "207.121.23.124", - "207.121.23.244", - "207.121.23.180", - "207.121.23.188", - "207.121.23.196", - "207.121.23.204", - "207.121.24.52", - "207.121.24.60", - "207.121.24.68", - "207.121.24.76", - "207.121.24.92", - "207.121.24.100", - "207.121.24.108", - "207.121.24.116", "154.95.86.76", "5.9.99.73", "78.46.92.118", @@ -434,14 +393,52 @@ const BUNNY_CDN_IPS = new Set([ "78.46.156.89", "88.198.9.155", "144.76.79.22", - "103.1.215.93", - "103.137.12.33", - "103.107.196.31", - "116.90.72.155", - "103.137.14.5", - "116.90.75.65", "37.19.207.37", "208.83.234.224", + "79.127.237.104", + "79.127.243.187", + "45.156.248.73", + "79.127.134.225", + "79.127.134.226", + "79.127.134.227", + "79.127.134.228", + "79.127.134.229", + "79.127.134.230", + "79.127.134.231", + "79.127.134.130", + "79.127.134.131", + "79.127.134.132", + "79.127.134.234", + "79.127.134.235", + "185.111.111.154", + "185.111.111.155", + "185.111.111.156", + "185.111.111.157", + "185.111.111.158", + "185.111.111.159", + "185.111.111.160", + "141.227.142.242", + "94.128.254.166", + "195.206.229.69", + "200.25.86.90", + "148.113.190.161", + "46.151.194.242", + "46.151.194.243", + "212.102.40.120", + "213.170.143.100", + "154.93.86.71", + "143.244.60.196", + "143.244.60.197", + "143.244.60.195", + "79.127.134.129", + "79.127.134.133", + "152.233.22.97", + "152.233.22.98", + "152.233.22.100", + "152.233.22.99", + "152.233.22.101", + "152.233.22.102", + "152.233.22.103", "116.202.155.146", "116.202.193.178", "116.202.224.168", @@ -502,6 +499,12 @@ const BUNNY_CDN_IPS = new Set([ "103.60.15.166", "103.60.15.167", "103.60.15.168", + "176.9.139.94", + "148.251.129.132", + "148.251.131.73", + "148.251.131.74", + "136.243.70.170", + "148.251.131.238", "109.248.43.116", "109.248.43.117", "109.248.43.162", @@ -527,7 +530,9 @@ const BUNNY_CDN_IPS = new Set([ "139.180.129.216", "139.99.174.7", "89.187.169.18", + "143.244.38.133", "89.187.179.7", + "169.150.213.50", "143.244.62.213", "185.93.3.246", "195.181.163.198", @@ -535,7 +540,6 @@ const BUNNY_CDN_IPS = new Set([ "84.17.37.211", "212.102.50.54", "212.102.46.115", - "143.244.38.135", "169.150.238.21", "169.150.207.51", "169.150.207.49", @@ -546,7 +550,6 @@ const BUNNY_CDN_IPS = new Set([ "169.150.247.139", "169.150.247.177", "169.150.247.178", - "169.150.213.49", "212.102.46.119", "84.17.38.234", "84.17.38.233", @@ -558,7 +561,6 @@ const BUNNY_CDN_IPS = new Set([ "169.150.247.138", "169.150.247.184", "169.150.247.185", - "156.146.58.83", "212.102.43.88", "89.187.169.26", "109.61.89.57", @@ -587,6 +589,17 @@ const BUNNY_CDN_IPS = new Set([ "138.199.4.177", "37.19.222.34", "46.151.193.85", + "79.127.237.99", + "212.104.158.30", + "212.104.158.31", + "212.104.158.32", + "212.104.158.33", + "212.104.158.34", + "212.104.158.28", + "212.104.158.29", + "212.104.158.35", + "212.104.158.36", + "212.104.158.37", "212.104.158.17", "212.104.158.18", "212.104.158.19", @@ -595,12 +608,20 @@ const BUNNY_CDN_IPS = new Set([ "212.104.158.22", "212.104.158.24", "212.104.158.26", - "79.127.237.134", "89.187.184.177", "89.187.184.179", "89.187.184.173", "89.187.184.178", "89.187.184.176", + "212.104.158.25", + "212.104.158.27", + "212.104.158.67", + "212.104.158.10", + "212.104.158.12", + "212.104.158.64", + "212.104.158.16", + "212.104.158.23", + "212.104.158.54", ]); // Arvancloud IP ranges @@ -616,6 +637,7 @@ const ARVANCLOUD_IP_RANGES = [ "37.32.18.0/27", "37.32.19.0/27", "185.215.232.0/22", + "178.131.120.48/28", ]; const CDN_PROVIDERS: CDNProvider[] = [ diff --git a/packages/server/src/services/compose.ts b/packages/server/src/services/compose.ts index 1436c52cc..89a12a156 100644 --- a/packages/server/src/services/compose.ts +++ b/packages/server/src/services/compose.ts @@ -7,14 +7,10 @@ import { cleanAppName, compose, } from "@dokploy/server/db/schema"; -import { - buildCompose, - getBuildComposeCommand, -} from "@dokploy/server/utils/builders/compose"; +import { getBuildComposeCommand } from "@dokploy/server/utils/builders/compose"; import { randomizeSpecificationFile } from "@dokploy/server/utils/docker/compose"; import { cloneCompose, - cloneComposeRemote, loadDockerCompose, loadDockerComposeRemote, } from "@dokploy/server/utils/docker/domain"; @@ -22,38 +18,28 @@ import type { ComposeSpecification } from "@dokploy/server/utils/docker/types"; import { sendBuildErrorNotifications } from "@dokploy/server/utils/notifications/build-error"; import { sendBuildSuccessNotifications } from "@dokploy/server/utils/notifications/build-success"; import { + ExecError, execAsync, execAsyncRemote, } from "@dokploy/server/utils/process/execAsync"; -import { - cloneBitbucketRepository, - getBitbucketCloneCommand, -} from "@dokploy/server/utils/providers/bitbucket"; +import { cloneBitbucketRepository } from "@dokploy/server/utils/providers/bitbucket"; import { cloneGitRepository, - getCustomGitCloneCommand, + getGitCommitInfo, } from "@dokploy/server/utils/providers/git"; -import { - cloneGiteaRepository, - getGiteaCloneCommand, -} from "@dokploy/server/utils/providers/gitea"; -import { - cloneGithubRepository, - getGithubCloneCommand, -} from "@dokploy/server/utils/providers/github"; -import { - cloneGitlabRepository, - getGitlabCloneCommand, -} from "@dokploy/server/utils/providers/gitlab"; -import { - createComposeFile, - getCreateComposeFileCommand, -} from "@dokploy/server/utils/providers/raw"; +import { cloneGiteaRepository } from "@dokploy/server/utils/providers/gitea"; +import { cloneGithubRepository } from "@dokploy/server/utils/providers/github"; +import { cloneGitlabRepository } from "@dokploy/server/utils/providers/gitlab"; +import { getCreateComposeFileCommand } from "@dokploy/server/utils/providers/raw"; import { TRPCError } from "@trpc/server"; import { eq } from "drizzle-orm"; import { encodeBase64 } from "../utils/docker/utils"; import { getDokployUrl } from "./admin"; -import { createDeploymentCompose, updateDeploymentStatus } from "./deployment"; +import { + createDeploymentCompose, + updateDeployment, + updateDeploymentStatus, +} from "./deployment"; import { validUniqueServerAppName } from "./project"; export type Compose = typeof compose.$inferSelect; @@ -163,10 +149,11 @@ export const loadServices = async ( const compose = await findComposeById(composeId); if (type === "fetch") { + const command = await cloneCompose(compose); if (compose.serverId) { - await cloneComposeRemote(compose); + await execAsyncRemote(compose.serverId, command); } else { - await cloneCompose(compose); + await execAsync(command); } } @@ -235,24 +222,41 @@ export const deployCompose = async ({ }); try { + const entity = { + ...compose, + type: "compose" as const, + }; + let command = "set -e;"; if (compose.sourceType === "github") { - await cloneGithubRepository({ - ...compose, - logPath: deployment.logPath, - type: "compose", - }); + command += await cloneGithubRepository(entity); } else if (compose.sourceType === "gitlab") { - await cloneGitlabRepository(compose, deployment.logPath, true); + command += await cloneGitlabRepository(entity); } else if (compose.sourceType === "bitbucket") { - await cloneBitbucketRepository(compose, deployment.logPath, true); + command += await cloneBitbucketRepository(entity); } else if (compose.sourceType === "git") { - await cloneGitRepository(compose, deployment.logPath, true); + command += await cloneGitRepository(entity); } else if (compose.sourceType === "gitea") { - await cloneGiteaRepository(compose, deployment.logPath, true); + command += await cloneGiteaRepository(entity); } else if (compose.sourceType === "raw") { - await createComposeFile(compose, deployment.logPath); + command += getCreateComposeFileCommand(entity); } - await buildCompose(compose, deployment.logPath); + + let commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; + if (compose.serverId) { + await execAsyncRemote(compose.serverId, commandWithLog); + } else { + await execAsync(commandWithLog); + } + + command = "set -e;"; + command += await getBuildComposeCommand(entity); + commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; + if (compose.serverId) { + await execAsyncRemote(compose.serverId, commandWithLog); + } else { + await execAsync(commandWithLog); + } + await updateDeploymentStatus(deployment.deploymentId, "done"); await updateCompose(composeId, { composeStatus: "done", @@ -265,8 +269,24 @@ export const deployCompose = async ({ buildLink, organizationId: compose.environment.project.organizationId, domains: compose.domains, + environmentName: compose.environment.name, }); } catch (error) { + let command = ""; + + // Only log details for non-ExecError errors + if (!(error instanceof ExecError)) { + const message = error instanceof Error ? error.message : String(error); + const encodedMessage = encodeBase64(message); + command += `echo "${encodedMessage}" | base64 -d >> "${deployment.logPath}";`; + } + + command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; + if (compose.serverId) { + await execAsyncRemote(compose.serverId, command); + } else { + await execAsync(command); + } await updateDeploymentStatus(deployment.deploymentId, "error"); await updateCompose(composeId, { composeStatus: "error", @@ -281,6 +301,19 @@ export const deployCompose = async ({ organizationId: compose.environment.project.organizationId, }); throw error; + } finally { + if (compose.sourceType !== "raw") { + const commitInfo = await getGitCommitInfo({ + ...compose, + type: "compose", + }); + if (commitInfo) { + await updateDeployment(deployment.deploymentId, { + title: commitInfo.message, + description: `Commit: ${commitInfo.hash}`, + }); + } + } } }; @@ -302,154 +335,23 @@ export const rebuildCompose = async ({ }); try { + let command = "set -e;"; if (compose.sourceType === "raw") { - await createComposeFile(compose, deployment.logPath); + command += getCreateComposeFileCommand(compose); } - await buildCompose(compose, deployment.logPath); - await updateDeploymentStatus(deployment.deploymentId, "done"); - await updateCompose(composeId, { - composeStatus: "done", - }); - } catch (error) { - await updateDeploymentStatus(deployment.deploymentId, "error"); - await updateCompose(composeId, { - composeStatus: "error", - }); - throw error; - } - - return true; -}; - -export const deployRemoteCompose = async ({ - composeId, - titleLog = "Manual deployment", - descriptionLog = "", -}: { - composeId: string; - titleLog: string; - descriptionLog: string; -}) => { - const compose = await findComposeById(composeId); - - const buildLink = `${await getDokployUrl()}/dashboard/project/${ - compose.environment.projectId - }/environment/${compose.environmentId}/services/compose/${compose.composeId}?tab=deployments`; - const deployment = await createDeploymentCompose({ - composeId: composeId, - title: titleLog, - description: descriptionLog, - }); - try { + let commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; if (compose.serverId) { - let command = "set -e;"; - - if (compose.sourceType === "github") { - command += await getGithubCloneCommand({ - ...compose, - logPath: deployment.logPath, - type: "compose", - serverId: compose.serverId, - }); - } else if (compose.sourceType === "gitlab") { - command += await getGitlabCloneCommand( - compose, - deployment.logPath, - true, - ); - } else if (compose.sourceType === "bitbucket") { - command += await getBitbucketCloneCommand( - compose, - deployment.logPath, - true, - ); - } else if (compose.sourceType === "git") { - command += await getCustomGitCloneCommand( - compose, - deployment.logPath, - true, - ); - console.log(command); - } else if (compose.sourceType === "raw") { - command += getCreateComposeFileCommand(compose, deployment.logPath); - } else if (compose.sourceType === "gitea") { - command += await getGiteaCloneCommand( - compose, - deployment.logPath, - true, - ); - } - - await execAsyncRemote(compose.serverId, command); - await getBuildComposeCommand(compose, deployment.logPath); - } - - await updateDeploymentStatus(deployment.deploymentId, "done"); - await updateCompose(composeId, { - composeStatus: "done", - }); - - await sendBuildSuccessNotifications({ - projectName: compose.environment.project.name, - applicationName: compose.name, - applicationType: "compose", - buildLink, - organizationId: compose.environment.project.organizationId, - domains: compose.domains, - }); - } catch (error) { - // @ts-ignore - const encodedContent = encodeBase64(error?.message); - - await execAsyncRemote( - compose.serverId, - ` - echo "\n\n===================================EXTRA LOGS============================================" >> ${deployment.logPath}; - echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath}; - echo "${encodedContent}" | base64 -d >> "${deployment.logPath}";`, - ); - await updateDeploymentStatus(deployment.deploymentId, "error"); - await updateCompose(composeId, { - composeStatus: "error", - }); - await sendBuildErrorNotifications({ - projectName: compose.environment.project.name, - applicationName: compose.name, - applicationType: "compose", - // @ts-ignore - errorMessage: error?.message || "Error building", - buildLink, - organizationId: compose.environment.project.organizationId, - }); - throw error; - } -}; - -export const rebuildRemoteCompose = async ({ - composeId, - titleLog = "Rebuild deployment", - descriptionLog = "", -}: { - composeId: string; - titleLog: string; - descriptionLog: string; -}) => { - const compose = await findComposeById(composeId); - - const deployment = await createDeploymentCompose({ - composeId: composeId, - title: titleLog, - description: descriptionLog, - }); - - try { - if (compose.sourceType === "raw") { - const command = getCreateComposeFileCommand(compose, deployment.logPath); - await execAsyncRemote(compose.serverId, command); + await execAsyncRemote(compose.serverId, commandWithLog); + } else { + await execAsync(commandWithLog); } + command += await getBuildComposeCommand(compose); + commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; if (compose.serverId) { - await getBuildComposeCommand(compose, deployment.logPath); + await execAsyncRemote(compose.serverId, commandWithLog); + } else { + await execAsync(commandWithLog); } await updateDeploymentStatus(deployment.deploymentId, "done"); @@ -457,16 +359,21 @@ export const rebuildRemoteCompose = async ({ composeStatus: "done", }); } catch (error) { - // @ts-ignore - const encodedContent = encodeBase64(error?.message); + let command = ""; - await execAsyncRemote( - compose.serverId, - ` - echo "\n\n===================================EXTRA LOGS============================================" >> ${deployment.logPath}; - echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath}; - echo "${encodedContent}" | base64 -d >> "${deployment.logPath}";`, - ); + // Only log details for non-ExecError errors + if (!(error instanceof ExecError)) { + const message = error instanceof Error ? error.message : String(error); + const encodedMessage = encodeBase64(message); + command += `echo "${encodedMessage}" | base64 -d >> "${deployment.logPath}";`; + } + + command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; + if (compose.serverId) { + await execAsyncRemote(compose.serverId, command); + } else { + await execAsync(command); + } await updateDeploymentStatus(deployment.deploymentId, "error"); await updateCompose(composeId, { composeStatus: "error", @@ -501,7 +408,7 @@ export const removeCompose = async ( } else { const command = ` docker network disconnect ${compose.appName} dokploy-traefik; - cd ${projectPath} && docker compose -p ${compose.appName} down ${ + cd ${projectPath} && env -i PATH="$PATH" docker compose -p ${compose.appName} down ${ deleteVolumes ? "--volumes" : "" } && rm -rf ${projectPath}`; @@ -528,7 +435,7 @@ export const startCompose = async (composeId: string) => { const projectPath = join(COMPOSE_PATH, compose.appName, "code"); const path = compose.sourceType === "raw" ? "docker-compose.yml" : compose.composePath; - const baseCommand = `docker compose -p ${compose.appName} -f ${path} up -d`; + const baseCommand = `env -i PATH="$PATH" docker compose -p ${compose.appName} -f ${path} up -d`; if (compose.composeType === "docker-compose") { if (compose.serverId) { await execAsyncRemote( @@ -563,14 +470,17 @@ export const stopCompose = async (composeId: string) => { if (compose.serverId) { await execAsyncRemote( compose.serverId, - `cd ${join(COMPOSE_PATH, compose.appName)} && docker compose -p ${ + `cd ${join(COMPOSE_PATH, compose.appName)} && env -i PATH="$PATH" docker compose -p ${ compose.appName } stop`, ); } else { - await execAsync(`docker compose -p ${compose.appName} stop`, { - cwd: join(COMPOSE_PATH, compose.appName), - }); + await execAsync( + `env -i PATH="$PATH" docker compose -p ${compose.appName} stop`, + { + cwd: join(COMPOSE_PATH, compose.appName), + }, + ); } } diff --git a/packages/server/src/services/deployment.ts b/packages/server/src/services/deployment.ts index ed03b32fc..6244ec8eb 100644 --- a/packages/server/src/services/deployment.ts +++ b/packages/server/src/services/deployment.ts @@ -74,24 +74,26 @@ export const createDeployment = async ( >, ) => { const application = await findApplicationById(deployment.applicationId); - try { await removeLastTenDeployments( deployment.applicationId, "application", application.serverId, ); - const { LOGS_PATH } = paths(!!application.serverId); + const serverId = application.buildServerId || application.serverId; + + const { LOGS_PATH } = paths(!!serverId); const formattedDateTime = format(new Date(), "yyyy-MM-dd:HH:mm:ss"); const fileName = `${application.appName}-${formattedDateTime}.log`; const logFilePath = path.join(LOGS_PATH, application.appName, fileName); - if (application.serverId) { - const server = await findServerById(application.serverId); + if (serverId) { + const server = await findServerById(serverId); const command = ` mkdir -p ${LOGS_PATH}/${application.appName}; echo "Initializing deployment" >> ${logFilePath}; + echo "Building on ${serverId ? "Build Server" : "Dokploy Server"}" >> ${logFilePath}; `; await execAsyncRemote(server.serverId, command); @@ -99,7 +101,7 @@ export const createDeployment = async ( await fsPromises.mkdir(path.join(LOGS_PATH, application.appName), { recursive: true, }); - await fsPromises.writeFile(logFilePath, "Initializing deployment"); + await fsPromises.writeFile(logFilePath, "Initializing deployment\n"); } const deploymentCreate = await db @@ -111,6 +113,9 @@ export const createDeployment = async ( logPath: logFilePath, description: deployment.description || "", startedAt: new Date().toISOString(), + ...(application.buildServerId && { + buildServerId: application.buildServerId, + }), }) .returning(); if (deploymentCreate.length === 0 || !deploymentCreate[0]) { @@ -249,7 +254,7 @@ export const createDeploymentCompose = async ( const command = ` mkdir -p ${LOGS_PATH}/${compose.appName}; -echo "Initializing deployment" >> ${logFilePath}; +echo "Initializing deployment\n" >> ${logFilePath}; `; await execAsyncRemote(server.serverId, command); @@ -257,7 +262,7 @@ echo "Initializing deployment" >> ${logFilePath}; await fsPromises.mkdir(path.join(LOGS_PATH, compose.appName), { recursive: true, }); - await fsPromises.writeFile(logFilePath, "Initializing deployment"); + await fsPromises.writeFile(logFilePath, "Initializing deployment\n"); } const deploymentCreate = await db diff --git a/packages/server/src/services/domain.ts b/packages/server/src/services/domain.ts index f81fffb96..50888e546 100644 --- a/packages/server/src/services/domain.ts +++ b/packages/server/src/services/domain.ts @@ -19,6 +19,7 @@ export const createDomain = async (input: typeof apiCreateDomain._type) => { .insert(domains) .values({ ...input, + host: input.host?.trim(), }) .returning() .then((response) => response[0]); @@ -120,6 +121,7 @@ export const updateDomainById = async ( .update(domains) .set({ ...domainData, + ...(domainData.host && { host: domainData.host.trim() }), }) .where(eq(domains.domainId, domainId)) .returning(); diff --git a/packages/server/src/services/environment.ts b/packages/server/src/services/environment.ts index 1d77510be..fb1952818 100644 --- a/packages/server/src/services/environment.ts +++ b/packages/server/src/services/environment.ts @@ -34,13 +34,43 @@ export const findEnvironmentById = async (environmentId: string) => { const environment = await db.query.environments.findFirst({ where: eq(environments.environmentId, environmentId), with: { - applications: true, - mariadb: true, - mongo: true, - mysql: true, - postgres: true, - redis: true, - compose: true, + applications: { + with: { + deployments: true, + server: true, + }, + }, + mariadb: { + with: { + server: true, + }, + }, + mongo: { + with: { + server: true, + }, + }, + mysql: { + with: { + server: true, + }, + }, + postgres: { + with: { + server: true, + }, + }, + redis: { + with: { + server: true, + }, + }, + compose: { + with: { + deployments: true, + server: true, + }, + }, project: true, }, }); diff --git a/packages/server/src/services/notification.ts b/packages/server/src/services/notification.ts index efd52061c..9eaf812e0 100644 --- a/packages/server/src/services/notification.ts +++ b/packages/server/src/services/notification.ts @@ -2,18 +2,21 @@ import { db } from "@dokploy/server/db"; import { type apiCreateDiscord, type apiCreateEmail, + type apiCreateLark, type apiCreateGotify, type apiCreateNtfy, type apiCreateSlack, type apiCreateTelegram, type apiUpdateDiscord, type apiUpdateEmail, + type apiUpdateLark, type apiUpdateGotify, type apiUpdateNtfy, type apiUpdateSlack, type apiUpdateTelegram, discord, email, + lark, gotify, notifications, ntfy, @@ -585,6 +588,7 @@ export const findNotificationById = async (notificationId: string) => { email: true, gotify: true, ntfy: true, + lark: true, }, }); if (!notification) { @@ -605,6 +609,94 @@ export const removeNotificationById = async (notificationId: string) => { return result[0]; }; +export const createLarkNotification = async ( + input: typeof apiCreateLark._type, + organizationId: string, +) => { + await db.transaction(async (tx) => { + const newLark = await tx + .insert(lark) + .values({ + webhookUrl: input.webhookUrl, + }) + .returning() + .then((value) => value[0]); + + if (!newLark) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Error input: Inserting lark", + }); + } + + const newDestination = await tx + .insert(notifications) + .values({ + larkId: newLark.larkId, + name: input.name, + appDeploy: input.appDeploy, + appBuildError: input.appBuildError, + databaseBackup: input.databaseBackup, + dokployRestart: input.dokployRestart, + dockerCleanup: input.dockerCleanup, + notificationType: "lark", + organizationId: organizationId, + serverThreshold: input.serverThreshold, + }) + .returning() + .then((value) => value[0]); + + if (!newDestination) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Error input: Inserting notification", + }); + } + + return newDestination; + }); +}; + +export const updateLarkNotification = async ( + input: typeof apiUpdateLark._type, +) => { + await db.transaction(async (tx) => { + const newDestination = await tx + .update(notifications) + .set({ + name: input.name, + appDeploy: input.appDeploy, + appBuildError: input.appBuildError, + databaseBackup: input.databaseBackup, + dokployRestart: input.dokployRestart, + dockerCleanup: input.dockerCleanup, + organizationId: input.organizationId, + serverThreshold: input.serverThreshold, + }) + .where(eq(notifications.notificationId, input.notificationId)) + .returning() + .then((value) => value[0]); + + if (!newDestination) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Error Updating notification", + }); + } + + await tx + .update(lark) + .set({ + webhookUrl: input.webhookUrl, + }) + .where(eq(lark.larkId, input.larkId)) + .returning() + .then((value) => value[0]); + + return newDestination; + }); +}; + export const updateNotificationById = async ( notificationId: string, notificationData: Partial, diff --git a/packages/server/src/services/postgres.ts b/packages/server/src/services/postgres.ts index 0d900443e..d7016038a 100644 --- a/packages/server/src/services/postgres.ts +++ b/packages/server/src/services/postgres.ts @@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server"; import { eq, getTableColumns } from "drizzle-orm"; import { validUniqueServerAppName } from "./project"; +export function getMountPath(dockerImage: string): string { + const versionMatch = dockerImage.match(/postgres:(\d+)/); + + if (versionMatch?.[1]) { + const version = Number.parseInt(versionMatch[1], 10); + if (version >= 18) { + return `/var/lib/postgresql/${version}/data`; + } + } + return "/var/lib/postgresql/data"; +} + export type Postgres = typeof postgres.$inferSelect; export const createPostgres = async (input: typeof apiCreatePostgres._type) => { diff --git a/packages/server/src/services/settings.ts b/packages/server/src/services/settings.ts index 301573cb4..23d11b09b 100644 --- a/packages/server/src/services/settings.ts +++ b/packages/server/src/services/settings.ts @@ -59,10 +59,8 @@ export const getUpdateData = async (): Promise => { let currentDigest: string; try { currentDigest = await getServiceImageDigest(); - } catch { - // Docker service might not exist locally - // You can run the # Installation command for docker service create mentioned in the below docs to test it locally: - // https://docs.dokploy.com/docs/core/manual-installation + } catch (error) { + // TODO: Docker versions 29.0.0 change the way to get the service image digest, so we need to update this in the future we upgrade to that version. return DEFAULT_UPDATE_DATA; } diff --git a/packages/server/src/services/user.ts b/packages/server/src/services/user.ts index ae03432a1..cd7379429 100644 --- a/packages/server/src/services/user.ts +++ b/packages/server/src/services/user.ts @@ -1,10 +1,10 @@ import { db } from "@dokploy/server/db"; -import { apikey, member, users_temp } from "@dokploy/server/db/schema"; +import { apikey, member, user } from "@dokploy/server/db/schema"; import { TRPCError } from "@trpc/server"; import { and, eq } from "drizzle-orm"; import { auth } from "../lib/auth"; -export type User = typeof users_temp.$inferSelect; +export type User = typeof user.$inferSelect; export const addNewProject = async ( userId: string, @@ -163,6 +163,24 @@ export const canPerformAccessEnvironment = async ( return false; }; +export const canPerformDeleteEnvironment = async ( + userId: string, + projectId: string, + organizationId: string, +) => { + const { accessedProjects, canDeleteEnvironments } = await findMemberById( + userId, + organizationId, + ); + const haveAccessToProject = accessedProjects.includes(projectId); + + if (canDeleteEnvironments && haveAccessToProject) { + return true; + } + + return false; +}; + export const canAccessToTraefikFiles = async ( userId: string, organizationId: string, @@ -240,6 +258,42 @@ export const checkEnvironmentAccess = async ( } }; +export const checkEnvironmentDeletionPermission = async ( + userId: string, + projectId: string, + organizationId: string, +) => { + const member = await findMemberById(userId, organizationId); + + if (!member) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "User not found in organization", + }); + } + + if (member.role === "owner" || member.role === "admin") { + return true; + } + + if (!member.canDeleteEnvironments) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You don't have permission to delete environments", + }); + } + + const hasProjectAccess = member.accessedProjects.includes(projectId); + if (!hasProjectAccess) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You don't have access to this project", + }); + } + + return true; +}; + export const checkProjectAccess = async ( authId: string, action: "create" | "delete" | "access", @@ -272,6 +326,46 @@ export const checkProjectAccess = async ( } }; +export const checkEnvironmentCreationPermission = async ( + userId: string, + projectId: string, + organizationId: string, +) => { + // Get user's member record + const member = await findMemberById(userId, organizationId); + + if (!member) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "User not found in organization", + }); + } + + // Owners and admins can always create environments + if (member.role === "owner" || member.role === "admin") { + return true; + } + + // Check if user has canCreateEnvironments permission + if (!member.canCreateEnvironments) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You don't have permission to create environments", + }); + } + + // Check if user has access to the project + const hasProjectAccess = member.accessedProjects.includes(projectId); + if (!hasProjectAccess) { + throw new TRPCError({ + code: "UNAUTHORIZED", + message: "You don't have access to this project", + }); + } + + return true; +}; + export const findMemberById = async ( userId: string, organizationId: string, @@ -309,16 +403,16 @@ export const updateUser = async (userId: string, userData: Partial) => { } } - const user = await db - .update(users_temp) + const userResult = await db + .update(user) .set({ ...userData, }) - .where(eq(users_temp.id, userId)) + .where(eq(user.id, userId)) .returning() .then((res) => res[0]); - return user; + return userResult; }; export const createApiKey = async ( diff --git a/packages/server/src/setup/postgres-setup.ts b/packages/server/src/setup/postgres-setup.ts index cf162f1ed..377a84952 100644 --- a/packages/server/src/setup/postgres-setup.ts +++ b/packages/server/src/setup/postgres-setup.ts @@ -17,7 +17,7 @@ export const initializePostgres = async () => { Mounts: [ { Type: "volume", - Source: "dokploy-postgres-database", + Source: "dokploy-postgres", Target: "/var/lib/postgresql/data", }, ], diff --git a/packages/server/src/setup/redis-setup.ts b/packages/server/src/setup/redis-setup.ts index 7366546da..894b3427d 100644 --- a/packages/server/src/setup/redis-setup.ts +++ b/packages/server/src/setup/redis-setup.ts @@ -14,7 +14,7 @@ export const initializeRedis = async () => { Mounts: [ { Type: "volume", - Source: "redis-data-volume", + Source: "dokploy-redis", Target: "/data", }, ], diff --git a/packages/server/src/setup/server-setup.ts b/packages/server/src/setup/server-setup.ts index 8128b57e0..0636215d9 100644 --- a/packages/server/src/setup/server-setup.ts +++ b/packages/server/src/setup/server-setup.ts @@ -51,7 +51,12 @@ export const serverSetup = async ( }); try { - onData?.("\nInstalling Server Dependencies: ✅\n"); + const isBuildServer = server.serverType === "build"; + onData?.( + isBuildServer + ? "\nInstalling Build Server Dependencies: ✅\n" + : "\nInstalling Server Dependencies: ✅\n", + ); await installRequirements(serverId, onData); await updateDeploymentStatus(deployment.deploymentId, "done"); @@ -65,7 +70,7 @@ export const serverSetup = async ( } }; -export const defaultCommand = () => { +export const defaultCommand = (isBuildServer = false) => { const bashCommand = ` set -e; DOCKER_VERSION=27.0.3 @@ -126,6 +131,7 @@ echo -e "---------------------------------------------" echo "| CPU Architecture | $SYS_ARCH" echo "| Operating System | $OS_TYPE $OS_VERSION" echo "| Docker | $DOCKER_VERSION" +${isBuildServer ? 'echo "| Server Type | Build Server"' : ""} echo -e "---------------------------------------------\n" echo -e "1. Installing required packages (curl, wget, git, jq, openssl). " @@ -135,6 +141,9 @@ command_exists() { ${installUtilities()} +${ + !isBuildServer + ? ` echo -e "2. Validating ports. " ${validatePorts()} @@ -173,6 +182,25 @@ ${installBuildpacks()} echo -e "13. Installing Railpack" ${installRailpack()} +` + : ` +echo -e "2. Installing Docker. " +${installDocker()} + +echo -e "3. Setting up Directories" +${setupMainDirectory()} +${setupDirectories()} + +echo -e "4. Installing Nixpacks" +${installNixpacks()} + +echo -e "5. Installing Buildpacks" +${installBuildpacks()} + +echo -e "6. Installing Railpack" +${installRailpack()} +` +} `; return bashCommand; @@ -189,10 +217,12 @@ const installRequirements = async ( throw new Error("No SSH Key found"); } + const isBuildServer = server.serverType === "build"; + return new Promise((resolve, reject) => { client .once("ready", () => { - const command = server.command || defaultCommand(); + const command = server.command || defaultCommand(isBuildServer); client.exec(command, (err, stream) => { if (err) { onData?.(err.message); diff --git a/packages/server/src/setup/traefik-setup.ts b/packages/server/src/setup/traefik-setup.ts index fa9bf78d0..73cff0b1c 100644 --- a/packages/server/src/setup/traefik-setup.ts +++ b/packages/server/src/setup/traefik-setup.ts @@ -20,7 +20,7 @@ export const TRAEFIK_PORT = Number.parseInt(process.env.TRAEFIK_PORT!, 10) || 80; export const TRAEFIK_HTTP3_PORT = Number.parseInt(process.env.TRAEFIK_HTTP3_PORT!, 10) || 443; -export const TRAEFIK_VERSION = process.env.TRAEFIK_VERSION || "3.5.0"; +export const TRAEFIK_VERSION = process.env.TRAEFIK_VERSION || "3.6.1"; export interface TraefikOptions { env?: string[]; diff --git a/packages/server/src/templates/index.ts b/packages/server/src/templates/index.ts index 17c461510..db67cb36f 100644 --- a/packages/server/src/templates/index.ts +++ b/packages/server/src/templates/index.ts @@ -37,7 +37,16 @@ export const generateRandomDomain = ({ const hash = randomBytes(3).toString("hex"); const slugIp = serverIp.replaceAll(".", "-").replaceAll(":", "-"); - return `${projectName}-${hash}${slugIp === "" ? "" : `-${slugIp}`}.traefik.me`; + // Domain labels have a max length of 63 characters + // Reserve space for: hash (6) + separators (1-2) + ip section + dot + traefik.me (10) + // Approx: 6 + 2 + (variable ip length) + 11 = ~19-30 chars for other parts + const maxProjectNameLength = 40; + const truncatedProjectName = + projectName.length > maxProjectNameLength + ? projectName.substring(0, maxProjectNameLength) + : projectName; + + return `${truncatedProjectName}-${hash}${slugIp === "" ? "" : `-${slugIp}`}.traefik.me`; }; export const generateHash = (length = 8): string => { diff --git a/packages/server/src/templates/processors.ts b/packages/server/src/templates/processors.ts index 5d9270aa1..9e73fb1f4 100644 --- a/packages/server/src/templates/processors.ts +++ b/packages/server/src/templates/processors.ts @@ -141,8 +141,8 @@ export function processValue( } if ( typeof payload === "string" && - payload.startsWith("{") && - payload.endsWith("}") + payload.trimStart().startsWith("{") && + payload.trimEnd().endsWith("}") ) { try { payload = JSON.parse(payload); diff --git a/packages/server/src/utils/ai/select-ai-provider.ts b/packages/server/src/utils/ai/select-ai-provider.ts index c0715030b..1967ff834 100644 --- a/packages/server/src/utils/ai/select-ai-provider.ts +++ b/packages/server/src/utils/ai/select-ai-provider.ts @@ -16,6 +16,7 @@ export function getProviderName(apiUrl: string) { if (apiUrl.includes("api.mistral.ai")) return "mistral"; if (apiUrl.includes(":11434") || apiUrl.includes("ollama")) return "ollama"; if (apiUrl.includes("api.deepinfra.com")) return "deepinfra"; + if (apiUrl.includes("generativelanguage.googleapis.com")) return "gemini"; return "custom"; } @@ -66,6 +67,13 @@ export function selectAIProvider(config: { apiUrl: string; apiKey: string }) { baseURL: config.apiUrl, apiKey: config.apiKey, }); + case "gemini": + return createOpenAICompatible({ + name: "gemini", + baseURL: config.apiUrl, + queryParams: { key: config.apiKey }, + headers: {}, + }); case "custom": return createOpenAICompatible({ name: "custom", diff --git a/packages/server/src/utils/builders/compose.ts b/packages/server/src/utils/builders/compose.ts index 667b46b74..fe5417ea5 100644 --- a/packages/server/src/utils/builders/compose.ts +++ b/packages/server/src/utils/builders/compose.ts @@ -1,117 +1,29 @@ -import { - createWriteStream, - existsSync, - mkdirSync, - writeFileSync, -} from "node:fs"; import { dirname, join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { InferResultType } from "@dokploy/server/types/with"; import boxen from "boxen"; -import { - writeDomainsToCompose, - writeDomainsToComposeRemote, -} from "../docker/domain"; +import { quote } from "shell-quote"; +import { writeDomainsToCompose } from "../docker/domain"; import { encodeBase64, getEnviromentVariablesObject, prepareEnvironmentVariables, } from "../docker/utils"; -import { execAsync, execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; export type ComposeNested = InferResultType< "compose", { environment: { with: { project: true } }; mounts: true; domains: true } >; -export const buildCompose = async (compose: ComposeNested, logPath: string) => { - const writeStream = createWriteStream(logPath, { flags: "a" }); - const { sourceType, appName, mounts, composeType, domains } = compose; - try { - const { COMPOSE_PATH } = paths(); - const command = createCommand(compose); - await writeDomainsToCompose(compose, domains); - createEnvFile(compose); - if (compose.isolatedDeployment) { - await execAsync( - `docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create ${composeType === "stack" ? "--driver overlay" : ""} --attachable ${compose.appName}`, - ); - } - - const logContent = ` - App Name: ${appName} - Build Compose 🐳 - Detected: ${mounts.length} mounts 📂 - Command: docker ${command} - Source Type: docker ${sourceType} ✅ - Compose Type: ${composeType} ✅`; - const logBox = boxen(logContent, { - padding: { - left: 1, - right: 1, - bottom: 1, - }, - width: 80, - borderStyle: "double", - }); - writeStream.write(`\n${logBox}\n`); - const projectPath = join(COMPOSE_PATH, compose.appName, "code"); - - await spawnAsync( - "docker", - [...command.split(" ")], - (data) => { - if (writeStream.writable) { - writeStream.write(data.toString()); - } - }, - { - cwd: projectPath, - env: { - NODE_ENV: process.env.NODE_ENV, - PATH: process.env.PATH, - ...(composeType === "stack" && { - ...getEnviromentVariablesObject( - compose.env, - compose.environment.project.env, - ), - }), - }, - }, - ); - - if (compose.isolatedDeployment) { - await execAsync( - `docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1`, - ).catch(() => {}); - } - - writeStream.write("Docker Compose Deployed: ✅"); - } catch (error) { - writeStream.write(`Error ❌ ${(error as Error).message}`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const getBuildComposeCommand = async ( - compose: ComposeNested, - logPath: string, -) => { - const { COMPOSE_PATH } = paths(true); +export const getBuildComposeCommand = async (compose: ComposeNested) => { + const { COMPOSE_PATH } = paths(!!compose.serverId); const { sourceType, appName, mounts, composeType, domains } = compose; const command = createCommand(compose); const envCommand = getCreateEnvFileCommand(compose); const projectPath = join(COMPOSE_PATH, compose.appName, "code"); const exportEnvCommand = getExportEnvCommand(compose); - const newCompose = await writeDomainsToComposeRemote( - compose, - domains, - logPath, - ); + const newCompose = await writeDomainsToCompose(compose, domains); const logContent = ` App Name: ${appName} Build Compose 🐳 @@ -133,7 +45,7 @@ Compose Type: ${composeType} ✅`; const bashCommand = ` set -e { - echo "${logBox}" >> "${logPath}" + echo "${logBox}"; ${newCompose} @@ -141,19 +53,18 @@ Compose Type: ${composeType} ✅`; cd "${projectPath}"; - ${exportEnvCommand} ${compose.isolatedDeployment ? `docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create --attachable ${compose.appName}` : ""} - docker ${command.split(" ").join(" ")} >> "${logPath}" 2>&1 || { echo "Error: ❌ Docker command failed" >> "${logPath}"; exit 1; } + env -i PATH="$PATH" ${exportEnvCommand} docker ${command.split(" ").join(" ")} 2>&1 || { echo "Error: ❌ Docker command failed"; exit 1; } ${compose.isolatedDeployment ? `docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1` : ""} - echo "Docker Compose Deployed: ✅" >> "${logPath}" + echo "Docker Compose Deployed: ✅"; } || { - echo "Error: ❌ Script execution failed" >> "${logPath}" + echo "Error: ❌ Script execution failed"; exit 1 } `; - return await execAsyncRemote(compose.serverId, bashCommand); + return bashCommand; }; const sanitizeCommand = (command: string) => { @@ -185,38 +96,8 @@ export const createCommand = (compose: ComposeNested) => { return command; }; -const createEnvFile = (compose: ComposeNested) => { - const { COMPOSE_PATH } = paths(); - const { env, composePath, appName } = compose; - const composeFilePath = - join(COMPOSE_PATH, appName, "code", composePath) || - join(COMPOSE_PATH, appName, "code", "docker-compose.yml"); - - const envFilePath = join(dirname(composeFilePath), ".env"); - let envContent = `APP_NAME=${appName}\n`; - envContent += env || ""; - if (!envContent.includes("DOCKER_CONFIG")) { - envContent += "\nDOCKER_CONFIG=/root/.docker"; - } - - if (compose.randomize) { - envContent += `\nCOMPOSE_PREFIX=${compose.suffix}`; - } - - const envFileContent = prepareEnvironmentVariables( - envContent, - compose.environment.project.env, - compose.environment.env, - ).join("\n"); - - if (!existsSync(dirname(envFilePath))) { - mkdirSync(dirname(envFilePath), { recursive: true }); - } - writeFileSync(envFilePath, envFileContent); -}; - export const getCreateEnvFileCommand = (compose: ComposeNested) => { - const { COMPOSE_PATH } = paths(true); + const { COMPOSE_PATH } = paths(!!compose.serverId); const { env, composePath, appName } = compose; const composeFilePath = join(COMPOSE_PATH, appName, "code", composePath) || @@ -255,8 +136,8 @@ const getExportEnvCommand = (compose: ComposeNested) => { compose.environment.project.env, ); const exports = Object.entries(envVars) - .map(([key, value]) => `export ${key}=${JSON.stringify(value)}`) - .join("\n"); + .map(([key, value]) => `${key}=${quote([value])}`) + .join(" "); - return exports ? `\n# Export environment variables\n${exports}\n` : ""; + return exports ? `${exports}` : ""; }; diff --git a/packages/server/src/utils/builders/docker-file.ts b/packages/server/src/utils/builders/docker-file.ts index b218590c8..8ca99ccf2 100644 --- a/packages/server/src/utils/builders/docker-file.ts +++ b/packages/server/src/utils/builders/docker-file.ts @@ -1,91 +1,22 @@ -import type { WriteStream } from "node:fs"; -import { prepareEnvironmentVariables } from "@dokploy/server/utils/docker/utils"; +import { + getEnviromentVariablesObject, + prepareEnvironmentVariablesForShell, +} from "@dokploy/server/utils/docker/utils"; +import { quote } from "shell-quote"; import { getBuildAppDirectory, getDockerContextPath, } from "../filesystem/directory"; -import { spawnAsync } from "../process/spawnAsync"; import type { ApplicationNested } from "."; -import { createEnvFile, createEnvFileCommand } from "./utils"; +import { createEnvFileCommand } from "./utils"; -export const buildCustomDocker = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { - const { - appName, - env, - publishDirectory, - buildArgs, - dockerBuildStage, - cleanCache, - } = application; - const dockerFilePath = getBuildAppDirectory(application); - try { - const image = `${appName}`; - - const defaultContextPath = - dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || "."; - const args = prepareEnvironmentVariables( - buildArgs, - application.environment.project.env, - application.environment.env, - ); - - const dockerContextPath = getDockerContextPath(application); - - const commandArgs = ["build", "-t", image, "-f", dockerFilePath, "."]; - - if (cleanCache) { - commandArgs.push("--no-cache"); - } - - if (dockerBuildStage) { - commandArgs.push("--target", dockerBuildStage); - } - - for (const arg of args) { - commandArgs.push("--build-arg", arg); - } - /* - Do not generate an environment file when publishDirectory is specified, - as it could be publicly exposed. - */ - if (!publishDirectory) { - createEnvFile( - dockerFilePath, - env, - application.environment.project.env, - application.environment.env, - ); - } - - await spawnAsync( - "docker", - commandArgs, - (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }, - { - cwd: dockerContextPath || defaultContextPath, - }, - ); - } catch (error) { - throw error; - } -}; - -export const getDockerCommand = ( - application: ApplicationNested, - logPath: string, -) => { +export const getDockerCommand = (application: ApplicationNested) => { const { appName, env, publishDirectory, buildArgs, + buildSecrets, dockerBuildStage, cleanCache, } = application; @@ -96,11 +27,6 @@ export const getDockerCommand = ( const defaultContextPath = dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || "."; - const args = prepareEnvironmentVariables( - buildArgs, - application.environment.project.env, - application.environment.env, - ); const dockerContextPath = getDockerContextPath(application) || defaultContextPath; @@ -115,8 +41,31 @@ export const getDockerCommand = ( commandArgs.push("--no-cache"); } + const args = prepareEnvironmentVariablesForShell( + buildArgs, + application.environment.project.env, + application.environment.env, + ); + for (const arg of args) { - commandArgs.push("--build-arg", `'${arg}'`); + commandArgs.push("--build-arg", arg); + } + + const secrets = getEnviromentVariablesObject( + buildSecrets, + application.environment.project.env, + application.environment.env, + ); + + const joinedSecrets = Object.entries(secrets) + .map(([key, value]) => `${key}=${quote([value])}`) + .join(" "); + + for (const key in secrets) { + // Although buildx is smart enough to know we may be referring to an environment variable name, + // we still make sure it doesn't fall back to `type=file`. + // See: https://docs.docker.com/reference/cli/docker/buildx/build/#secret + commandArgs.push("--secret", `type=env,id=${key}`); } /* @@ -134,17 +83,17 @@ export const getDockerCommand = ( } command += ` -echo "Building ${appName}" >> ${logPath}; -cd ${dockerContextPath} >> ${logPath} 2>> ${logPath} || { - echo "❌ The path ${dockerContextPath} does not exist" >> ${logPath}; +echo "Building ${appName}" ; +cd ${dockerContextPath} || { + echo "❌ The path ${dockerContextPath} does not exist" ; exit 1; } -docker ${commandArgs.join(" ")} >> ${logPath} 2>> ${logPath} || { - echo "❌ Docker build failed" >> ${logPath}; +${joinedSecrets} docker ${commandArgs.join(" ")} || { + echo "❌ Docker build failed" ; exit 1; } -echo "✅ Docker build completed." >> ${logPath}; +echo "✅ Docker build completed." ; `; return command; diff --git a/packages/server/src/utils/builders/heroku.ts b/packages/server/src/utils/builders/heroku.ts index 3306f2fc2..8b38c694d 100644 --- a/packages/server/src/utils/builders/heroku.ts +++ b/packages/server/src/utils/builders/heroku.ts @@ -1,58 +1,12 @@ -import type { WriteStream } from "node:fs"; -import { prepareEnvironmentVariables } from "../docker/utils"; +import { prepareEnvironmentVariablesForShell } from "../docker/utils"; import { getBuildAppDirectory } from "../filesystem/directory"; -import { spawnAsync } from "../process/spawnAsync"; import type { ApplicationNested } from "."; -// TODO: integrate in the vps sudo chown -R $(whoami) ~/.docker -export const buildHeroku = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { - const { env, appName, cleanCache } = application; - const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( - env, - application.environment.project.env, - application.environment.env, - ); - try { - const args = [ - "build", - appName, - "--path", - buildAppDirectory, - "--builder", - `heroku/builder:${application.herokuVersion || "24"}`, - ]; - - for (const env of envVariables) { - args.push("--env", env); - } - - if (cleanCache) { - args.push("--clear-cache"); - } - - await spawnAsync("pack", args, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - return true; - } catch (e) { - throw e; - } -}; - -export const getHerokuCommand = ( - application: ApplicationNested, - logPath: string, -) => { +export const getHerokuCommand = (application: ApplicationNested) => { const { env, appName, cleanCache } = application; const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( + const envVariables = prepareEnvironmentVariablesForShell( env, application.environment.project.env, application.environment.env, @@ -72,17 +26,17 @@ export const getHerokuCommand = ( } for (const env of envVariables) { - args.push("--env", `'${env}'`); + args.push("--env", env); } const command = `pack ${args.join(" ")}`; const bashCommand = ` -echo "Starting heroku build..." >> ${logPath}; -${command} >> ${logPath} 2>> ${logPath} || { - echo "❌ Heroku build failed" >> ${logPath}; +echo "Starting heroku build..." ; +${command} || { + echo "❌ Heroku build failed" ; exit 1; } -echo "✅ Heroku build completed." >> ${logPath}; +echo "✅ Heroku build completed." ; `; return bashCommand; diff --git a/packages/server/src/utils/builders/index.ts b/packages/server/src/utils/builders/index.ts index 5d3261dbb..139b9bb1d 100644 --- a/packages/server/src/utils/builders/index.ts +++ b/packages/server/src/utils/builders/index.ts @@ -1,7 +1,6 @@ -import { createWriteStream } from "node:fs"; import type { InferResultType } from "@dokploy/server/types/with"; import type { CreateServiceOptions } from "dockerode"; -import { uploadImage, uploadImageRemoteCommand } from "../cluster/upload"; +import { uploadImageRemoteCommand } from "../cluster/upload"; import { calculateResources, generateBindMounts, @@ -11,12 +10,12 @@ import { prepareEnvironmentVariables, } from "../docker/utils"; import { getRemoteDocker } from "../servers/remote-docker"; -import { buildCustomDocker, getDockerCommand } from "./docker-file"; -import { buildHeroku, getHerokuCommand } from "./heroku"; -import { buildNixpacks, getNixpacksCommand } from "./nixpacks"; -import { buildPaketo, getPaketoCommand } from "./paketo"; -import { buildRailpack, getRailpackCommand } from "./railpack"; -import { buildStatic, getStaticCommand } from "./static"; +import { getDockerCommand } from "./docker-file"; +import { getHerokuCommand } from "./heroku"; +import { getNixpacksCommand } from "./nixpacks"; +import { getPaketoCommand } from "./paketo"; +import { getRailpackCommand } from "./railpack"; +import { getStaticCommand } from "./static"; // NIXPACKS codeDirectory = where is the path of the code directory // HEROKU codeDirectory = where is the path of the code directory @@ -30,80 +29,40 @@ export type ApplicationNested = InferResultType< redirects: true; ports: true; registry: true; + buildRegistry: true; environment: { with: { project: true } }; } >; -export const buildApplication = async ( - application: ApplicationNested, - logPath: string, -) => { - const writeStream = createWriteStream(logPath, { flags: "a" }); - const { buildType, sourceType } = application; - try { - writeStream.write( - `\nBuild ${buildType}: ✅\nSource Type: ${sourceType}: ✅\n`, - ); - console.log(`Build ${buildType}: ✅`); - if (buildType === "nixpacks") { - await buildNixpacks(application, writeStream); - } else if (buildType === "heroku_buildpacks") { - await buildHeroku(application, writeStream); - } else if (buildType === "paketo_buildpacks") { - await buildPaketo(application, writeStream); - } else if (buildType === "dockerfile") { - await buildCustomDocker(application, writeStream); - } else if (buildType === "static") { - await buildStatic(application, writeStream); - } else if (buildType === "railpack") { - await buildRailpack(application, writeStream); - } - - if (application.registryId) { - await uploadImage(application, writeStream); - } - await mechanizeDockerContainer(application); - writeStream.write("Docker Deployed: ✅"); - } catch (error) { - if (error instanceof Error) { - writeStream.write(`Error ❌\n${error?.message}`); - } else { - writeStream.write("Error ❌"); - } - throw error; - } finally { - writeStream.end(); - } -}; - -export const getBuildCommand = ( - application: ApplicationNested, - logPath: string, -) => { +export const getBuildCommand = (application: ApplicationNested) => { let command = ""; - const { buildType, registry } = application; + const { buildType } = application; + + if (application.sourceType === "docker") { + return ""; + } switch (buildType) { case "nixpacks": - command = getNixpacksCommand(application, logPath); + command = getNixpacksCommand(application); break; case "heroku_buildpacks": - command = getHerokuCommand(application, logPath); + command = getHerokuCommand(application); break; case "paketo_buildpacks": - command = getPaketoCommand(application, logPath); + command = getPaketoCommand(application); break; case "static": - command = getStaticCommand(application, logPath); + command = getStaticCommand(application); break; case "dockerfile": - command = getDockerCommand(application, logPath); + command = getDockerCommand(application); break; case "railpack": - command = getRailpackCommand(application, logPath); + command = getRailpackCommand(application); break; } - if (registry) { - command += uploadImageRemoteCommand(application, logPath); + if (application.registry || application.buildRegistry) { + command += uploadImageRemoteCommand(application); } return command; @@ -121,6 +80,7 @@ export const mechanizeDockerContainer = async ( memoryReservation, cpuReservation, command, + args, ports, } = application; @@ -142,6 +102,8 @@ export const mechanizeDockerContainer = async ( RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(application); const bindsMount = generateBindMounts(mounts); @@ -165,12 +127,16 @@ export const mechanizeDockerContainer = async ( Image: image, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], - ...(command - ? { - Command: ["/bin/sh"], - Args: ["-c", command], - } - : {}), + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), + ...(command && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && { + Args: args, + }), + Labels, }, Networks, @@ -182,14 +148,16 @@ export const mechanizeDockerContainer = async ( }, Mode, RollbackConfig, - EndpointSpec: { - Ports: ports.map((port) => ({ - PublishMode: port.publishMode, - Protocol: port.protocol, - TargetPort: port.targetPort, - PublishedPort: port.publishedPort, - })), - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Ports: ports.map((port) => ({ + PublishMode: port.publishMode, + Protocol: port.protocol, + TargetPort: port.targetPort, + PublishedPort: port.publishedPort, + })), + }, UpdateConfig, }; @@ -205,13 +173,15 @@ export const mechanizeDockerContainer = async ( ForceUpdate: inspect.Spec.TaskTemplate.ForceUpdate + 1, }, }); - } catch { + } catch (error) { + console.log(error); await docker.createService(settings); } }; const getImageName = (application: ApplicationNested) => { - const { appName, sourceType, dockerImage, registry } = application; + const { appName, sourceType, dockerImage, registry, buildRegistry } = + application; const imageName = `${appName}:latest`; if (sourceType === "docker") { return dockerImage || "ERROR-NO-IMAGE-PROVIDED"; @@ -224,12 +194,26 @@ const getImageName = (application: ApplicationNested) => { : `${registryUrl ? `${registryUrl}/` : ""}${username}/${imageName}`; return registryTag; } + if (buildRegistry) { + const { registryUrl, imagePrefix, username } = buildRegistry; + const registryTag = imagePrefix + ? `${registryUrl ? `${registryUrl}/` : ""}${imagePrefix}/${imageName}` + : `${registryUrl ? `${registryUrl}/` : ""}${username}/${imageName}`; + return registryTag; + } return imageName; }; export const getAuthConfig = (application: ApplicationNested) => { - const { registry, username, password, sourceType, registryUrl } = application; + const { + registry, + buildRegistry, + username, + password, + sourceType, + registryUrl, + } = application; if (sourceType === "docker") { if (username && password) { @@ -245,6 +229,12 @@ export const getAuthConfig = (application: ApplicationNested) => { username: registry.username, serveraddress: registry.registryUrl, }; + } else if (buildRegistry) { + return { + password: buildRegistry.password, + username: buildRegistry.username, + serveraddress: buildRegistry.registryUrl, + }; } return undefined; diff --git a/packages/server/src/utils/builders/nixpacks.ts b/packages/server/src/utils/builders/nixpacks.ts index 76905d0e7..b7134ea65 100644 --- a/packages/server/src/utils/builders/nixpacks.ts +++ b/packages/server/src/utils/builders/nixpacks.ts @@ -1,106 +1,16 @@ -import { existsSync, mkdirSync, type WriteStream } from "node:fs"; import path from "node:path"; -import { - buildStatic, - getStaticCommand, -} from "@dokploy/server/utils/builders/static"; +import { getStaticCommand } from "@dokploy/server/utils/builders/static"; import { nanoid } from "nanoid"; -import { prepareEnvironmentVariables } from "../docker/utils"; +import { prepareEnvironmentVariablesForShell } from "../docker/utils"; import { getBuildAppDirectory } from "../filesystem/directory"; -import { spawnAsync } from "../process/spawnAsync"; import type { ApplicationNested } from "."; -export const buildNixpacks = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { +export const getNixpacksCommand = (application: ApplicationNested) => { const { env, appName, publishDirectory, cleanCache } = application; const buildAppDirectory = getBuildAppDirectory(application); const buildContainerId = `${appName}-${nanoid(10)}`; - const envVariables = prepareEnvironmentVariables( - env, - application.environment.project.env, - application.environment.env, - ); - - const writeToStream = (data: string) => { - if (writeStream.writable) { - writeStream.write(data); - } - }; - - try { - const args = ["build", buildAppDirectory, "--name", appName]; - - if (cleanCache) { - args.push("--no-cache"); - } - - for (const env of envVariables) { - args.push("--env", env); - } - - if (publishDirectory) { - /* No need for any start command, since we'll use nginx later on */ - args.push("--no-error-without-start"); - } - - await spawnAsync("nixpacks", args, writeToStream); - - /* - Run the container with the image created by nixpacks, - and copy the artifacts on the host filesystem. - Then, remove the container and create a static build. - */ - if (publishDirectory) { - await spawnAsync( - "docker", - ["create", "--name", buildContainerId, appName], - writeToStream, - ); - - const localPath = path.join(buildAppDirectory, publishDirectory); - - if (!existsSync(path.dirname(localPath))) { - mkdirSync(path.dirname(localPath), { recursive: true }); - } - - // https://docs.docker.com/reference/cli/docker/container/cp/ - const isDirectory = - publishDirectory.endsWith("/") || !path.extname(publishDirectory); - - await spawnAsync( - "docker", - [ - "cp", - `${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""}`, - localPath, - ], - writeToStream, - ); - - await spawnAsync("docker", ["rm", buildContainerId], writeToStream); - - await buildStatic(application, writeStream); - } - return true; - } catch (e) { - await spawnAsync("docker", ["rm", buildContainerId], writeToStream); - - throw e; - } -}; - -export const getNixpacksCommand = ( - application: ApplicationNested, - logPath: string, -) => { - const { env, appName, publishDirectory, cleanCache } = application; - - const buildAppDirectory = getBuildAppDirectory(application); - const buildContainerId = `${appName}-${nanoid(10)}`; - const envVariables = prepareEnvironmentVariables( + const envVariables = prepareEnvironmentVariablesForShell( env, application.environment.project.env, application.environment.env, @@ -113,7 +23,7 @@ export const getNixpacksCommand = ( } for (const env of envVariables) { - args.push("--env", `'${env}'`); + args.push("--env", env); } if (publishDirectory) { @@ -122,12 +32,12 @@ export const getNixpacksCommand = ( } const command = `nixpacks ${args.join(" ")}`; let bashCommand = ` -echo "Starting nixpacks build..." >> ${logPath}; -${command} >> ${logPath} 2>> ${logPath} || { - echo "❌ Nixpacks build failed" >> ${logPath}; - exit 1; -} -echo "✅ Nixpacks build completed." >> ${logPath}; + echo "Starting nixpacks build..." ; + ${command} || { + echo "❌ Nixpacks build failed" ; + exit 1; + } + echo "✅ Nixpacks build completed." ; `; /* @@ -141,16 +51,16 @@ echo "✅ Nixpacks build completed." >> ${logPath}; publishDirectory.endsWith("/") || !path.extname(publishDirectory); bashCommand += ` -docker create --name ${buildContainerId} ${appName} -mkdir -p ${localPath} -docker cp ${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""} ${path.join(buildAppDirectory, publishDirectory)} >> ${logPath} 2>> ${logPath} || { + docker create --name ${buildContainerId} ${appName} + mkdir -p ${localPath} + docker cp ${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""} ${path.join(buildAppDirectory, publishDirectory)} || { + docker rm ${buildContainerId} + echo "❌ Copying ${publishDirectory} to ${path.join(buildAppDirectory, publishDirectory)} failed" ; + exit 1; + } docker rm ${buildContainerId} - echo "❌ Copying ${publishDirectory} to ${path.join(buildAppDirectory, publishDirectory)} failed" >> ${logPath}; - exit 1; -} -docker rm ${buildContainerId} -${getStaticCommand(application, logPath)} - `; + ${getStaticCommand(application)} + `; } return bashCommand; diff --git a/packages/server/src/utils/builders/paketo.ts b/packages/server/src/utils/builders/paketo.ts index b95a1bb31..bb4f8c8a4 100644 --- a/packages/server/src/utils/builders/paketo.ts +++ b/packages/server/src/utils/builders/paketo.ts @@ -1,57 +1,12 @@ -import type { WriteStream } from "node:fs"; -import { prepareEnvironmentVariables } from "../docker/utils"; +import { prepareEnvironmentVariablesForShell } from "../docker/utils"; import { getBuildAppDirectory } from "../filesystem/directory"; -import { spawnAsync } from "../process/spawnAsync"; import type { ApplicationNested } from "."; -export const buildPaketo = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { - const { env, appName, cleanCache } = application; - const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( - env, - application.environment.project.env, - application.environment.env, - ); - try { - const args = [ - "build", - appName, - "--path", - buildAppDirectory, - "--builder", - "paketobuildpacks/builder-jammy-full", - ]; - - if (cleanCache) { - args.push("--clear-cache"); - } - - for (const env of envVariables) { - args.push("--env", env); - } - - await spawnAsync("pack", args, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - return true; - } catch (e) { - throw e; - } -}; - -export const getPaketoCommand = ( - application: ApplicationNested, - logPath: string, -) => { +export const getPaketoCommand = (application: ApplicationNested) => { const { env, appName, cleanCache } = application; const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( + const envVariables = prepareEnvironmentVariablesForShell( env, application.environment.project.env, application.environment.env, @@ -71,17 +26,17 @@ export const getPaketoCommand = ( } for (const env of envVariables) { - args.push("--env", `'${env}'`); + args.push("--env", env); } const command = `pack ${args.join(" ")}`; const bashCommand = ` -echo "Starting Paketo build..." >> ${logPath}; -${command} >> ${logPath} 2>> ${logPath} || { - echo "❌ Paketo build failed" >> ${logPath}; +echo "Starting Paketo build..." ; +${command} || { + echo "❌ Paketo build failed" ; exit 1; } -echo "✅ Paketo build completed." >> ${logPath}; +echo "✅ Paketo build completed." ; `; return bashCommand; diff --git a/packages/server/src/utils/builders/railpack.ts b/packages/server/src/utils/builders/railpack.ts index 4adc9ca1c..62fa9f975 100644 --- a/packages/server/src/utils/builders/railpack.ts +++ b/packages/server/src/utils/builders/railpack.ts @@ -1,13 +1,12 @@ import { createHash } from "node:crypto"; -import type { WriteStream } from "node:fs"; import { nanoid } from "nanoid"; +import { quote } from "shell-quote"; import { parseEnvironmentKeyValuePair, prepareEnvironmentVariables, + prepareEnvironmentVariablesForShell, } from "../docker/utils"; import { getBuildAppDirectory } from "../filesystem/directory"; -import { execAsync } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; import type { ApplicationNested } from "."; const calculateSecretsHash = (envVariables: string[]): string => { @@ -18,111 +17,10 @@ const calculateSecretsHash = (envVariables: string[]): string => { return hash.digest("hex"); }; -export const buildRailpack = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { +export const getRailpackCommand = (application: ApplicationNested) => { const { env, appName, cleanCache } = application; const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( - env, - application.environment.project.env, - application.environment.env, - ); - - try { - await execAsync( - "docker buildx create --use --name builder-containerd --driver docker-container || true", - ); - - await execAsync("docker buildx use builder-containerd"); - - // First prepare the build plan and info - const prepareArgs = [ - "prepare", - buildAppDirectory, - "--plan-out", - `${buildAppDirectory}/railpack-plan.json`, - "--info-out", - `${buildAppDirectory}/railpack-info.json`, - ]; - - // Add environment variables to prepare command - for (const env of envVariables) { - prepareArgs.push("--env", env); - } - - // Run prepare command - await spawnAsync("railpack", prepareArgs, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - - // Calculate secrets hash for layer invalidation - const secretsHash = calculateSecretsHash(envVariables); - - // Build with BuildKit using the Railpack frontend - const cacheKey = cleanCache ? nanoid(10) : undefined; - const buildArgs = [ - "buildx", - "build", - ...(cacheKey - ? [ - "--build-arg", - `secrets-hash=${secretsHash}`, - "--build-arg", - `cache-key=${cacheKey}`, - ] - : []), - "--build-arg", - `BUILDKIT_SYNTAX=ghcr.io/railwayapp/railpack-frontend:v${application.railpackVersion}`, - "-f", - `${buildAppDirectory}/railpack-plan.json`, - "--output", - `type=docker,name=${appName}`, - ]; - - // Add secrets properly formatted - const env: { [key: string]: string } = {}; - for (const pair of envVariables) { - const [key, value] = parseEnvironmentKeyValuePair(pair); - if (key && value) { - buildArgs.push("--secret", `id=${key},env=${key}`); - env[key] = value; - } - } - - buildArgs.push(buildAppDirectory); - - await spawnAsync( - "docker", - buildArgs, - (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }, - { - env: { ...process.env, ...env }, - }, - ); - - return true; - } catch (e) { - throw e; - } finally { - await execAsync("docker buildx rm builder-containerd"); - } -}; - -export const getRailpackCommand = ( - application: ApplicationNested, - logPath: string, -) => { - const { env, appName, cleanCache } = application; - const buildAppDirectory = getBuildAppDirectory(application); - const envVariables = prepareEnvironmentVariables( + const envVariables = prepareEnvironmentVariablesForShell( env, application.environment.project.env, application.environment.env, @@ -139,7 +37,7 @@ export const getRailpackCommand = ( ]; for (const env of envVariables) { - prepareArgs.push("--env", `'${env}'`); + prepareArgs.push("--env", env); } // Calculate secrets hash for layer invalidation @@ -167,37 +65,49 @@ export const getRailpackCommand = ( ]; // Add secrets properly formatted + // Use prepareEnvironmentVariables (without ForShell) to get raw values for parsing + const rawEnvVariables = prepareEnvironmentVariables( + env, + application.environment.project.env, + application.environment.env, + ); const exportEnvs = []; - for (const pair of envVariables) { + for (const pair of rawEnvVariables) { const [key, value] = parseEnvironmentKeyValuePair(pair); if (key && value) { buildArgs.push("--secret", `id=${key},env=${key}`); - exportEnvs.push(`export ${key}='${value}'`); + exportEnvs.push(`export ${key}=${quote([value])}`); } } buildArgs.push(buildAppDirectory); const bashCommand = ` + # Ensure we have a builder with containerd + +export RAILPACK_VERSION=${application.railpackVersion} +bash -c "$(curl -fsSL https://railpack.com/install.sh)" docker buildx create --use --name builder-containerd --driver docker-container || true docker buildx use builder-containerd -echo "Preparing Railpack build plan..." >> "${logPath}"; -railpack ${prepareArgs.join(" ")} >> ${logPath} 2>> ${logPath} || { - echo "❌ Railpack prepare failed" >> ${logPath}; +echo "Preparing Railpack build plan..." ; +railpack ${prepareArgs.join(" ")} || { + echo "❌ Railpack prepare failed" ; + docker buildx rm builder-containerd || true exit 1; } -echo "✅ Railpack prepare completed." >> ${logPath}; +echo "✅ Railpack prepare completed." ; -echo "Building with Railpack frontend..." >> "${logPath}"; +echo "Building with Railpack frontend..." ; # Export environment variables for secrets ${exportEnvs.join("\n")} -docker ${buildArgs.join(" ")} >> ${logPath} 2>> ${logPath} || { - echo "❌ Railpack build failed" >> ${logPath}; +docker ${buildArgs.join(" ")} || { + echo "❌ Railpack build failed" ; + docker buildx rm builder-containerd || true exit 1; } -echo "✅ Railpack build completed." >> ${logPath}; +echo "✅ Railpack build completed." ; docker buildx rm builder-containerd `; diff --git a/packages/server/src/utils/builders/static.ts b/packages/server/src/utils/builders/static.ts index e59faa711..99fa25285 100644 --- a/packages/server/src/utils/builders/static.ts +++ b/packages/server/src/utils/builders/static.ts @@ -1,9 +1,5 @@ -import type { WriteStream } from "node:fs"; -import { - buildCustomDocker, - getDockerCommand, -} from "@dokploy/server/utils/builders/docker-file"; -import { createFile, getCreateFileCommand } from "../docker/utils"; +import { getDockerCommand } from "@dokploy/server/utils/builders/docker-file"; +import { getCreateFileCommand } from "../docker/utils"; import { getBuildAppDirectory } from "../filesystem/directory"; import type { ApplicationNested } from "."; @@ -32,81 +28,40 @@ http { } `; -export const buildStatic = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { +export const getStaticCommand = (application: ApplicationNested) => { const { publishDirectory, isStaticSpa } = application; const buildAppDirectory = getBuildAppDirectory(application); - - try { - if (isStaticSpa) { - createFile(buildAppDirectory, "nginx.conf", nginxSpaConfig); - } - - createFile( + let command = ""; + if (isStaticSpa) { + command += getCreateFileCommand( buildAppDirectory, - ".dockerignore", - [".git", ".env", "Dockerfile", ".dockerignore"].join("\n"), + "nginx.conf", + nginxSpaConfig, ); - - createFile( - buildAppDirectory, - "Dockerfile", - [ - "FROM nginx:alpine", - "WORKDIR /usr/share/nginx/html/", - isStaticSpa ? "COPY nginx.conf /etc/nginx/nginx.conf" : "", - `COPY ${publishDirectory || "."} .`, - 'CMD ["nginx", "-g", "daemon off;"]', - ].join("\n"), - ); - - createFile( - buildAppDirectory, - ".dockerignore", - [".git", ".env", "Dockerfile", ".dockerignore"].join("\n"), - ); - - await buildCustomDocker( - { - ...application, - buildType: "dockerfile", - dockerfile: "Dockerfile", - }, - writeStream, - ); - - return true; - } catch (e) { - throw e; } -}; -export const getStaticCommand = ( - application: ApplicationNested, - logPath: string, -) => { - const { publishDirectory } = application; - const buildAppDirectory = getBuildAppDirectory(application); + command += getCreateFileCommand( + buildAppDirectory, + ".dockerignore", + [".git", ".env", "Dockerfile", ".dockerignore"].join("\n"), + ); - let command = getCreateFileCommand( + command += getCreateFileCommand( buildAppDirectory, "Dockerfile", [ "FROM nginx:alpine", "WORKDIR /usr/share/nginx/html/", + isStaticSpa ? "COPY nginx.conf /etc/nginx/nginx.conf" : "", `COPY ${publishDirectory || "."} .`, + 'CMD ["nginx", "-g", "daemon off;"]', ].join("\n"), ); - command += getDockerCommand( - { - ...application, - buildType: "dockerfile", - dockerfile: "Dockerfile", - }, - logPath, - ); + command += getDockerCommand({ + ...application, + buildType: "dockerfile", + dockerfile: "Dockerfile", + }); return command; }; diff --git a/packages/server/src/utils/cluster/upload.ts b/packages/server/src/utils/cluster/upload.ts index c13a2701c..a57a771f3 100644 --- a/packages/server/src/utils/cluster/upload.ts +++ b/packages/server/src/utils/cluster/upload.ts @@ -1,106 +1,77 @@ -import type { WriteStream } from "node:fs"; +import type { Registry } from "@dokploy/server/services/registry"; import type { ApplicationNested } from "../builders"; -import { spawnAsync } from "../process/spawnAsync"; -export const uploadImage = async ( - application: ApplicationNested, - writeStream: WriteStream, -) => { +export const uploadImageRemoteCommand = (application: ApplicationNested) => { const registry = application.registry; + const buildRegistry = application.buildRegistry; - if (!registry) { - throw new Error("Registry not found"); + if (!registry && !buildRegistry) { + throw new Error("No registry found"); } - const { registryUrl, imagePrefix, username } = registry; const { appName } = application; const imageName = `${appName}:latest`; - const finalURL = registryUrl; - - // Build registry tag in correct format: registry.com/owner/image:tag - // For ghcr.io: ghcr.io/username/image:tag - // For docker.io: docker.io/username/image:tag - const registryTag = imagePrefix + const commands: string[] = []; + if (registry) { + const registryTag = getRegistryTag(registry, imageName); + if (registryTag) { + commands.push(`echo "📦 [Enabled Registry Swarm]"`); + commands.push(getRegistryCommands(registry, imageName, registryTag)); + } + } + if (buildRegistry) { + const buildRegistryTag = getRegistryTag(buildRegistry, imageName); + if (buildRegistryTag) { + commands.push(`echo "🔑 [Enabled Build Registry]"`); + commands.push( + getRegistryCommands(buildRegistry, imageName, buildRegistryTag), + ); + commands.push( + `echo "⚠️ INFO: After the build is finished, you need to wait a few seconds for the server to download the image and run the container."`, + ); + commands.push( + `echo "📊 Check the Logs tab to see when the container starts running."`, + ); + } + } + try { + return commands.join("\n"); + } catch (error) { + throw error; + } +}; +const getRegistryTag = (registry: Registry | null, imageName: string) => { + if (!registry) { + return null; + } + const { registryUrl, imagePrefix, username } = registry; + return imagePrefix ? `${registryUrl ? `${registryUrl}/` : ""}${imagePrefix}/${imageName}` : `${registryUrl ? `${registryUrl}/` : ""}${username}/${imageName}`; - - try { - writeStream.write( - `📦 [Enabled Registry] Uploading image to ${registry.registryType} | ${imageName} | ${finalURL} | ${registryTag}\n`, - ); - const loginCommand = spawnAsync( - "docker", - ["login", finalURL, "-u", registry.username, "--password-stdin"], - (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }, - ); - loginCommand.child?.stdin?.write(registry.password); - loginCommand.child?.stdin?.end(); - await loginCommand; - - await spawnAsync("docker", ["tag", imageName, registryTag], (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - - await spawnAsync("docker", ["push", registryTag], (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - } catch (error) { - console.log(error); - throw error; - } }; -export const uploadImageRemoteCommand = ( - application: ApplicationNested, - logPath: string, -) => { - const registry = application.registry; - - if (!registry) { - throw new Error("Registry not found"); - } - - const { registryUrl, imagePrefix, username } = registry; - const { appName } = application; - const imageName = `${appName}:latest`; - - const finalURL = registryUrl; - - // Build registry tag in correct format: registry.com/owner/image:tag - const registryTag = imagePrefix - ? `${registryUrl}/${imagePrefix}/${imageName}` - : `${registryUrl}/${username}/${imageName}`; - - try { - const command = ` - echo "📦 [Enabled Registry] Uploading image to '${registry.registryType}' | '${registryTag}'" >> ${logPath}; - echo "${registry.password}" | docker login ${finalURL} -u ${registry.username} --password-stdin >> ${logPath} 2>> ${logPath} || { - echo "❌ DockerHub Failed" >> ${logPath}; - exit 1; - } - echo "✅ Registry Login Success" >> ${logPath}; - docker tag ${imageName} ${registryTag} >> ${logPath} 2>> ${logPath} || { - echo "❌ Error tagging image" >> ${logPath}; - exit 1; - } - echo "✅ Image Tagged" >> ${logPath}; - docker push ${registryTag} 2>> ${logPath} || { - echo "❌ Error pushing image" >> ${logPath}; - exit 1; - } - echo "✅ Image Pushed" >> ${logPath}; - `; - return command; - } catch (error) { - throw error; - } +const getRegistryCommands = ( + registry: Registry, + imageName: string, + registryTag: string, +): string => { + return ` +echo "📦 [Enabled Registry] Uploading image to '${registry.registryType}' | '${registryTag}'" ; +echo "${registry.password}" | docker login ${registry.registryUrl} -u ${registry.username} --password-stdin || { + echo "❌ DockerHub Failed" ; + exit 1; +} +echo "✅ Registry Login Success" ; +docker tag ${imageName} ${registryTag} || { + echo "❌ Error tagging image" ; + exit 1; +} +echo "✅ Image Tagged" ; +docker push ${registryTag} || { + echo "❌ Error pushing image" ; + exit 1; +} + echo "✅ Image Pushed" ; +`; }; diff --git a/packages/server/src/utils/databases/mariadb.ts b/packages/server/src/utils/databases/mariadb.ts index 1671de454..a73dd8bb4 100644 --- a/packages/server/src/utils/databases/mariadb.ts +++ b/packages/server/src/utils/databases/mariadb.ts @@ -29,6 +29,7 @@ export const buildMariadb = async (mariadb: MariadbNested) => { cpuLimit, cpuReservation, command, + args, mounts, } = mariadb; @@ -45,6 +46,8 @@ export const buildMariadb = async (mariadb: MariadbNested) => { RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(mariadb); const resources = calculateResources({ memoryLimit, @@ -71,12 +74,16 @@ export const buildMariadb = async (mariadb: MariadbNested) => { Image: dockerImage, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], - ...(command - ? { - Command: ["/bin/sh"], - Args: ["-c", command], - } - : {}), + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), + ...(command && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && { + Args: args, + }), + Labels, }, Networks, @@ -88,19 +95,21 @@ export const buildMariadb = async (mariadb: MariadbNested) => { }, Mode, RollbackConfig, - EndpointSpec: { - Mode: "dnsrr", - Ports: externalPort - ? [ - { - Protocol: "tcp", - TargetPort: 3306, - PublishedPort: externalPort, - PublishMode: "host", - }, - ] - : [], - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Mode: "dnsrr" as const, + Ports: externalPort + ? [ + { + Protocol: "tcp" as const, + TargetPort: 3306, + PublishedPort: externalPort, + PublishMode: "host" as const, + }, + ] + : [], + }, UpdateConfig, }; try { diff --git a/packages/server/src/utils/databases/mongo.ts b/packages/server/src/utils/databases/mongo.ts index b4c36e6eb..9cb8a69f4 100644 --- a/packages/server/src/utils/databases/mongo.ts +++ b/packages/server/src/utils/databases/mongo.ts @@ -28,6 +28,7 @@ export const buildMongo = async (mongo: MongoNested) => { databaseUser, databasePassword, command, + args, mounts, replicaSets, } = mongo; @@ -91,6 +92,8 @@ ${command ?? "wait $MONGOD_PID"}`; RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(mongo); const resources = calculateResources({ @@ -119,17 +122,24 @@ ${command ?? "wait $MONGOD_PID"}`; Image: dockerImage, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), ...(replicaSets ? { Command: ["/bin/bash"], Args: ["-c", startupScript], } - : { - ...(command && { - Command: ["/bin/bash"], - Args: ["-c", command], - }), - }), + : {}), + ...(command && + !replicaSets && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && + !replicaSets && { + Args: args, + }), + Labels, }, Networks, @@ -141,19 +151,21 @@ ${command ?? "wait $MONGOD_PID"}`; }, Mode, RollbackConfig, - EndpointSpec: { - Mode: "dnsrr", - Ports: externalPort - ? [ - { - Protocol: "tcp", - TargetPort: 27017, - PublishedPort: externalPort, - PublishMode: "host", - }, - ] - : [], - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Mode: "dnsrr" as const, + Ports: externalPort + ? [ + { + Protocol: "tcp" as const, + TargetPort: 27017, + PublishedPort: externalPort, + PublishMode: "host" as const, + }, + ] + : [], + }, UpdateConfig, }; diff --git a/packages/server/src/utils/databases/mysql.ts b/packages/server/src/utils/databases/mysql.ts index a3ed72afc..493931fdc 100644 --- a/packages/server/src/utils/databases/mysql.ts +++ b/packages/server/src/utils/databases/mysql.ts @@ -30,6 +30,7 @@ export const buildMysql = async (mysql: MysqlNested) => { cpuLimit, cpuReservation, command, + args, mounts, } = mysql; @@ -51,6 +52,8 @@ export const buildMysql = async (mysql: MysqlNested) => { RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(mysql); const resources = calculateResources({ memoryLimit, @@ -77,12 +80,16 @@ export const buildMysql = async (mysql: MysqlNested) => { Image: dockerImage, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], - ...(command - ? { - Command: ["/bin/sh"], - Args: ["-c", command], - } - : {}), + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), + ...(command && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && { + Args: args, + }), + Labels, }, Networks, @@ -94,19 +101,21 @@ export const buildMysql = async (mysql: MysqlNested) => { }, Mode, RollbackConfig, - EndpointSpec: { - Mode: "dnsrr", - Ports: externalPort - ? [ - { - Protocol: "tcp", - TargetPort: 3306, - PublishedPort: externalPort, - PublishMode: "host", - }, - ] - : [], - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Mode: "dnsrr" as const, + Ports: externalPort + ? [ + { + Protocol: "tcp" as const, + TargetPort: 3306, + PublishedPort: externalPort, + PublishMode: "host" as const, + }, + ] + : [], + }, UpdateConfig, }; try { diff --git a/packages/server/src/utils/databases/postgres.ts b/packages/server/src/utils/databases/postgres.ts index 83f65f1c2..7adb45367 100644 --- a/packages/server/src/utils/databases/postgres.ts +++ b/packages/server/src/utils/databases/postgres.ts @@ -28,6 +28,7 @@ export const buildPostgres = async (postgres: PostgresNested) => { databaseUser, databasePassword, command, + args, mounts, } = postgres; @@ -44,6 +45,8 @@ export const buildPostgres = async (postgres: PostgresNested) => { RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(postgres); const resources = calculateResources({ memoryLimit, @@ -70,12 +73,16 @@ export const buildPostgres = async (postgres: PostgresNested) => { Image: dockerImage, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], - ...(command - ? { - Command: ["/bin/sh"], - Args: ["-c", command], - } - : {}), + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), + ...(command && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && { + Args: args, + }), + Labels, }, Networks, @@ -87,19 +94,21 @@ export const buildPostgres = async (postgres: PostgresNested) => { }, Mode, RollbackConfig, - EndpointSpec: { - Mode: "dnsrr", - Ports: externalPort - ? [ - { - Protocol: "tcp", - TargetPort: 5432, - PublishedPort: externalPort, - PublishMode: "host", - }, - ] - : [], - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Mode: "dnsrr" as const, + Ports: externalPort + ? [ + { + Protocol: "tcp" as const, + TargetPort: 5432, + PublishedPort: externalPort, + PublishMode: "host" as const, + }, + ] + : [], + }, UpdateConfig, }; try { diff --git a/packages/server/src/utils/databases/redis.ts b/packages/server/src/utils/databases/redis.ts index 85ae873d4..4c7701726 100644 --- a/packages/server/src/utils/databases/redis.ts +++ b/packages/server/src/utils/databases/redis.ts @@ -26,6 +26,7 @@ export const buildRedis = async (redis: RedisNested) => { cpuLimit, cpuReservation, command, + args, mounts, } = redis; @@ -42,6 +43,8 @@ export const buildRedis = async (redis: RedisNested) => { RollbackConfig, UpdateConfig, Networks, + StopGracePeriod, + EndpointSpec, } = generateConfigContainer(redis); const resources = calculateResources({ memoryLimit, @@ -68,11 +71,22 @@ export const buildRedis = async (redis: RedisNested) => { Image: dockerImage, Env: envVariables, Mounts: [...volumesMount, ...bindsMount, ...filesMount], - Command: ["/bin/sh"], - Args: [ - "-c", - command ? command : `redis-server --requirepass ${databasePassword}`, - ], + ...(StopGracePeriod !== null && + StopGracePeriod !== undefined && { StopGracePeriod }), + ...(command || args + ? { + ...(command && { + Command: command.split(" "), + }), + ...(args && + args.length > 0 && { + Args: args, + }), + } + : { + Command: ["/bin/sh"], + Args: ["-c", `redis-server --requirepass ${databasePassword}`], + }), Labels, }, Networks, @@ -84,19 +98,21 @@ export const buildRedis = async (redis: RedisNested) => { }, Mode, RollbackConfig, - EndpointSpec: { - Mode: "dnsrr", - Ports: externalPort - ? [ - { - Protocol: "tcp", - TargetPort: 6379, - PublishedPort: externalPort, - PublishMode: "host", - }, - ] - : [], - }, + EndpointSpec: EndpointSpec + ? EndpointSpec + : { + Mode: "dnsrr" as const, + Ports: externalPort + ? [ + { + Protocol: "tcp" as const, + TargetPort: 6379, + PublishedPort: externalPort, + PublishMode: "host" as const, + }, + ] + : [], + }, UpdateConfig, }; diff --git a/packages/server/src/utils/docker/collision.ts b/packages/server/src/utils/docker/collision.ts index 9752100ca..88d20d4d8 100644 --- a/packages/server/src/utils/docker/collision.ts +++ b/packages/server/src/utils/docker/collision.ts @@ -1,11 +1,11 @@ import { findComposeById } from "@dokploy/server/services/compose"; import { stringify } from "yaml"; +import { execAsync, execAsyncRemote } from "../process/execAsync"; import { addAppNameToAllServiceNames } from "./collision/root-network"; import { generateRandomHash } from "./compose"; import { addSuffixToAllVolumes } from "./compose/volume"; import { cloneCompose, - cloneComposeRemote, loadDockerCompose, loadDockerComposeRemote, } from "./domain"; @@ -31,10 +31,11 @@ export const randomizeIsolatedDeploymentComposeFile = async ( ) => { const compose = await findComposeById(composeId); + const command = await cloneCompose(compose); if (compose.serverId) { - await cloneComposeRemote(compose); + await execAsyncRemote(compose.serverId, command); } else { - await cloneCompose(compose); + await execAsync(command); } let composeData: ComposeSpecification | null; diff --git a/packages/server/src/utils/docker/domain.ts b/packages/server/src/utils/docker/domain.ts index 7a9521d1d..2272f364e 100644 --- a/packages/server/src/utils/docker/domain.ts +++ b/packages/server/src/utils/docker/domain.ts @@ -1,35 +1,16 @@ import fs, { existsSync, readFileSync } from "node:fs"; -import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { Compose } from "@dokploy/server/services/compose"; import type { Domain } from "@dokploy/server/services/domain"; import { parse, stringify } from "yaml"; import { execAsyncRemote } from "../process/execAsync"; -import { - cloneRawBitbucketRepository, - cloneRawBitbucketRepositoryRemote, -} from "../providers/bitbucket"; -import { - cloneGitRawRepository, - cloneRawGitRepositoryRemote, -} from "../providers/git"; -import { - cloneRawGiteaRepository, - cloneRawGiteaRepositoryRemote, -} from "../providers/gitea"; -import { - cloneRawGithubRepository, - cloneRawGithubRepositoryRemote, -} from "../providers/github"; -import { - cloneRawGitlabRepository, - cloneRawGitlabRepositoryRemote, -} from "../providers/gitlab"; -import { - createComposeFileRaw, - createComposeFileRawRemote, -} from "../providers/raw"; +import { cloneBitbucketRepository } from "../providers/bitbucket"; +import { cloneGitRepository } from "../providers/git"; +import { cloneGiteaRepository } from "../providers/gitea"; +import { cloneGithubRepository } from "../providers/github"; +import { cloneGitlabRepository } from "../providers/gitlab"; +import { getCreateComposeFileCommand } from "../providers/raw"; import { randomizeDeployableSpecificationFile } from "./collision"; import { randomizeSpecificationFile } from "./compose"; import type { @@ -40,35 +21,25 @@ import type { import { encodeBase64 } from "./utils"; export const cloneCompose = async (compose: Compose) => { + let command = "set -e;"; + const entity = { + ...compose, + type: "compose" as const, + }; if (compose.sourceType === "github") { - await cloneRawGithubRepository(compose); + command += await cloneGithubRepository(entity); } else if (compose.sourceType === "gitlab") { - await cloneRawGitlabRepository(compose); + command += await cloneGitlabRepository(entity); } else if (compose.sourceType === "bitbucket") { - await cloneRawBitbucketRepository(compose); + command += await cloneBitbucketRepository(entity); } else if (compose.sourceType === "git") { - await cloneGitRawRepository(compose); + command += await cloneGitRepository(entity); } else if (compose.sourceType === "gitea") { - await cloneRawGiteaRepository(compose); + command += await cloneGiteaRepository(entity); } else if (compose.sourceType === "raw") { - await createComposeFileRaw(compose); - } -}; - -export const cloneComposeRemote = async (compose: Compose) => { - if (compose.sourceType === "github") { - await cloneRawGithubRepositoryRemote(compose); - } else if (compose.sourceType === "gitlab") { - await cloneRawGitlabRepositoryRemote(compose); - } else if (compose.sourceType === "bitbucket") { - await cloneRawBitbucketRepositoryRemote(compose); - } else if (compose.sourceType === "git") { - await cloneRawGitRepositoryRemote(compose); - } else if (compose.sourceType === "gitea") { - await cloneRawGiteaRepositoryRemote(compose); - } else if (compose.sourceType === "raw") { - await createComposeFileRawRemote(compose); + command += getCreateComposeFileCommand(compose); } + return command; }; export const getComposePath = (compose: Compose) => { @@ -134,25 +105,6 @@ export const readComposeFile = async (compose: Compose) => { export const writeDomainsToCompose = async ( compose: Compose, domains: Domain[], -) => { - if (!domains.length) { - return; - } - const composeConverted = await addDomainToCompose(compose, domains); - - const path = getComposePath(compose); - const composeString = stringify(composeConverted, { lineWidth: 1000 }); - try { - await writeFile(path, composeString, "utf8"); - } catch (error) { - throw error; - } -}; - -export const writeDomainsToComposeRemote = async ( - compose: Compose, - domains: Domain[], - logPath: string, ) => { if (!domains.length) { return ""; @@ -164,23 +116,21 @@ export const writeDomainsToComposeRemote = async ( if (!composeConverted) { return ` -echo "❌ Error: Compose file not found" >> ${logPath}; +echo "❌ Error: Compose file not found"; exit 1; `; } - if (compose.serverId) { - const composeString = stringify(composeConverted, { lineWidth: 1000 }); - const encodedContent = encodeBase64(composeString); - return `echo "${encodedContent}" | base64 -d > "${path}";`; - } + + const composeString = stringify(composeConverted, { lineWidth: 1000 }); + const encodedContent = encodeBase64(composeString); + return `echo "${encodedContent}" | base64 -d > "${path}";`; } catch (error) { // @ts-ignore - return `echo "❌ Has occured an error: ${error?.message || error}" >> ${logPath}; + return `echo "❌ Has occurred an error: ${error?.message || error}"; exit 1; `; } }; -// (node:59875) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit export const addDomainToCompose = async ( compose: Compose, domains: Domain[], @@ -190,7 +140,7 @@ export const addDomainToCompose = async ( let result: ComposeSpecification | null; if (compose.serverId) { - result = await loadDockerComposeRemote(compose); // aca hay que ir al servidor e ir a traer el compose file al servidor + result = await loadDockerComposeRemote(compose); } else { result = await loadDockerCompose(compose); } diff --git a/packages/server/src/utils/docker/utils.ts b/packages/server/src/utils/docker/utils.ts index ae14bcf40..4258cfbbe 100644 --- a/packages/server/src/utils/docker/utils.ts +++ b/packages/server/src/utils/docker/utils.ts @@ -5,6 +5,7 @@ import { docker, paths } from "@dokploy/server/constants"; import type { Compose } from "@dokploy/server/services/compose"; import type { ContainerInfo, ResourceRequirements } from "dockerode"; import { parse } from "dotenv"; +import { quote } from "shell-quote"; import type { ApplicationNested } from "../builders"; import type { MariadbNested } from "../databases/mariadb"; import type { MongoNested } from "../databases/mongo"; @@ -310,6 +311,21 @@ export const prepareEnvironmentVariables = ( return resolvedVars; }; +export const prepareEnvironmentVariablesForShell = ( + serviceEnv: string | null, + projectEnv?: string | null, + environmentEnv?: string | null, +): string[] => { + const envVars = prepareEnvironmentVariables( + serviceEnv, + projectEnv, + environmentEnv, + ); + // Using shell-quote library to properly escape shell arguments + // This is the standard way to handle special characters in shell commands + return envVars.map((env) => quote([env])); +}; + export const parseEnvironmentKeyValuePair = ( pair: string, ): [string, string] => { @@ -394,19 +410,24 @@ export const generateConfigContainer = ( replicas, mounts, networkSwarm, + stopGracePeriodSwarm, + endpointSpecSwarm, } = application; + const sanitizedStopGracePeriodSwarm = + typeof stopGracePeriodSwarm === "bigint" + ? Number(stopGracePeriodSwarm) + : stopGracePeriodSwarm; + const haveMounts = mounts && mounts.length > 0; return { ...(healthCheckSwarm && { HealthCheck: healthCheckSwarm, }), - ...(restartPolicySwarm - ? { - RestartPolicy: restartPolicySwarm, - } - : {}), + ...(restartPolicySwarm && { + RestartPolicy: restartPolicySwarm, + }), ...(placementSwarm ? { Placement: placementSwarm, @@ -444,6 +465,10 @@ export const generateConfigContainer = ( Order: "start-first", }, }), + ...(sanitizedStopGracePeriodSwarm !== null && + sanitizedStopGracePeriodSwarm !== undefined && { + StopGracePeriod: sanitizedStopGracePeriodSwarm, + }), ...(networkSwarm ? { Networks: networkSwarm, @@ -451,6 +476,18 @@ export const generateConfigContainer = ( : { Networks: [{ Target: "dokploy-network" }], }), + ...(endpointSpecSwarm && { + EndpointSpec: { + ...(endpointSpecSwarm.Mode && { Mode: endpointSpecSwarm.Mode }), + Ports: + endpointSpecSwarm.Ports?.map((port) => ({ + Protocol: (port.Protocol || "tcp") as "tcp" | "udp" | "sctp", + TargetPort: port.TargetPort || 0, + PublishedPort: port.PublishedPort || 0, + PublishMode: (port.PublishMode || "host") as "ingress" | "host", + })) || [], + }, + }), }; }; diff --git a/packages/server/src/utils/notifications/build-error.ts b/packages/server/src/utils/notifications/build-error.ts index 0d2c2108b..3ee983031 100644 --- a/packages/server/src/utils/notifications/build-error.ts +++ b/packages/server/src/utils/notifications/build-error.ts @@ -8,6 +8,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendSlackNotification, sendTelegramNotification, @@ -44,172 +45,294 @@ export const sendBuildErrorNotifications = async ({ slack: true, gotify: true, ntfy: true, + lark: true, }, }); for (const notification of notificationList) { - const { email, discord, telegram, slack, gotify, ntfy } = notification; - if (email) { - const template = await renderAsync( - BuildFailedEmail({ - projectName, - applicationName, - applicationType, - errorMessage: errorMessage, - buildLink, - date: date.toLocaleString(), - }), - ).catch(); - await sendEmailNotification(email, "Build failed for dokploy", template); - } + const { email, discord, telegram, slack, gotify, ntfy, lark } = + notification; + try { + if (email) { + const template = await renderAsync( + BuildFailedEmail({ + projectName, + applicationName, + applicationType, + errorMessage: errorMessage, + buildLink, + date: date.toLocaleString(), + }), + ).catch(); + await sendEmailNotification( + email, + "Build failed for dokploy", + template, + ); + } - if (discord) { - const decorate = (decoration: string, text: string) => - `${discord.decoration ? decoration : ""} ${text}`.trim(); + if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); - const limitCharacter = 800; - const truncatedErrorMessage = errorMessage.substring(0, limitCharacter); - await sendDiscordNotification(discord, { - title: decorate(">", "`⚠️` Build Failed"), - color: 0xed4245, - fields: [ - { - name: decorate("`🛠️`", "Project"), - value: projectName, - inline: true, + const limitCharacter = 800; + const truncatedErrorMessage = errorMessage.substring(0, limitCharacter); + await sendDiscordNotification(discord, { + title: decorate(">", "`⚠️` Build Failed"), + color: 0xed4245, + fields: [ + { + name: decorate("`🛠️`", "Project"), + value: projectName, + inline: true, + }, + { + name: decorate("`⚙️`", "Application"), + value: applicationName, + inline: true, + }, + { + name: decorate("`❔`", "Type"), + value: applicationType, + inline: true, + }, + { + name: decorate("`📅`", "Date"), + value: ``, + inline: true, + }, + { + name: decorate("`⌚`", "Time"), + value: ``, + inline: true, + }, + { + name: decorate("`❓`", "Type"), + value: "Failed", + inline: true, + }, + { + name: decorate("`⚠️`", "Error Message"), + value: `\`\`\`${truncatedErrorMessage}\`\`\``, + }, + { + name: decorate("`🧷`", "Build Link"), + value: `[Click here to access build link](${buildLink})`, + }, + ], + timestamp: date.toISOString(), + footer: { + text: "Dokploy Build Notification", }, - { - name: decorate("`⚙️`", "Application"), - value: applicationName, - inline: true, - }, - { - name: decorate("`❔`", "Type"), - value: applicationType, - inline: true, - }, - { - name: decorate("`📅`", "Date"), - value: ``, - inline: true, - }, - { - name: decorate("`⌚`", "Time"), - value: ``, - inline: true, - }, - { - name: decorate("`❓`", "Type"), - value: "Failed", - inline: true, - }, - { - name: decorate("`⚠️`", "Error Message"), - value: `\`\`\`${truncatedErrorMessage}\`\`\``, - }, - { - name: decorate("`🧷`", "Build Link"), - value: `[Click here to access build link](${buildLink})`, - }, - ], - timestamp: date.toISOString(), - footer: { - text: "Dokploy Build Notification", - }, - }); - } + }); + } - if (gotify) { - const decorate = (decoration: string, text: string) => - `${gotify.decoration ? decoration : ""} ${text}\n`; - await sendGotifyNotification( - gotify, - decorate("⚠️", "Build Failed"), - `${decorate("🛠️", `Project: ${projectName}`)}` + - `${decorate("⚙️", `Application: ${applicationName}`)}` + - `${decorate("❔", `Type: ${applicationType}`)}` + - `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + - `${decorate("⚠️", `Error:\n${errorMessage}`)}` + - `${decorate("🔗", `Build details:\n${buildLink}`)}`, - ); - } + if (gotify) { + const decorate = (decoration: string, text: string) => + `${gotify.decoration ? decoration : ""} ${text}\n`; + await sendGotifyNotification( + gotify, + decorate("⚠️", "Build Failed"), + `${decorate("🛠️", `Project: ${projectName}`)}` + + `${decorate("⚙️", `Application: ${applicationName}`)}` + + `${decorate("❔", `Type: ${applicationType}`)}` + + `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + + `${decorate("⚠️", `Error:\n${errorMessage}`)}` + + `${decorate("🔗", `Build details:\n${buildLink}`)}`, + ); + } - if (ntfy) { - await sendNtfyNotification( - ntfy, - "Build Failed", - "warning", - `view, Build details, ${buildLink}, clear=true;`, - `🛠️Project: ${projectName}\n` + - `⚙️Application: ${applicationName}\n` + - `❔Type: ${applicationType}\n` + - `🕒Date: ${date.toLocaleString()}\n` + - `⚠️Error:\n${errorMessage}`, - ); - } + if (ntfy) { + await sendNtfyNotification( + ntfy, + "Build Failed", + "warning", + `view, Build details, ${buildLink}, clear=true;`, + `🛠️Project: ${projectName}\n` + + `⚙️Application: ${applicationName}\n` + + `❔Type: ${applicationType}\n` + + `🕒Date: ${date.toLocaleString()}\n` + + `⚠️Error:\n${errorMessage}`, + ); + } - if (telegram) { - const inlineButton = [ - [ - { - text: "Deployment Logs", - url: buildLink, - }, - ], - ]; + if (telegram) { + const inlineButton = [ + [ + { + text: "Deployment Logs", + url: buildLink, + }, + ], + ]; - await sendTelegramNotification( - telegram, - `⚠️ Build Failed\n\nProject: ${projectName}\nApplication: ${applicationName}\nType: ${applicationType}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}\n\nError:\n
${errorMessage}
`, - inlineButton, - ); - } + await sendTelegramNotification( + telegram, + `⚠️ Build Failed\n\nProject: ${projectName}\nApplication: ${applicationName}\nType: ${applicationType}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}\n\nError:\n
${errorMessage}
`, + inlineButton, + ); + } - if (slack) { - const { channel } = slack; - await sendSlackNotification(slack, { - channel: channel, - attachments: [ - { - color: "#FF0000", - pretext: ":warning: *Build Failed*", - fields: [ - { - title: "Project", - value: projectName, - short: true, + if (slack) { + const { channel } = slack; + await sendSlackNotification(slack, { + channel: channel, + attachments: [ + { + color: "#FF0000", + pretext: ":warning: *Build Failed*", + fields: [ + { + title: "Project", + value: projectName, + short: true, + }, + { + title: "Application", + value: applicationName, + short: true, + }, + { + title: "Type", + value: applicationType, + short: true, + }, + { + title: "Time", + value: date.toLocaleString(), + short: true, + }, + { + title: "Error", + value: `\`\`\`${errorMessage}\`\`\``, + short: false, + }, + ], + actions: [ + { + type: "button", + text: "View Build Details", + url: buildLink, + }, + ], + }, + ], + }); + } + + if (lark) { + const limitCharacter = 800; + const truncatedErrorMessage = errorMessage.substring(0, limitCharacter); + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, }, - { - title: "Application", - value: applicationName, - short: true, + }, + header: { + title: { + tag: "plain_text", + content: "⚠️ Build Failed", }, - { - title: "Type", - value: applicationType, - short: true, + subtitle: { + tag: "plain_text", + content: "", }, - { - title: "Time", - value: date.toLocaleString(), - short: true, - }, - { - title: "Error", - value: `\`\`\`${errorMessage}\`\`\``, - short: false, - }, - ], - actions: [ - { - type: "button", - text: "View Build Details", - url: buildLink, - }, - ], + template: "red", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Project:**\n${projectName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Type:**\n${applicationType}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Application:**\n${applicationName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Date:**\n${format(date, "PP pp")}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + { + tag: "button", + text: { + tag: "plain_text", + content: "View Build Details", + }, + type: "danger", + width: "default", + size: "medium", + behaviors: [ + { + type: "open_url", + default_url: buildLink, + pc_url: "", + ios_url: "", + android_url: "", + }, + ], + margin: "0px 0px 0px 0px", + }, + ], + }, }, - ], - }); + }); + } + } catch (error) { + console.log(error); } } }; diff --git a/packages/server/src/utils/notifications/build-success.ts b/packages/server/src/utils/notifications/build-success.ts index fb8b89f76..232eb76c2 100644 --- a/packages/server/src/utils/notifications/build-success.ts +++ b/packages/server/src/utils/notifications/build-success.ts @@ -9,6 +9,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendSlackNotification, sendTelegramNotification, @@ -21,6 +22,7 @@ interface Props { buildLink: string; organizationId: string; domains: Domain[]; + environmentName: string; } export const sendBuildSuccessNotifications = async ({ @@ -30,6 +32,7 @@ export const sendBuildSuccessNotifications = async ({ buildLink, organizationId, domains, + environmentName, }: Props) => { const date = new Date(); const unixDate = ~~(Number(date) / 1000); @@ -45,170 +48,302 @@ export const sendBuildSuccessNotifications = async ({ slack: true, gotify: true, ntfy: true, + lark: true, }, }); for (const notification of notificationList) { - const { email, discord, telegram, slack, gotify, ntfy } = notification; - - if (email) { - const template = await renderAsync( - BuildSuccessEmail({ - projectName, - applicationName, - applicationType, - buildLink, - date: date.toLocaleString(), - }), - ).catch(); - await sendEmailNotification(email, "Build success for dokploy", template); - } - - if (discord) { - const decorate = (decoration: string, text: string) => - `${discord.decoration ? decoration : ""} ${text}`.trim(); - - await sendDiscordNotification(discord, { - title: decorate(">", "`✅` Build Success"), - color: 0x57f287, - fields: [ - { - name: decorate("`🛠️`", "Project"), - value: projectName, - inline: true, - }, - { - name: decorate("`⚙️`", "Application"), - value: applicationName, - inline: true, - }, - { - name: decorate("`❔`", "Type"), - value: applicationType, - inline: true, - }, - { - name: decorate("`📅`", "Date"), - value: ``, - inline: true, - }, - { - name: decorate("`⌚`", "Time"), - value: ``, - inline: true, - }, - { - name: decorate("`❓`", "Type"), - value: "Successful", - inline: true, - }, - { - name: decorate("`🧷`", "Build Link"), - value: `[Click here to access build link](${buildLink})`, - }, - ], - timestamp: date.toISOString(), - footer: { - text: "Dokploy Build Notification", - }, - }); - } - - if (gotify) { - const decorate = (decoration: string, text: string) => - `${gotify.decoration ? decoration : ""} ${text}\n`; - await sendGotifyNotification( - gotify, - decorate("✅", "Build Success"), - `${decorate("🛠️", `Project: ${projectName}`)}` + - `${decorate("⚙️", `Application: ${applicationName}`)}` + - `${decorate("❔", `Type: ${applicationType}`)}` + - `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + - `${decorate("🔗", `Build details:\n${buildLink}`)}`, - ); - } - - if (ntfy) { - await sendNtfyNotification( - ntfy, - "Build Success", - "white_check_mark", - `view, Build details, ${buildLink}, clear=true;`, - `🛠Project: ${projectName}\n` + - `⚙️Application: ${applicationName}\n` + - `❔Type: ${applicationType}\n` + - `🕒Date: ${date.toLocaleString()}`, - ); - } - - if (telegram) { - const chunkArray = (array: T[], chunkSize: number): T[][] => - Array.from({ length: Math.ceil(array.length / chunkSize) }, (_, i) => - array.slice(i * chunkSize, i * chunkSize + chunkSize), + const { email, discord, telegram, slack, gotify, ntfy, lark } = + notification; + try { + if (email) { + const template = await renderAsync( + BuildSuccessEmail({ + projectName, + applicationName, + applicationType, + buildLink, + date: date.toLocaleString(), + environmentName, + }), + ).catch(); + await sendEmailNotification( + email, + "Build success for dokploy", + template, ); + } - const inlineButton = [ - [ - { - text: "Deployment Logs", - url: buildLink, + if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + + await sendDiscordNotification(discord, { + title: decorate(">", "`✅` Build Successes"), + color: 0x57f287, + fields: [ + { + name: decorate("`🛠️`", "Project"), + value: projectName, + inline: true, + }, + { + name: decorate("`⚙️`", "Application"), + value: applicationName, + inline: true, + }, + { + name: decorate("`🌍`", "Environment"), + value: environmentName, + inline: true, + }, + { + name: decorate("`❔`", "Type"), + value: applicationType, + inline: true, + }, + { + name: decorate("`📅`", "Date"), + value: ``, + inline: true, + }, + { + name: decorate("`⌚`", "Time"), + value: ``, + inline: true, + }, + { + name: decorate("`❓`", "Type"), + value: "Successful", + inline: true, + }, + { + name: decorate("`🧷`", "Build Link"), + value: `[Click here to access build link](${buildLink})`, + }, + ], + timestamp: date.toISOString(), + footer: { + text: "Dokploy Build Notification", }, - ], - ...chunkArray(domains, 2).map((chunk) => - chunk.map((data) => ({ - text: data.host, - url: `${data.https ? "https" : "http"}://${data.host}`, - })), - ), - ]; + }); + } - await sendTelegramNotification( - telegram, - `✅ Build Success\n\nProject: ${projectName}\nApplication: ${applicationName}\nType: ${applicationType}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}`, - inlineButton, - ); - } + if (gotify) { + const decorate = (decoration: string, text: string) => + `${gotify.decoration ? decoration : ""} ${text}\n`; + await sendGotifyNotification( + gotify, + decorate("✅", "Build Success"), + `${decorate("🛠️", `Project: ${projectName}`)}` + + `${decorate("⚙️", `Application: ${applicationName}`)}` + + `${decorate("🌍", `Environment: ${environmentName}`)}` + + `${decorate("❔", `Type: ${applicationType}`)}` + + `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + + `${decorate("🔗", `Build details:\n${buildLink}`)}`, + ); + } - if (slack) { - const { channel } = slack; - await sendSlackNotification(slack, { - channel: channel, - attachments: [ - { - color: "#00FF00", - pretext: ":white_check_mark: *Build Success*", - fields: [ - { - title: "Project", - value: projectName, - short: true, + if (ntfy) { + await sendNtfyNotification( + ntfy, + "Build Success", + "white_check_mark", + `view, Build details, ${buildLink}, clear=true;`, + `🛠Project: ${projectName}\n` + + `⚙️Application: ${applicationName}\n` + + `🌍Environment: ${environmentName}\n` + + `❔Type: ${applicationType}\n` + + `🕒Date: ${date.toLocaleString()}`, + ); + } + + if (telegram) { + const chunkArray = (array: T[], chunkSize: number): T[][] => + Array.from({ length: Math.ceil(array.length / chunkSize) }, (_, i) => + array.slice(i * chunkSize, i * chunkSize + chunkSize), + ); + + const inlineButton = [ + [ + { + text: "Deployment Logs", + url: buildLink, + }, + ], + ...chunkArray(domains, 2).map((chunk) => + chunk.map((data) => ({ + text: data.host, + url: `${data.https ? "https" : "http"}://${data.host}`, + })), + ), + ]; + + await sendTelegramNotification( + telegram, + `✅ Build Success\n\nProject: ${projectName}\nApplication: ${applicationName}\nEnvironment: ${environmentName}\nType: ${applicationType}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}`, + inlineButton, + ); + } + + if (slack) { + const { channel } = slack; + await sendSlackNotification(slack, { + channel: channel, + attachments: [ + { + color: "#00FF00", + pretext: ":white_check_mark: *Build Success*", + fields: [ + { + title: "Project", + value: projectName, + short: true, + }, + { + title: "Application", + value: applicationName, + short: true, + }, + { + title: "Environment", + value: environmentName, + short: true, + }, + { + title: "Type", + value: applicationType, + short: true, + }, + { + title: "Time", + value: date.toLocaleString(), + short: true, + }, + ], + actions: [ + { + type: "button", + text: "View Build Details", + url: buildLink, + }, + ], + }, + ], + }); + } + + if (lark) { + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, }, - { - title: "Application", - value: applicationName, - short: true, + }, + header: { + title: { + tag: "plain_text", + content: "✅ Build Success", }, - { - title: "Type", - value: applicationType, - short: true, + subtitle: { + tag: "plain_text", + content: "", }, - { - title: "Time", - value: date.toLocaleString(), - short: true, - }, - ], - actions: [ - { - type: "button", - text: "View Build Details", - url: buildLink, - }, - ], + template: "green", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Project:**\n${projectName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Environment:**\n${environmentName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Type:**\n${applicationType}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Application:**\n${applicationName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Date:**\n${format(date, "PP pp")}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + { + tag: "button", + text: { + tag: "plain_text", + content: "View Build Details", + }, + type: "primary", + width: "default", + size: "medium", + behaviors: [ + { + type: "open_url", + default_url: buildLink, + pc_url: "", + ios_url: "", + android_url: "", + }, + ], + margin: "0px 0px 0px 0px", + }, + ], + }, }, - ], - }); + }); + } + } catch (error) { + console.log(error); } } }; diff --git a/packages/server/src/utils/notifications/database-backup.ts b/packages/server/src/utils/notifications/database-backup.ts index f3c5cd5f4..02141e3ae 100644 --- a/packages/server/src/utils/notifications/database-backup.ts +++ b/packages/server/src/utils/notifications/database-backup.ts @@ -8,6 +8,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendSlackNotification, sendTelegramNotification, @@ -44,199 +45,319 @@ export const sendDatabaseBackupNotifications = async ({ slack: true, gotify: true, ntfy: true, + lark: true, }, }); for (const notification of notificationList) { - const { email, discord, telegram, slack, gotify, ntfy } = notification; + const { email, discord, telegram, slack, gotify, ntfy, lark } = + notification; + try { + if (email) { + const template = await renderAsync( + DatabaseBackupEmail({ + projectName, + applicationName, + databaseType, + type, + errorMessage, + date: date.toLocaleString(), + }), + ).catch(); + await sendEmailNotification( + email, + "Database backup for dokploy", + template, + ); + } - if (email) { - const template = await renderAsync( - DatabaseBackupEmail({ - projectName, - applicationName, - databaseType, - type, - errorMessage, - date: date.toLocaleString(), - }), - ).catch(); - await sendEmailNotification( - email, - "Database backup for dokploy", - template, - ); - } + if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); - if (discord) { - const decorate = (decoration: string, text: string) => - `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { + title: + type === "success" + ? decorate(">", "`✅` Database Backup Successful") + : decorate(">", "`❌` Database Backup Failed"), + color: type === "success" ? 0x57f287 : 0xed4245, + fields: [ + { + name: decorate("`🛠️`", "Project"), + value: projectName, + inline: true, + }, + { + name: decorate("`⚙️`", "Application"), + value: applicationName, + inline: true, + }, + { + name: decorate("`❔`", "Database"), + value: databaseType, + inline: true, + }, + { + name: decorate("`📂`", "Database Name"), + value: databaseName, + inline: true, + }, + { + name: decorate("`📅`", "Date"), + value: ``, + inline: true, + }, + { + name: decorate("`⌚`", "Time"), + value: ``, + inline: true, + }, + { + name: decorate("`❓`", "Type"), + value: type + .replace("error", "Failed") + .replace("success", "Successful"), + inline: true, + }, + ...(type === "error" && errorMessage + ? [ + { + name: decorate("`⚠️`", "Error Message"), + value: `\`\`\`${errorMessage}\`\`\``, + }, + ] + : []), + ], + timestamp: date.toISOString(), + footer: { + text: "Dokploy Database Backup Notification", + }, + }); + } - await sendDiscordNotification(discord, { - title: - type === "success" - ? decorate(">", "`✅` Database Backup Successful") - : decorate(">", "`❌` Database Backup Failed"), - color: type === "success" ? 0x57f287 : 0xed4245, - fields: [ - { - name: decorate("`🛠️`", "Project"), - value: projectName, - inline: true, - }, - { - name: decorate("`⚙️`", "Application"), - value: applicationName, - inline: true, - }, - { - name: decorate("`❔`", "Database"), - value: databaseType, - inline: true, - }, - { - name: decorate("`📂`", "Database Name"), - value: databaseName, - inline: true, - }, - { - name: decorate("`📅`", "Date"), - value: ``, - inline: true, - }, - { - name: decorate("`⌚`", "Time"), - value: ``, - inline: true, - }, - { - name: decorate("`❓`", "Type"), - value: type - .replace("error", "Failed") - .replace("success", "Successful"), - inline: true, - }, - ...(type === "error" && errorMessage - ? [ - { - name: decorate("`⚠️`", "Error Message"), - value: `\`\`\`${errorMessage}\`\`\``, - }, - ] - : []), - ], - timestamp: date.toISOString(), - footer: { - text: "Dokploy Database Backup Notification", - }, - }); - } + if (gotify) { + const decorate = (decoration: string, text: string) => + `${gotify.decoration ? decoration : ""} ${text}\n`; - if (gotify) { - const decorate = (decoration: string, text: string) => - `${gotify.decoration ? decoration : ""} ${text}\n`; + await sendGotifyNotification( + gotify, + decorate( + type === "success" ? "✅" : "❌", + `Database Backup ${type === "success" ? "Successful" : "Failed"}`, + ), + `${decorate("🛠️", `Project: ${projectName}`)}` + + `${decorate("⚙️", `Application: ${applicationName}`)}` + + `${decorate("❔", `Type: ${databaseType}`)}` + + `${decorate("📂", `Database Name: ${databaseName}`)}` + + `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + + `${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`, + ); + } - await sendGotifyNotification( - gotify, - decorate( - type === "success" ? "✅" : "❌", + if (ntfy) { + await sendNtfyNotification( + ntfy, `Database Backup ${type === "success" ? "Successful" : "Failed"}`, - ), - `${decorate("🛠️", `Project: ${projectName}`)}` + - `${decorate("⚙️", `Application: ${applicationName}`)}` + - `${decorate("❔", `Type: ${databaseType}`)}` + - `${decorate("📂", `Database Name: ${databaseName}`)}` + - `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + - `${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`, - ); - } + `${type === "success" ? "white_check_mark" : "x"}`, + "", + `🛠Project: ${projectName}\n` + + `⚙️Application: ${applicationName}\n` + + `❔Type: ${databaseType}\n` + + `📂Database Name: ${databaseName}` + + `🕒Date: ${date.toLocaleString()}\n` + + `${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`, + ); + } - if (ntfy) { - await sendNtfyNotification( - ntfy, - `Database Backup ${type === "success" ? "Successful" : "Failed"}`, - `${type === "success" ? "white_check_mark" : "x"}`, - "", - `🛠Project: ${projectName}\n` + - `⚙️Application: ${applicationName}\n` + - `❔Type: ${databaseType}\n` + - `📂Database Name: ${databaseName}` + - `🕒Date: ${date.toLocaleString()}\n` + - `${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`, - ); - } + if (telegram) { + const isError = type === "error" && errorMessage; - if (telegram) { - const isError = type === "error" && errorMessage; + const statusEmoji = type === "success" ? "✅" : "❌"; + const typeStatus = type === "success" ? "Successful" : "Failed"; + const errorMsg = isError + ? `\n\nError:\n
${errorMessage}
` + : ""; - const statusEmoji = type === "success" ? "✅" : "❌"; - const typeStatus = type === "success" ? "Successful" : "Failed"; - const errorMsg = isError - ? `\n\nError:\n
${errorMessage}
` - : ""; + const messageText = `${statusEmoji} Database Backup ${typeStatus}\n\nProject: ${projectName}\nApplication: ${applicationName}\nType: ${databaseType}\nDatabase Name: ${databaseName}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}${isError ? errorMsg : ""}`; - const messageText = `${statusEmoji} Database Backup ${typeStatus}\n\nProject: ${projectName}\nApplication: ${applicationName}\nType: ${databaseType}\nDatabase Name: ${databaseName}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}${isError ? errorMsg : ""}`; + await sendTelegramNotification(telegram, messageText); + } - await sendTelegramNotification(telegram, messageText); - } + if (slack) { + const { channel } = slack; + await sendSlackNotification(slack, { + channel: channel, + attachments: [ + { + color: type === "success" ? "#00FF00" : "#FF0000", + pretext: + type === "success" + ? ":white_check_mark: *Database Backup Successful*" + : ":x: *Database Backup Failed*", + fields: [ + ...(type === "error" && errorMessage + ? [ + { + title: "Error Message", + value: errorMessage, + short: false, + }, + ] + : []), + { + title: "Project", + value: projectName, + short: true, + }, + { + title: "Application", + value: applicationName, + short: true, + }, + { + title: "Type", + value: databaseType, + short: true, + }, + { + title: "Database Name", + value: databaseName, + }, + { + title: "Time", + value: date.toLocaleString(), + short: true, + }, + { + title: "Type", + value: type, + }, + { + title: "Status", + value: type === "success" ? "Successful" : "Failed", + }, + ], + }, + ], + }); + } - if (slack) { - const { channel } = slack; - await sendSlackNotification(slack, { - channel: channel, - attachments: [ - { - color: type === "success" ? "#00FF00" : "#FF0000", - pretext: - type === "success" - ? ":white_check_mark: *Database Backup Successful*" - : ":x: *Database Backup Failed*", - fields: [ - ...(type === "error" && errorMessage - ? [ + if (lark) { + const limitCharacter = 800; + const truncatedErrorMessage = + errorMessage && errorMessage.length > limitCharacter + ? errorMessage.substring(0, limitCharacter) + : errorMessage; + + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, + }, + }, + header: { + title: { + tag: "plain_text", + content: + type === "success" + ? "✅ Database Backup Successful" + : "❌ Database Backup Failed", + }, + subtitle: { + tag: "plain_text", + content: "", + }, + template: type === "success" ? "green" : "red", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ { - title: "Error Message", - value: errorMessage, - short: false, + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Project:**\n${projectName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Database Type:**\n${databaseType}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Status:**\n${type === "success" ? "Successful" : "Failed"}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, }, - ] - : []), - { - title: "Project", - value: projectName, - short: true, - }, - { - title: "Application", - value: applicationName, - short: true, - }, - { - title: "Type", - value: databaseType, - short: true, - }, - { - title: "Database Name", - value: databaseName, - }, - { - title: "Time", - value: date.toLocaleString(), - short: true, - }, - { - title: "Type", - value: type, - }, - { - title: "Status", - value: type === "success" ? "Successful" : "Failed", - }, - ], + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Application:**\n${applicationName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Database Name:**\n${databaseName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Date:**\n${format(date, "PP pp")}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + ...(type === "error" && truncatedErrorMessage + ? [ + { + tag: "markdown", + content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``, + text_align: "left", + text_size: "normal_v2", + }, + ] + : []), + ], + }, }, - ], - }); + }); + } + } catch (error) { + console.log(error); } } }; diff --git a/packages/server/src/utils/notifications/docker-cleanup.ts b/packages/server/src/utils/notifications/docker-cleanup.ts index 15b1c347a..f7947c8a0 100644 --- a/packages/server/src/utils/notifications/docker-cleanup.ts +++ b/packages/server/src/utils/notifications/docker-cleanup.ts @@ -8,6 +8,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendSlackNotification, sendTelegramNotification, @@ -31,109 +32,192 @@ export const sendDockerCleanupNotifications = async ( slack: true, gotify: true, ntfy: true, + lark: true, }, }); for (const notification of notificationList) { - const { email, discord, telegram, slack, gotify, ntfy } = notification; + const { email, discord, telegram, slack, gotify, ntfy, lark } = + notification; + try { + if (email) { + const template = await renderAsync( + DockerCleanupEmail({ message, date: date.toLocaleString() }), + ).catch(); - if (email) { - const template = await renderAsync( - DockerCleanupEmail({ message, date: date.toLocaleString() }), - ).catch(); + await sendEmailNotification( + email, + "Docker cleanup for dokploy", + template, + ); + } - await sendEmailNotification( - email, - "Docker cleanup for dokploy", - template, - ); - } + if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); - if (discord) { - const decorate = (decoration: string, text: string) => - `${discord.decoration ? decoration : ""} ${text}`.trim(); - - await sendDiscordNotification(discord, { - title: decorate(">", "`✅` Docker Cleanup"), - color: 0x57f287, - fields: [ - { - name: decorate("`📅`", "Date"), - value: ``, - inline: true, + await sendDiscordNotification(discord, { + title: decorate(">", "`✅` Docker Cleanup"), + color: 0x57f287, + fields: [ + { + name: decorate("`📅`", "Date"), + value: ``, + inline: true, + }, + { + name: decorate("`⌚`", "Time"), + value: ``, + inline: true, + }, + { + name: decorate("`❓`", "Type"), + value: "Successful", + inline: true, + }, + { + name: decorate("`📜`", "Message"), + value: `\`\`\`${message}\`\`\``, + }, + ], + timestamp: date.toISOString(), + footer: { + text: "Dokploy Docker Cleanup Notification", }, - { - name: decorate("`⌚`", "Time"), - value: ``, - inline: true, - }, - { - name: decorate("`❓`", "Type"), - value: "Successful", - inline: true, - }, - { - name: decorate("`📜`", "Message"), - value: `\`\`\`${message}\`\`\``, - }, - ], - timestamp: date.toISOString(), - footer: { - text: "Dokploy Docker Cleanup Notification", - }, - }); - } + }); + } - if (gotify) { - const decorate = (decoration: string, text: string) => - `${gotify.decoration ? decoration : ""} ${text}\n`; - await sendGotifyNotification( - gotify, - decorate("✅", "Docker Cleanup"), - `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + - `${decorate("📜", `Message:\n${message}`)}`, - ); - } + if (gotify) { + const decorate = (decoration: string, text: string) => + `${gotify.decoration ? decoration : ""} ${text}\n`; + await sendGotifyNotification( + gotify, + decorate("✅", "Docker Cleanup"), + `${decorate("🕒", `Date: ${date.toLocaleString()}`)}` + + `${decorate("📜", `Message:\n${message}`)}`, + ); + } - if (ntfy) { - await sendNtfyNotification( - ntfy, - "Docker Cleanup", - "white_check_mark", - "", - `🕒Date: ${date.toLocaleString()}\n` + `📜Message:\n${message}`, - ); - } + if (ntfy) { + await sendNtfyNotification( + ntfy, + "Docker Cleanup", + "white_check_mark", + "", + `🕒Date: ${date.toLocaleString()}\n` + `📜Message:\n${message}`, + ); + } - if (telegram) { - await sendTelegramNotification( - telegram, - `✅ Docker Cleanup\n\nMessage: ${message}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}`, - ); - } + if (telegram) { + await sendTelegramNotification( + telegram, + `✅ Docker Cleanup\n\nMessage: ${message}\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}`, + ); + } - if (slack) { - const { channel } = slack; - await sendSlackNotification(slack, { - channel: channel, - attachments: [ - { - color: "#00FF00", - pretext: ":white_check_mark: *Docker Cleanup*", - fields: [ - { - title: "Message", - value: message, + if (slack) { + const { channel } = slack; + await sendSlackNotification(slack, { + channel: channel, + attachments: [ + { + color: "#00FF00", + pretext: ":white_check_mark: *Docker Cleanup*", + fields: [ + { + title: "Message", + value: message, + }, + { + title: "Time", + value: date.toLocaleString(), + short: true, + }, + ], + }, + ], + }); + } + + if (lark) { + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, }, - { - title: "Time", - value: date.toLocaleString(), - short: true, + }, + header: { + title: { + tag: "plain_text", + content: "✅ Docker Cleanup", }, - ], + subtitle: { + tag: "plain_text", + content: "", + }, + template: "green", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: "**Status:**\nSuccessful", + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Cleanup Details:**\n${message}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Date:**\n${format(date, "PP pp")}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + ], + }, }, - ], - }); + }); + } + } catch (error) { + console.log(error); } } }; diff --git a/packages/server/src/utils/notifications/dokploy-restart.ts b/packages/server/src/utils/notifications/dokploy-restart.ts index a6ade6f11..093e14010 100644 --- a/packages/server/src/utils/notifications/dokploy-restart.ts +++ b/packages/server/src/utils/notifications/dokploy-restart.ts @@ -8,6 +8,7 @@ import { sendDiscordNotification, sendEmailNotification, sendGotifyNotification, + sendLarkNotification, sendNtfyNotification, sendSlackNotification, sendTelegramNotification, @@ -25,24 +26,31 @@ export const sendDokployRestartNotifications = async () => { slack: true, gotify: true, ntfy: true, + lark: true, }, }); for (const notification of notificationList) { - const { email, discord, telegram, slack, gotify, ntfy } = notification; + const { email, discord, telegram, slack, gotify, ntfy, lark } = + notification; - if (email) { - const template = await renderAsync( - DokployRestartEmail({ date: date.toLocaleString() }), - ).catch(); - await sendEmailNotification(email, "Dokploy Server Restarted", template); - } + try { + if (email) { + const template = await renderAsync( + DokployRestartEmail({ date: date.toLocaleString() }), + ).catch(); - if (discord) { - const decorate = (decoration: string, text: string) => - `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendEmailNotification( + email, + "Dokploy Server Restarted", + template, + ); + } + + if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); - try { await sendDiscordNotification(discord, { title: decorate(">", "`✅` Dokploy Server Restarted"), color: 0x57f287, @@ -68,27 +76,19 @@ export const sendDokployRestartNotifications = async () => { text: "Dokploy Restart Notification", }, }); - } catch (error) { - console.log(error); } - } - if (gotify) { - const decorate = (decoration: string, text: string) => - `${gotify.decoration ? decoration : ""} ${text}\n`; - try { + if (gotify) { + const decorate = (decoration: string, text: string) => + `${gotify.decoration ? decoration : ""} ${text}\n`; await sendGotifyNotification( gotify, decorate("✅", "Dokploy Server Restarted"), `${decorate("🕒", `Date: ${date.toLocaleString()}`)}`, ); - } catch (error) { - console.log(error); } - } - if (ntfy) { - try { + if (ntfy) { await sendNtfyNotification( ntfy, "Dokploy Server Restarted", @@ -96,25 +96,17 @@ export const sendDokployRestartNotifications = async () => { "", `🕒Date: ${date.toLocaleString()}`, ); - } catch (error) { - console.log(error); } - } - if (telegram) { - try { + if (telegram) { await sendTelegramNotification( telegram, `✅ Dokploy Server Restarted\n\nDate: ${format(date, "PP")}\nTime: ${format(date, "pp")}`, ); - } catch (error) { - console.log(error); } - } - if (slack) { - const { channel } = slack; - try { + if (slack) { + const { channel } = slack; await sendSlackNotification(slack, { channel: channel, attachments: [ @@ -131,9 +123,81 @@ export const sendDokployRestartNotifications = async () => { }, ], }); - } catch (error) { - console.log(error); } + + if (lark) { + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, + }, + }, + header: { + title: { + tag: "plain_text", + content: "✅ Dokploy Server Restarted", + }, + subtitle: { + tag: "plain_text", + content: "", + }, + template: "green", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: "**Status:**\nSuccessful", + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Restart Time:**\n${format(date, "PP pp")}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + ], + }, + }, + }); + } + } catch (error) { + console.log(error); } } }; diff --git a/packages/server/src/utils/notifications/server-threshold.ts b/packages/server/src/utils/notifications/server-threshold.ts index 2e63ba25a..b8d627425 100644 --- a/packages/server/src/utils/notifications/server-threshold.ts +++ b/packages/server/src/utils/notifications/server-threshold.ts @@ -3,6 +3,7 @@ import { db } from "../../db"; import { notifications } from "../../db/schema"; import { sendDiscordNotification, + sendLarkNotification, sendSlackNotification, sendTelegramNotification, } from "./utils"; @@ -34,6 +35,7 @@ export const sendServerThresholdNotifications = async ( discord: true, telegram: true, slack: true, + lark: true, }, }); @@ -41,7 +43,7 @@ export const sendServerThresholdNotifications = async ( const typeColor = 0xff0000; // Rojo para indicar alerta for (const notification of notificationList) { - const { discord, telegram, slack } = notification; + const { discord, telegram, slack, lark } = notification; if (discord) { const decorate = (decoration: string, text: string) => @@ -151,5 +153,101 @@ export const sendServerThresholdNotifications = async ( ], }); } + + if (lark) { + await sendLarkNotification(lark, { + msg_type: "interactive", + card: { + schema: "2.0", + config: { + update_multi: true, + style: { + text_size: { + normal_v2: { + default: "normal", + pc: "normal", + mobile: "heading", + }, + }, + }, + }, + header: { + title: { + tag: "plain_text", + content: `⚠️ Server ${payload.Type} Alert`, + }, + subtitle: { + tag: "plain_text", + content: "", + }, + template: "red", + padding: "12px 12px 12px 12px", + }, + body: { + direction: "vertical", + padding: "12px 12px 12px 12px", + elements: [ + { + tag: "column_set", + columns: [ + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Server Name:**\n${payload.ServerName}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Current Value:**\n${payload.Value.toFixed(2)}%`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Alert Message:**\n${payload.Message}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + { + tag: "column", + width: "weighted", + elements: [ + { + tag: "markdown", + content: `**Type:**\n${payload.Type === "CPU" ? "🔲" : "💾"} ${payload.Type}`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Threshold:**\n${payload.Threshold.toFixed(2)}%`, + text_align: "left", + text_size: "normal_v2", + }, + { + tag: "markdown", + content: `**Alert Time:**\n${date.toLocaleString()}`, + text_align: "left", + text_size: "normal_v2", + }, + ], + vertical_align: "top", + weight: 1, + }, + ], + }, + ], + }, + }, + }); + } } }; diff --git a/packages/server/src/utils/notifications/utils.ts b/packages/server/src/utils/notifications/utils.ts index ec1c020ad..539376ac5 100644 --- a/packages/server/src/utils/notifications/utils.ts +++ b/packages/server/src/utils/notifications/utils.ts @@ -2,6 +2,7 @@ import type { discord, email, gotify, + lark, ntfy, slack, telegram, @@ -33,9 +34,13 @@ export const sendEmailNotification = async ( to: toAddresses.join(", "), subject, html: htmlContent, + textEncoding: "base64", }); } catch (err) { console.log(err); + throw new Error( + `Failed to send email notification ${err instanceof Error ? err.message : "Unknown error"}`, + ); } }; @@ -43,15 +48,23 @@ export const sendDiscordNotification = async ( connection: typeof discord.$inferInsert, embed: any, ) => { - // try { - await fetch(connection.webhookUrl, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ embeds: [embed] }), - }); - // } catch (err) { - // console.log(err); - // } + try { + const response = await fetch(connection.webhookUrl, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ embeds: [embed] }), + }); + if (!response.ok) { + throw new Error( + `Failed to send discord notification ${response.statusText}`, + ); + } + } catch (err) { + console.log("error", err); + throw new Error( + `Failed to send discord notification ${err instanceof Error ? err.message : "Unknown error"}`, + ); + } }; export const sendTelegramNotification = async ( @@ -88,13 +101,21 @@ export const sendSlackNotification = async ( message: any, ) => { try { - await fetch(connection.webhookUrl, { + const response = await fetch(connection.webhookUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(message), }); + if (!response.ok) { + throw new Error( + `Failed to send slack notification ${response.statusText}`, + ); + } } catch (err) { - console.log(err); + console.log("error", err); + throw new Error( + `Failed to send slack notification ${err instanceof Error ? err.message : "Unknown error"}`, + ); } }; @@ -151,3 +172,18 @@ export const sendNtfyNotification = async ( throw new Error(`Failed to send ntfy notification: ${response.statusText}`); } }; + +export const sendLarkNotification = async ( + connection: typeof lark.$inferInsert, + message: any, +) => { + try { + await fetch(connection.webhookUrl, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(message), + }); + } catch (err) { + console.log(err); + } +}; diff --git a/packages/server/src/utils/process/ExecError.ts b/packages/server/src/utils/process/ExecError.ts new file mode 100644 index 000000000..773968b5c --- /dev/null +++ b/packages/server/src/utils/process/ExecError.ts @@ -0,0 +1,55 @@ +export interface ExecErrorDetails { + command: string; + stdout?: string; + stderr?: string; + exitCode?: number; + originalError?: Error; + serverId?: string | null; +} + +export class ExecError extends Error { + public readonly command: string; + public readonly stdout?: string; + public readonly stderr?: string; + public readonly exitCode?: number; + public readonly originalError?: Error; + public readonly serverId?: string | null; + + constructor(message: string, details: ExecErrorDetails) { + super(message); + this.name = "ExecError"; + this.command = details.command; + this.stdout = details.stdout; + this.stderr = details.stderr; + this.exitCode = details.exitCode; + this.originalError = details.originalError; + this.serverId = details.serverId; + + // Maintains proper stack trace for where our error was thrown (only available on V8) + if (Error.captureStackTrace) { + Error.captureStackTrace(this, ExecError); + } + } + + /** + * Get a formatted error message with all details + */ + getDetailedMessage(): string { + const parts = [ + `Command: ${this.command}`, + this.exitCode !== undefined ? `Exit Code: ${this.exitCode}` : null, + this.serverId ? `Server ID: ${this.serverId}` : "Location: Local", + this.stderr ? `Stderr: ${this.stderr}` : null, + this.stdout ? `Stdout: ${this.stdout}` : null, + ].filter(Boolean); + + return `${this.message}\n${parts.join("\n")}`; + } + + /** + * Check if this error is from a remote execution + */ + isRemote(): boolean { + return !!this.serverId; + } +} diff --git a/packages/server/src/utils/process/execAsync.ts b/packages/server/src/utils/process/execAsync.ts index 84f0701d9..cd0249000 100644 --- a/packages/server/src/utils/process/execAsync.ts +++ b/packages/server/src/utils/process/execAsync.ts @@ -2,8 +2,43 @@ import { exec, execFile } from "node:child_process"; import util from "node:util"; import { findServerById } from "@dokploy/server/services/server"; import { Client } from "ssh2"; +import { ExecError } from "./ExecError"; -export const execAsync = util.promisify(exec); +// Re-export ExecError for easier imports +export { ExecError } from "./ExecError"; + +const execAsyncBase = util.promisify(exec); + +export const execAsync = async ( + command: string, + options?: { cwd?: string; env?: NodeJS.ProcessEnv; shell?: string }, +): Promise<{ stdout: string; stderr: string }> => { + try { + const result = await execAsyncBase(command, options); + return { + stdout: result.stdout.toString(), + stderr: result.stderr.toString(), + }; + } catch (error) { + if (error instanceof Error) { + // @ts-ignore - exec error has these properties + const exitCode = error.code; + // @ts-ignore + const stdout = error.stdout?.toString() || ""; + // @ts-ignore + const stderr = error.stderr?.toString() || ""; + + throw new ExecError(`Command execution failed: ${error.message}`, { + command, + stdout, + stderr, + exitCode, + originalError: error, + }); + } + throw error; + } +}; interface ExecOptions { cwd?: string; @@ -21,7 +56,16 @@ export const execAsyncStream = ( const childProcess = exec(command, options, (error) => { if (error) { - reject(error); + reject( + new ExecError(`Command execution failed: ${error.message}`, { + command, + stdout: stdoutComplete, + stderr: stderrComplete, + // @ts-ignore + exitCode: error.code, + originalError: error, + }), + ); return; } resolve({ stdout: stdoutComplete, stderr: stderrComplete }); @@ -45,7 +89,14 @@ export const execAsyncStream = ( childProcess.on("error", (error) => { console.log(error); - reject(error); + reject( + new ExecError(`Command execution error: ${error.message}`, { + command, + stdout: stdoutComplete, + stderr: stderrComplete, + originalError: error, + }), + ); }); }); }; @@ -108,7 +159,14 @@ export const execAsyncRemote = async ( conn.exec(command, (err, stream) => { if (err) { onData?.(err.message); - throw err; + reject( + new ExecError(`Remote command execution failed: ${err.message}`, { + command, + serverId, + originalError: err, + }), + ); + return; } stream .on("close", (code: number, _signal: string) => { @@ -117,8 +175,15 @@ export const execAsyncRemote = async ( resolve({ stdout, stderr }); } else { reject( - new Error( - `Command exited with code ${code}. Stderr: ${stderr}, command: ${command}`, + new ExecError( + `Remote command failed with exit code ${code}`, + { + command, + stdout, + stderr, + exitCode: code, + serverId, + }, ), ); } @@ -136,17 +201,25 @@ export const execAsyncRemote = async ( .on("error", (err) => { conn.end(); if (err.level === "client-authentication") { - onData?.( - `Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`, - ); + const errorMsg = `Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`; + onData?.(errorMsg); reject( - new Error( - `Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`, - ), + new ExecError(errorMsg, { + command, + serverId, + originalError: err, + }), ); } else { - onData?.(`SSH connection error: ${err.message}`); - reject(new Error(`SSH connection error: ${err.message}`)); + const errorMsg = `SSH connection error: ${err.message}`; + onData?.(errorMsg); + reject( + new ExecError(errorMsg, { + command, + serverId, + originalError: err, + }), + ); } }) .connect({ diff --git a/packages/server/src/utils/providers/bitbucket.ts b/packages/server/src/utils/providers/bitbucket.ts index ed6cd8c31..2248baaaf 100644 --- a/packages/server/src/utils/providers/bitbucket.ts +++ b/packages/server/src/utils/providers/bitbucket.ts @@ -1,4 +1,3 @@ -import { createWriteStream } from "node:fs"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { @@ -9,12 +8,8 @@ import { type Bitbucket, findBitbucketById, } from "@dokploy/server/services/bitbucket"; -import type { Compose } from "@dokploy/server/services/compose"; import type { InferResultType } from "@dokploy/server/types/with"; import { TRPCError } from "@trpc/server"; -import { recreateDirectory } from "../filesystem/directory"; -import { execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; export type ApplicationWithBitbucket = InferResultType< "applications", @@ -81,202 +76,52 @@ export const getBitbucketHeaders = (bitbucketProvider: Bitbucket) => { }; }; -export const cloneBitbucketRepository = async ( - entity: ApplicationWithBitbucket | ComposeWithBitbucket, - logPath: string, - isCompose = false, -) => { - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(); - const writeStream = createWriteStream(logPath, { flags: "a" }); +interface CloneBitbucketRepository { + appName: string; + bitbucketRepository: string | null; + bitbucketOwner: string | null; + bitbucketBranch: string | null; + bitbucketId: string | null; + enableSubmodules: boolean; + serverId: string | null; + type?: "application" | "compose"; +} + +export const cloneBitbucketRepository = async ({ + type = "application", + ...entity +}: CloneBitbucketRepository) => { + let command = "set -e;"; const { appName, bitbucketRepository, bitbucketOwner, bitbucketBranch, bitbucketId, - bitbucket, enableSubmodules, + serverId, } = entity; + const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(!!serverId); if (!bitbucketId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Bitbucket Provider not found", - }); + command += `echo "Error: ❌ Bitbucket Provider not found"; exit 1;`; + return command; } + const bitbucket = await findBitbucketById(bitbucketId); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; + if (!bitbucket) { + command += `echo "Error: ❌ Bitbucket Provider not found"; exit 1;`; + return command; + } + const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); + command += `rm -rf ${outputPath};`; + command += `mkdir -p ${outputPath};`; const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`; const cloneUrl = getBitbucketCloneUrl(bitbucket, repoclone); - try { - writeStream.write(`\nCloning Repo ${repoclone} to ${outputPath}: ✅\n`); - const cloneArgs = [ - "clone", - "--branch", - bitbucketBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; - - await spawnAsync("git", cloneArgs, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - writeStream.write(`\nCloned ${repoclone} to ${outputPath}: ✅\n`); - } catch (error) { - writeStream.write(`ERROR Cloning: ${error}: ❌`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const cloneRawBitbucketRepository = async (entity: Compose) => { - const { COMPOSE_PATH } = paths(); - const { - appName, - bitbucketRepository, - bitbucketOwner, - bitbucketBranch, - bitbucketId, - enableSubmodules, - } = entity; - - if (!bitbucketId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Bitbucket Provider not found", - }); - } - - const bitbucketProvider = await findBitbucketById(bitbucketId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); - const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`; - const cloneUrl = getBitbucketCloneUrl(bitbucketProvider, repoclone); - - try { - const cloneArgs = [ - "clone", - "--branch", - bitbucketBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; - - await spawnAsync("git", cloneArgs); - } catch (error) { - throw error; - } -}; - -export const cloneRawBitbucketRepositoryRemote = async (compose: Compose) => { - const { COMPOSE_PATH } = paths(true); - const { - appName, - bitbucketRepository, - bitbucketOwner, - bitbucketBranch, - bitbucketId, - serverId, - enableSubmodules, - } = compose; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - if (!bitbucketId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Bitbucket Provider not found", - }); - } - - const bitbucketProvider = await findBitbucketById(bitbucketId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`; - const cloneUrl = getBitbucketCloneUrl(bitbucketProvider, repoclone); - - try { - const cloneCommand = ` - rm -rf ${outputPath}; - git clone --branch ${bitbucketBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} - `; - await execAsyncRemote(serverId, cloneCommand); - } catch (error) { - throw error; - } -}; - -export const getBitbucketCloneCommand = async ( - entity: ApplicationWithBitbucket | ComposeWithBitbucket, - logPath: string, - isCompose = false, -) => { - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(true); - const { - appName, - bitbucketRepository, - bitbucketOwner, - bitbucketBranch, - bitbucketId, - serverId, - enableSubmodules, - } = entity; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - - if (!bitbucketId) { - const command = ` - echo "Error: ❌ Bitbucket Provider not found" >> ${logPath}; - exit 1; - `; - await execAsyncRemote(serverId, command); - throw new TRPCError({ - code: "NOT_FOUND", - message: "Bitbucket Provider not found", - }); - } - - const bitbucketProvider = await findBitbucketById(bitbucketId); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; - const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); - const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`; - const cloneUrl = getBitbucketCloneUrl(bitbucketProvider, repoclone); - - const cloneCommand = ` -rm -rf ${outputPath}; -mkdir -p ${outputPath}; -if ! git clone --branch ${bitbucketBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${cloneUrl} ${outputPath} >> ${logPath} 2>&1; then - echo "❌ [ERROR] Fail to clone the repository ${repoclone}" >> ${logPath}; - exit 1; -fi -echo "Cloned ${repoclone} to ${outputPath}: ✅" >> ${logPath}; - `; - - return cloneCommand; + command += `echo "Cloning Repo ${repoclone} to ${outputPath}: ✅";`; + command += `git clone --branch ${bitbucketBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`; + return command; }; export const getBitbucketRepositories = async (bitbucketId?: string) => { diff --git a/packages/server/src/utils/providers/docker.ts b/packages/server/src/utils/providers/docker.ts index 56341b7d6..06f962dc7 100644 --- a/packages/server/src/utils/providers/docker.ts +++ b/packages/server/src/utils/providers/docker.ts @@ -1,60 +1,6 @@ -import { createWriteStream } from "node:fs"; -import { type ApplicationNested, mechanizeDockerContainer } from "../builders"; -import { pullImage } from "../docker/utils"; +import type { ApplicationNested } from "../builders"; -interface RegistryAuth { - username: string; - password: string; - registryUrl: string; -} - -export const buildDocker = async ( - application: ApplicationNested, - logPath: string, -): Promise => { - const { buildType, dockerImage, username, password } = application; - const authConfig: Partial = { - username: username || "", - password: password || "", - registryUrl: application.registryUrl || "", - }; - - const writeStream = createWriteStream(logPath, { flags: "a" }); - - writeStream.write(`\nBuild ${buildType}\n`); - - writeStream.write(`Pulling ${dockerImage}: ✅\n`); - - try { - if (!dockerImage) { - throw new Error("Docker image not found"); - } - - await pullImage( - dockerImage, - (data) => { - if (writeStream.writable) { - writeStream.write(`${data}\n`); - } - }, - authConfig, - ); - await mechanizeDockerContainer(application); - writeStream.write("\nDocker Deployed: ✅\n"); - } catch (error) { - writeStream.write( - `❌ Error: ${error instanceof Error ? error.message : String(error)}`, - ); - throw error; - } finally { - writeStream.end(); - } -}; - -export const buildRemoteDocker = async ( - application: ApplicationNested, - logPath: string, -) => { +export const buildRemoteDocker = async (application: ApplicationNested) => { const { registryUrl, dockerImage, username, password } = application; try { @@ -62,25 +8,25 @@ export const buildRemoteDocker = async ( throw new Error("Docker image not found"); } let command = ` -echo "Pulling ${dockerImage}" >> ${logPath}; +echo "Pulling ${dockerImage}"; `; if (username && password) { command += ` -if ! echo "${password}" | docker login --username "${username}" --password-stdin "${registryUrl || ""}" >> ${logPath} 2>&1; then - echo "❌ Login failed" >> ${logPath}; +if ! echo "${password}" | docker login --username "${username}" --password-stdin "${registryUrl || ""}" 2>&1; then + echo "❌ Login failed"; exit 1; fi `; } command += ` -docker pull ${dockerImage} >> ${logPath} 2>> ${logPath} || { - echo "❌ Pulling image failed" >> ${logPath}; +docker pull ${dockerImage} 2>&1 || { + echo "❌ Pulling image failed"; exit 1; } -echo "✅ Pulling image completed." >> ${logPath}; +echo "✅ Pulling image completed."; `; return command; } catch (error) { diff --git a/packages/server/src/utils/providers/git.ts b/packages/server/src/utils/providers/git.ts index 5779252db..8e640892d 100644 --- a/packages/server/src/utils/providers/git.ts +++ b/packages/server/src/utils/providers/git.ts @@ -1,159 +1,65 @@ -import { createWriteStream } from "node:fs"; import path, { join } from "node:path"; import { paths } from "@dokploy/server/constants"; -import type { Compose } from "@dokploy/server/services/compose"; import { findSSHKeyById, updateSSHKeyById, } from "@dokploy/server/services/ssh-key"; -import { TRPCError } from "@trpc/server"; -import { recreateDirectory } from "../filesystem/directory"; import { execAsync, execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; -export const cloneGitRepository = async ( - entity: { - appName: string; - customGitUrl?: string | null; - customGitBranch?: string | null; - customGitSSHKeyId?: string | null; - enableSubmodules?: boolean; - }, - logPath: string, - isCompose = false, -) => { - const { SSH_PATH, COMPOSE_PATH, APPLICATIONS_PATH } = paths(); +interface CloneGitRepository { + appName: string; + customGitUrl?: string | null; + customGitBranch?: string | null; + customGitSSHKeyId?: string | null; + enableSubmodules?: boolean; + serverId: string | null; + type?: "application" | "compose"; +} + +export const cloneGitRepository = async ({ + type = "application", + ...entity +}: CloneGitRepository) => { + let command = "set -e;"; const { appName, customGitUrl, customGitBranch, customGitSSHKeyId, enableSubmodules, + serverId, } = entity; + const { SSH_PATH, COMPOSE_PATH, APPLICATIONS_PATH } = paths(!!serverId); if (!customGitUrl || !customGitBranch) { - throw new TRPCError({ - code: "BAD_REQUEST", - message: "Error: Repository not found", - }); + command += `echo "Error: ❌ Repository not found"; exit 1;`; + return command; } - const writeStream = createWriteStream(logPath, { flags: "a" }); const temporalKeyPath = path.join("/tmp", "id_rsa"); if (customGitSSHKeyId) { const sshKey = await findSSHKeyById(customGitSSHKeyId); - await execAsync(` + command += ` echo "${sshKey.privateKey}" > ${temporalKeyPath} - chmod 600 ${temporalKeyPath} - `); + chmod 600 ${temporalKeyPath}; + `; } - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; + const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); const knownHostsPath = path.join(SSH_PATH, "known_hosts"); - try { - if (!isHttpOrHttps(customGitUrl)) { - if (!customGitSSHKeyId) { - throw new TRPCError({ - code: "BAD_REQUEST", - message: - "Error: you are trying to clone a ssh repository without a ssh key, please set a ssh key", - }); - } - await addHostToKnownHosts(customGitUrl); + if (!isHttpOrHttps(customGitUrl)) { + if (!customGitSSHKeyId) { + command += `echo "Error: ❌ You are trying to clone a ssh repository without a ssh key, please set a ssh key"; exit 1;`; + return command; } - await recreateDirectory(outputPath); - writeStream.write( - `\nCloning Repo Custom ${customGitUrl} to ${outputPath}: ✅\n`, - ); - - if (customGitSSHKeyId) { - await updateSSHKeyById({ - sshKeyId: customGitSSHKeyId, - lastUsedAt: new Date().toISOString(), - }); - } - - const { port } = sanitizeRepoPathSSH(customGitUrl); - const cloneArgs = [ - "clone", - "--branch", - customGitBranch, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - customGitUrl, - outputPath, - "--progress", - ]; - - await spawnAsync( - "git", - cloneArgs, - (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }, - { - env: { - ...process.env, - ...(customGitSSHKeyId && { - GIT_SSH_COMMAND: `ssh -i ${temporalKeyPath}${port ? ` -p ${port}` : ""} -o UserKnownHostsFile=${knownHostsPath}`, - }), - }, - }, - ); - - writeStream.write(`\nCloned Custom Git ${customGitUrl}: ✅\n`); - } catch (error) { - writeStream.write(`\nERROR Cloning Custom Git: ${error}: ❌\n`); - throw error; - } finally { - writeStream.end(); + command += addHostToKnownHostsCommand(customGitUrl); } -}; - -export const getCustomGitCloneCommand = async ( - entity: { - appName: string; - customGitUrl?: string | null; - customGitBranch?: string | null; - customGitSSHKeyId?: string | null; - serverId: string | null; - enableSubmodules: boolean; - }, - logPath: string, - isCompose = false, -) => { - const { SSH_PATH, COMPOSE_PATH, APPLICATIONS_PATH } = paths(true); - const { - appName, - customGitUrl, - customGitBranch, - customGitSSHKeyId, - serverId, - enableSubmodules, - } = entity; - - if (!customGitUrl || !customGitBranch) { - const command = ` - echo "Error: ❌ Repository not found" >> ${logPath}; - exit 1; - `; - - await execAsyncRemote(serverId, command); - throw new TRPCError({ - code: "BAD_REQUEST", - message: "Error: Repository not found", - }); - } - - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; - const outputPath = join(basePath, appName, "code"); - const knownHostsPath = path.join(SSH_PATH, "known_hosts"); + command += `rm -rf ${outputPath};`; + command += `mkdir -p ${outputPath};`; + command += `echo "Cloning Repo Custom ${customGitUrl} to ${outputPath}: ✅";`; if (customGitSSHKeyId) { await updateSSHKeyById({ @@ -161,48 +67,22 @@ export const getCustomGitCloneCommand = async ( lastUsedAt: new Date().toISOString(), }); } - try { - const command = []; - if (!isHttpOrHttps(customGitUrl)) { - if (!customGitSSHKeyId) { - command.push( - `echo "Error: you are trying to clone a ssh repository without a ssh key, please set a ssh key ❌" >> ${logPath}; - exit 1; - `, - ); - } - command.push(addHostToKnownHostsCommand(customGitUrl)); - } - command.push(`rm -rf ${outputPath};`); - command.push(`mkdir -p ${outputPath};`); - command.push( - `echo "Cloning Custom Git ${customGitUrl}" to ${outputPath}: ✅ >> ${logPath};`, - ); - if (customGitSSHKeyId) { - const sshKey = await findSSHKeyById(customGitSSHKeyId); - const { port } = sanitizeRepoPathSSH(customGitUrl); - const gitSshCommand = `ssh -i /tmp/id_rsa${port ? ` -p ${port}` : ""} -o UserKnownHostsFile=${knownHostsPath}`; - command.push( - ` - echo "${sshKey.privateKey}" > /tmp/id_rsa - chmod 600 /tmp/id_rsa - export GIT_SSH_COMMAND="${gitSshCommand}" - `, - ); - } - command.push( - `if ! git clone --branch ${customGitBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${customGitUrl} ${outputPath} >> ${logPath} 2>&1; then - echo "❌ [ERROR] Fail to clone the repository ${customGitUrl}" >> ${logPath}; + if (customGitSSHKeyId) { + const sshKey = await findSSHKeyById(customGitSSHKeyId); + const { port } = sanitizeRepoPathSSH(customGitUrl); + const gitSshCommand = `ssh -i /tmp/id_rsa${port ? ` -p ${port}` : ""} -o UserKnownHostsFile=${knownHostsPath}`; + command += `echo "${sshKey.privateKey}" > /tmp/id_rsa;`; + command += "chmod 600 /tmp/id_rsa;"; + command += `export GIT_SSH_COMMAND="${gitSshCommand}";`; + } + command += `if ! git clone --branch ${customGitBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${customGitUrl} ${outputPath}; then + echo "❌ [ERROR] Fail to clone the repository ${customGitUrl}"; exit 1; fi - `, - ); - command.push(`echo "Cloned Custom Git ${customGitUrl}: ✅" >> ${logPath};`); - return command.join("\n"); - } catch (error) { - throw error; - } + `; + + return command; }; const isHttpOrHttps = (url: string): boolean => { @@ -210,19 +90,19 @@ const isHttpOrHttps = (url: string): boolean => { return regex.test(url); }; -const addHostToKnownHosts = async (repositoryURL: string) => { - const { SSH_PATH } = paths(); - const { domain, port } = sanitizeRepoPathSSH(repositoryURL); - const knownHostsPath = path.join(SSH_PATH, "known_hosts"); +// const addHostToKnownHosts = async (repositoryURL: string) => { +// const { SSH_PATH } = paths(); +// const { domain, port } = sanitizeRepoPathSSH(repositoryURL); +// const knownHostsPath = path.join(SSH_PATH, "known_hosts"); - const command = `ssh-keyscan -p ${port} ${domain} >> ${knownHostsPath}`; - try { - await execAsync(command); - } catch (error) { - console.error(`Error adding host to known_hosts: ${error}`); - throw error; - } -}; +// const command = `ssh-keyscan -p ${port} ${domain} >> ${knownHostsPath}`; +// try { +// await execAsync(command); +// } catch (error) { +// console.error(`Error adding host to known_hosts: ${error}`); +// throw error; +// } +// }; const addHostToKnownHostsCommand = (repositoryURL: string) => { const { SSH_PATH } = paths(true); @@ -267,160 +147,43 @@ const sanitizeRepoPathSSH = (input: string) => { }; }; -export const cloneGitRawRepository = async (entity: { +interface Props { appName: string; - customGitUrl?: string | null; - customGitBranch?: string | null; - customGitSSHKeyId?: string | null; - enableSubmodules?: boolean; -}) => { - const { - appName, - customGitUrl, - customGitBranch, - customGitSSHKeyId, - enableSubmodules, - } = entity; + type?: "application" | "compose"; + serverId: string | null; +} - if (!customGitUrl || !customGitBranch) { - throw new TRPCError({ - code: "BAD_REQUEST", - message: "Error: Repository not found", - }); - } - - const { SSH_PATH, COMPOSE_PATH } = paths(); - const temporalKeyPath = path.join("/tmp", "id_rsa"); - const basePath = COMPOSE_PATH; +export const getGitCommitInfo = async ({ + appName, + type = "application", + serverId, +}: Props) => { + const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(!!serverId); + const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); - const knownHostsPath = path.join(SSH_PATH, "known_hosts"); - - if (customGitSSHKeyId) { - const sshKey = await findSSHKeyById(customGitSSHKeyId); - - await execAsync(` - echo "${sshKey.privateKey}" > ${temporalKeyPath} - chmod 600 ${temporalKeyPath} - `); - } - + let stdoutResult = ""; + const result = { + message: "", + hash: "", + }; try { - if (!isHttpOrHttps(customGitUrl)) { - if (!customGitSSHKeyId) { - throw new TRPCError({ - code: "BAD_REQUEST", - message: - "Error: you are trying to clone a ssh repository without a ssh key, please set a ssh key", - }); - } - await addHostToKnownHosts(customGitUrl); - } - await recreateDirectory(outputPath); - - if (customGitSSHKeyId) { - await updateSSHKeyById({ - sshKeyId: customGitSSHKeyId, - lastUsedAt: new Date().toISOString(), - }); + const gitCommand = `git -C ${outputPath} log -1 --pretty=format:"%H---DELIMITER---%B"`; + if (serverId) { + const { stdout } = await execAsyncRemote(serverId, gitCommand); + stdoutResult = stdout.trim(); + } else { + const { stdout } = await execAsync(gitCommand); + stdoutResult = stdout.trim(); } - const { port } = sanitizeRepoPathSSH(customGitUrl); - const cloneArgs = [ - "clone", - "--branch", - customGitBranch, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - customGitUrl, - outputPath, - "--progress", - ]; - - await spawnAsync("git", cloneArgs, (_data) => {}, { - env: { - ...process.env, - ...(customGitSSHKeyId && { - GIT_SSH_COMMAND: `ssh -i ${temporalKeyPath}${port ? ` -p ${port}` : ""} -o UserKnownHostsFile=${knownHostsPath}`, - }), - }, - }); + const parts = stdoutResult.split("---DELIMITER---"); + if (parts && parts.length === 2) { + result.hash = parts[0]?.trim() || ""; + result.message = parts[1]?.trim() || ""; + } } catch (error) { - throw error; - } -}; - -export const cloneRawGitRepositoryRemote = async (compose: Compose) => { - const { - appName, - customGitBranch, - customGitUrl, - customGitSSHKeyId, - serverId, - enableSubmodules, - } = compose; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - if (!customGitUrl) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Git Provider not found", - }); - } - - const { SSH_PATH, COMPOSE_PATH } = paths(true); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const knownHostsPath = path.join(SSH_PATH, "known_hosts"); - - if (customGitSSHKeyId) { - await updateSSHKeyById({ - sshKeyId: customGitSSHKeyId, - lastUsedAt: new Date().toISOString(), - }); - } - try { - const command = []; - if (!isHttpOrHttps(customGitUrl)) { - if (!customGitSSHKeyId) { - command.push( - `echo "Error: you are trying to clone a ssh repository without a ssh key, please set a ssh key ❌" ; - exit 1; - `, - ); - } - command.push(addHostToKnownHostsCommand(customGitUrl)); - } - command.push(`rm -rf ${outputPath};`); - command.push(`mkdir -p ${outputPath};`); - if (customGitSSHKeyId) { - const sshKey = await findSSHKeyById(customGitSSHKeyId); - const { port } = sanitizeRepoPathSSH(customGitUrl); - const gitSshCommand = `ssh -i /tmp/id_rsa${port ? ` -p ${port}` : ""} -o UserKnownHostsFile=${knownHostsPath}`; - command.push( - ` - echo "${sshKey.privateKey}" > /tmp/id_rsa - chmod 600 /tmp/id_rsa - export GIT_SSH_COMMAND="${gitSshCommand}" - `, - ); - } - - command.push( - `if ! git clone --branch ${customGitBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${customGitUrl} ${outputPath} ; then - echo "[ERROR] Fail to clone the repository "; - exit 1; - fi - `, - ); - - await execAsyncRemote(serverId, command.join("\n")); - } catch (error) { - throw error; + console.error(`Error getting git commit info: ${error}`); + return null; } + return result; }; diff --git a/packages/server/src/utils/providers/gitea.ts b/packages/server/src/utils/providers/gitea.ts index db6dcbb78..ec8946ab3 100644 --- a/packages/server/src/utils/providers/gitea.ts +++ b/packages/server/src/utils/providers/gitea.ts @@ -1,7 +1,5 @@ -import { createWriteStream } from "node:fs"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; -import type { Compose } from "@dokploy/server/services/compose"; import { findGiteaById, type Gitea, @@ -9,9 +7,6 @@ import { } from "@dokploy/server/services/gitea"; import type { InferResultType } from "@dokploy/server/types/with"; import { TRPCError } from "@trpc/server"; -import { recreateDirectory } from "../filesystem/directory"; -import { execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; export const getErrorCloneRequirements = (entity: { giteaRepository?: string | null; @@ -119,79 +114,27 @@ export type ApplicationWithGitea = InferResultType< export type ComposeWithGitea = InferResultType<"compose", { gitea: true }>; -export const getGiteaCloneCommand = async ( - entity: ApplicationWithGitea | ComposeWithGitea, - logPath: string, - isCompose = false, -) => { - const { - appName, - giteaBranch, - giteaId, - giteaOwner, - giteaRepository, - serverId, - enableSubmodules, - } = entity; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - - if (!giteaId) { - const command = ` - echo "Error: ❌ Gitlab Provider not found" >> ${logPath}; - exit 1; - `; - - await execAsyncRemote(serverId, command); - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea Provider not found", - }); - } - - // Use paths(true) for remote operations - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(true); - await refreshGiteaToken(giteaId); - const gitea = await findGiteaById(giteaId); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; - const outputPath = join(basePath, appName, "code"); - - const repoClone = `${giteaOwner}/${giteaRepository}.git`; - const cloneUrl = buildGiteaCloneUrl( - gitea?.giteaUrl!, - gitea?.accessToken!, - giteaOwner!, - giteaRepository!, - ); - - const cloneCommand = ` - rm -rf ${outputPath}; - mkdir -p ${outputPath}; - - if ! git clone --branch ${giteaBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} >> ${logPath} 2>&1; then - echo "❌ [ERROR] Failed to clone the repository ${repoClone}" >> ${logPath}; - exit 1; - fi - - echo "Cloned ${repoClone} to ${outputPath}: ✅" >> ${logPath}; - `; - - return cloneCommand; +type GiteaClone = (ApplicationWithGitea | ComposeWithGitea) & { + serverId: string | null; + type?: "application" | "compose"; }; -export const cloneGiteaRepository = async ( - entity: ApplicationWithGitea | ComposeWithGitea, - logPath: string, - isCompose = false, -) => { - const { APPLICATIONS_PATH, COMPOSE_PATH } = paths(); +interface CloneGiteaRepository { + appName: string; + giteaBranch: string | null; + giteaId: string | null; + giteaOwner: string | null; + giteaRepository: string | null; + enableSubmodules: boolean; + serverId: string | null; + type?: "application" | "compose"; +} - const writeStream = createWriteStream(logPath, { flags: "a" }); +export const cloneGiteaRepository = async ({ + type = "application", + ...entity +}: CloneGiteaRepository) => { + let command = "set -e;"; const { appName, giteaBranch, @@ -199,27 +142,27 @@ export const cloneGiteaRepository = async ( giteaOwner, giteaRepository, enableSubmodules, + serverId, } = entity; + const { APPLICATIONS_PATH, COMPOSE_PATH } = paths(!!serverId); if (!giteaId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea Provider not found", - }); + command += `echo "Error: ❌ Gitea Provider not found"; exit 1;`; + return command; } await refreshGiteaToken(giteaId); const giteaProvider = await findGiteaById(giteaId); + if (!giteaProvider) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea provider not found in the database", - }); + command += `echo "❌ [ERROR] Gitea provider not found in the database"; exit 1;`; + return command; } - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; + const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); + command += `rm -rf ${outputPath};`; + command += `mkdir -p ${outputPath};`; const repoClone = `${giteaOwner}/${giteaRepository}.git`; const cloneUrl = buildGiteaCloneUrl( @@ -229,134 +172,9 @@ export const cloneGiteaRepository = async ( giteaRepository!, ); - writeStream.write(`\nCloning Repo ${repoClone} to ${outputPath}...\n`); - - try { - await spawnAsync( - "git", - [ - "clone", - "--branch", - giteaBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ], - (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }, - ); - writeStream.write(`\nCloned ${repoClone}: ✅\n`); - } catch (error) { - writeStream.write(`ERROR Cloning: ${error}: ❌`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const cloneRawGiteaRepository = async (entity: Compose) => { - const { - appName, - giteaRepository, - giteaOwner, - giteaBranch, - giteaId, - enableSubmodules, - } = entity; - const { COMPOSE_PATH } = paths(); - - if (!giteaId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea Provider not found", - }); - } - await refreshGiteaToken(giteaId); - const giteaProvider = await findGiteaById(giteaId); - if (!giteaProvider) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea provider not found in the database", - }); - } - - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); - - const cloneUrl = buildGiteaCloneUrl( - giteaProvider.giteaUrl, - giteaProvider.accessToken!, - giteaOwner!, - giteaRepository!, - ); - - try { - await spawnAsync("git", [ - "clone", - "--branch", - giteaBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]); - } catch (error) { - throw error; - } -}; - -export const cloneRawGiteaRepositoryRemote = async (compose: Compose) => { - const { - appName, - giteaRepository, - giteaOwner, - giteaBranch, - giteaId, - serverId, - enableSubmodules, - } = compose; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - if (!giteaId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitea Provider not found", - }); - } - const { COMPOSE_PATH } = paths(true); - const giteaProvider = await findGiteaById(giteaId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const cloneUrl = buildGiteaCloneUrl( - giteaProvider.giteaUrl, - giteaProvider.accessToken!, - giteaOwner!, - giteaRepository!, - ); - - try { - const command = ` - rm -rf ${outputPath}; - git clone --branch ${giteaBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} - `; - await execAsyncRemote(serverId, command); - } catch (error) { - throw error; - } + command += `echo "Cloning Repo ${repoClone} to ${outputPath}: ✅";`; + command += `git clone --branch ${giteaBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`; + return command; }; export const haveGiteaRequirements = (giteaProvider: Gitea) => { diff --git a/packages/server/src/utils/providers/github.ts b/packages/server/src/utils/providers/github.ts index 30125db8b..5b7763df7 100644 --- a/packages/server/src/utils/providers/github.ts +++ b/packages/server/src/utils/providers/github.ts @@ -1,16 +1,11 @@ -import { createWriteStream } from "node:fs"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { apiFindGithubBranches } from "@dokploy/server/db/schema"; -import type { Compose } from "@dokploy/server/services/compose"; import { findGithubById, type Github } from "@dokploy/server/services/github"; import type { InferResultType } from "@dokploy/server/types/with"; import { createAppAuth } from "@octokit/auth-app"; import { TRPCError } from "@trpc/server"; import { Octokit } from "octokit"; -import { recreateDirectory } from "../filesystem/directory"; -import { execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; export const authGithub = (githubProvider: Github): Octokit => { if (!haveGithubRequirements(githubProvider)) { @@ -123,42 +118,39 @@ interface CloneGithubRepository { branch: string | null; githubId: string | null; repository: string | null; - logPath: string; type?: "application" | "compose"; enableSubmodules: boolean; + serverId: string | null; } export const cloneGithubRepository = async ({ - logPath, type = "application", ...entity }: CloneGithubRepository) => { + let command = "set -e;"; const isCompose = type === "compose"; - const { APPLICATIONS_PATH, COMPOSE_PATH } = paths(); - const writeStream = createWriteStream(logPath, { flags: "a" }); - const { appName, repository, owner, branch, githubId, enableSubmodules } = - entity; + const { + appName, + repository, + owner, + branch, + githubId, + enableSubmodules, + serverId, + } = entity; + const { APPLICATIONS_PATH, COMPOSE_PATH } = paths(!!serverId); if (!githubId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "GitHub Provider not found", - }); + command += `echo "Error: ❌ Github Provider not found"; exit 1;`; + + return command; } const requirements = getErrorCloneRequirements(entity); // Check if requirements are met if (requirements.length > 0) { - writeStream.write( - `\nGitHub Repository configuration failed for application: ${appName}\n`, - ); - writeStream.write("Reasons:\n"); - writeStream.write(requirements.join("\n")); - writeStream.end(); - throw new TRPCError({ - code: "BAD_REQUEST", - message: "Error: GitHub repository information is incomplete.", - }); + command += `echo "GitHub Repository configuration failed for application: ${appName}"; echo "Reasons:"; echo "${requirements.join("\n")}"; exit 1;`; + return command; } const githubProvider = await findGithubById(githubId); @@ -167,193 +159,14 @@ export const cloneGithubRepository = async ({ const octokit = authGithub(githubProvider); const token = await getGithubToken(octokit); const repoclone = `github.com/${owner}/${repository}.git`; - await recreateDirectory(outputPath); + command += `rm -rf ${outputPath};`; + command += `mkdir -p ${outputPath};`; const cloneUrl = `https://oauth2:${token}@${repoclone}`; - try { - writeStream.write(`\nCloning Repo ${repoclone} to ${outputPath}: ✅\n`); - const cloneArgs = [ - "clone", - "--branch", - branch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; + command += `echo "Cloning Repo ${repoclone} to ${outputPath}: ✅";`; + command += `git clone --branch ${branch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`; - await spawnAsync("git", cloneArgs, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - writeStream.write(`\nCloned ${repoclone}: ✅\n`); - } catch (error) { - writeStream.write(`ERROR Cloning: ${error}: ❌`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const getGithubCloneCommand = async ({ - logPath, - type = "application", - ...entity -}: CloneGithubRepository & { serverId: string }) => { - const { - appName, - repository, - owner, - branch, - githubId, - serverId, - enableSubmodules, - } = entity; - const isCompose = type === "compose"; - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - - if (!githubId) { - const command = ` - echo "Error: ❌ Github Provider not found" >> ${logPath}; - exit 1; - `; - - await execAsyncRemote(serverId, command); - throw new TRPCError({ - code: "NOT_FOUND", - message: "GitHub Provider not found", - }); - } - - const requirements = getErrorCloneRequirements(entity); - - // Build log messages - let logMessages = ""; - if (requirements.length > 0) { - logMessages += `\nGitHub Repository configuration failed for application: ${appName}\n`; - logMessages += "Reasons:\n"; - logMessages += requirements.join("\n"); - const escapedLogMessages = logMessages - .replace(/\\/g, "\\\\") - .replace(/"/g, '\\"') - .replace(/\n/g, "\\n"); - - const bashCommand = ` - echo "${escapedLogMessages}" >> ${logPath}; - exit 1; # Exit with error code - `; - - await execAsyncRemote(serverId, bashCommand); - return; - } - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(true); - const githubProvider = await findGithubById(githubId); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; - const outputPath = join(basePath, appName, "code"); - const octokit = authGithub(githubProvider); - const token = await getGithubToken(octokit); - const repoclone = `github.com/${owner}/${repository}.git`; - const cloneUrl = `https://oauth2:${token}@${repoclone}`; - - const cloneCommand = ` -rm -rf ${outputPath}; -mkdir -p ${outputPath}; -if ! git clone --branch ${branch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${cloneUrl} ${outputPath} >> ${logPath} 2>&1; then - echo "❌ [ERROR] Fail to clone repository ${repoclone}" >> ${logPath}; - exit 1; -fi -echo "Cloned ${repoclone} to ${outputPath}: ✅" >> ${logPath}; - `; - - return cloneCommand; -}; - -export const cloneRawGithubRepository = async (entity: Compose) => { - const { appName, repository, owner, branch, githubId, enableSubmodules } = - entity; - - if (!githubId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "GitHub Provider not found", - }); - } - const { COMPOSE_PATH } = paths(); - const githubProvider = await findGithubById(githubId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const octokit = authGithub(githubProvider); - const token = await getGithubToken(octokit); - const repoclone = `github.com/${owner}/${repository}.git`; - await recreateDirectory(outputPath); - const cloneUrl = `https://oauth2:${token}@${repoclone}`; - try { - const cloneArgs = [ - "clone", - "--branch", - branch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; - await spawnAsync("git", cloneArgs); - } catch (error) { - throw error; - } -}; - -export const cloneRawGithubRepositoryRemote = async (compose: Compose) => { - const { - appName, - repository, - owner, - branch, - githubId, - serverId, - enableSubmodules, - } = compose; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - if (!githubId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "GitHub Provider not found", - }); - } - - const { COMPOSE_PATH } = paths(true); - const githubProvider = await findGithubById(githubId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const octokit = authGithub(githubProvider); - const token = await getGithubToken(octokit); - const repoclone = `github.com/${owner}/${repository}.git`; - const cloneUrl = `https://oauth2:${token}@${repoclone}`; - try { - const command = ` - rm -rf ${outputPath}; - git clone --branch ${branch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} - `; - await execAsyncRemote(serverId, command); - } catch (error) { - throw error; - } + return command; }; export const getGithubRepositories = async (githubId?: string) => { diff --git a/packages/server/src/utils/providers/gitlab.ts b/packages/server/src/utils/providers/gitlab.ts index 840347fdb..3343c9bb6 100644 --- a/packages/server/src/utils/providers/gitlab.ts +++ b/packages/server/src/utils/providers/gitlab.ts @@ -1,8 +1,6 @@ -import { createWriteStream } from "node:fs"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { apiGitlabTestConnection } from "@dokploy/server/db/schema"; -import type { Compose } from "@dokploy/server/services/compose"; import { findGitlabById, type Gitlab, @@ -10,9 +8,6 @@ import { } from "@dokploy/server/services/gitlab"; import type { InferResultType } from "@dokploy/server/types/with"; import { TRPCError } from "@trpc/server"; -import { recreateDirectory } from "../filesystem/directory"; -import { execAsyncRemote } from "../process/execAsync"; -import { spawnAsync } from "../process/spawnAsync"; export const refreshGitlabToken = async (gitlabProviderId: string) => { const gitlabProvider = await findGitlabById(gitlabProviderId); @@ -102,25 +97,34 @@ const getGitlabCloneUrl = (gitlab: GitlabInfo, repoClone: string) => { return cloneUrl; }; -export const cloneGitlabRepository = async ( - entity: ApplicationWithGitlab | ComposeWithGitlab, - logPath: string, - isCompose = false, -) => { - const writeStream = createWriteStream(logPath, { flags: "a" }); +interface CloneGitlabRepository { + appName: string; + gitlabBranch: string | null; + gitlabId: string | null; + gitlabPathNamespace: string | null; + enableSubmodules: boolean; + serverId: string | null; + type?: "application" | "compose"; +} + +export const cloneGitlabRepository = async ({ + type = "application", + ...entity +}: CloneGitlabRepository) => { + let command = "set -e;"; const { appName, gitlabBranch, gitlabId, gitlabPathNamespace, enableSubmodules, + serverId, } = entity; + const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(!!serverId); if (!gitlabId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitlab Provider not found", - }); + command += `echo "Error: ❌ Gitlab Provider not found"; exit 1;`; + return command; } await refreshGitlabToken(gitlabId); @@ -130,127 +134,19 @@ export const cloneGitlabRepository = async ( // Check if requirements are met if (requirements.length > 0) { - writeStream.write( - `\nGitLab Repository configuration failed for application: ${appName}\n`, - ); - writeStream.write("Reasons:\n"); - writeStream.write(requirements.join("\n")); - writeStream.end(); - throw new TRPCError({ - code: "BAD_REQUEST", - message: "Error: GitLab repository information is incomplete.", - }); + command += `echo "❌ [ERROR] GitLab Repository configuration failed for application: ${appName}"; echo "Reasons:"; echo "${requirements.join("\n")}"; exit 1;`; + return command; } - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; + const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); + command += `rm -rf ${outputPath};`; + command += `mkdir -p ${outputPath};`; const repoClone = getGitlabRepoClone(gitlab, gitlabPathNamespace); const cloneUrl = getGitlabCloneUrl(gitlab, repoClone); - try { - writeStream.write(`\nCloning Repo ${repoClone} to ${outputPath}: ✅\n`); - const cloneArgs = [ - "clone", - "--branch", - gitlabBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; - - await spawnAsync("git", cloneArgs, (data) => { - if (writeStream.writable) { - writeStream.write(data); - } - }); - writeStream.write(`\nCloned ${repoClone}: ✅\n`); - } catch (error) { - writeStream.write(`ERROR Cloning: ${error}: ❌`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const getGitlabCloneCommand = async ( - entity: ApplicationWithGitlab | ComposeWithGitlab, - logPath: string, - isCompose = false, -) => { - const { - appName, - gitlabPathNamespace, - gitlabBranch, - gitlabId, - serverId, - enableSubmodules, - } = entity; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - - if (!gitlabId) { - const command = ` - echo "Error: ❌ Gitlab Provider not found" >> ${logPath}; - exit 1; - `; - - await execAsyncRemote(serverId, command); - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitlab Provider not found", - }); - } - - const requirements = getErrorCloneRequirements(entity); - - // Build log messages - let logMessages = ""; - if (requirements.length > 0) { - logMessages += `\nGitLab Repository configuration failed for application: ${appName}\n`; - logMessages += "Reasons:\n"; - logMessages += requirements.join("\n"); - const escapedLogMessages = logMessages - .replace(/\\/g, "\\\\") - .replace(/"/g, '\\"') - .replace(/\n/g, "\\n"); - - const bashCommand = ` - echo "${escapedLogMessages}" >> ${logPath}; - exit 1; # Exit with error code - `; - - await execAsyncRemote(serverId, bashCommand); - return; - } - - const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(true); - await refreshGitlabToken(gitlabId); - const gitlab = await findGitlabById(gitlabId); - const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; - const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); - const repoClone = getGitlabRepoClone(gitlab, gitlabPathNamespace); - const cloneUrl = getGitlabCloneUrl(gitlab, repoClone); - const cloneCommand = ` -rm -rf ${outputPath}; -mkdir -p ${outputPath}; -if ! git clone --branch ${gitlabBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} --progress ${cloneUrl} ${outputPath} >> ${logPath} 2>&1; then - echo "❌ [ERROR] Fail to clone the repository ${repoClone}" >> ${logPath}; - exit 1; -fi -echo "Cloned ${repoClone} to ${outputPath}: ✅" >> ${logPath}; - `; - - return cloneCommand; + command += `echo "Cloning Repo ${repoClone} to ${outputPath}: ✅";`; + command += `git clone --branch ${gitlabBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`; + return command; }; export const getGitlabRepositories = async (gitlabId?: string) => { @@ -355,88 +251,6 @@ export const getGitlabBranches = async (input: { }[]; }; -export const cloneRawGitlabRepository = async (entity: Compose) => { - const { - appName, - gitlabBranch, - gitlabId, - gitlabPathNamespace, - enableSubmodules, - } = entity; - - if (!gitlabId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitlab Provider not found", - }); - } - - const { COMPOSE_PATH } = paths(); - await refreshGitlabToken(gitlabId); - const gitlabProvider = await findGitlabById(gitlabId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - await recreateDirectory(outputPath); - const repoClone = getGitlabRepoClone(gitlabProvider, gitlabPathNamespace); - const cloneUrl = getGitlabCloneUrl(gitlabProvider, repoClone); - try { - const cloneArgs = [ - "clone", - "--branch", - gitlabBranch!, - "--depth", - "1", - ...(enableSubmodules ? ["--recurse-submodules"] : []), - cloneUrl, - outputPath, - "--progress", - ]; - await spawnAsync("git", cloneArgs); - } catch (error) { - throw error; - } -}; - -export const cloneRawGitlabRepositoryRemote = async (compose: Compose) => { - const { - appName, - gitlabPathNamespace, - gitlabBranch, - gitlabId, - serverId, - enableSubmodules, - } = compose; - - if (!serverId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Server not found", - }); - } - if (!gitlabId) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Gitlab Provider not found", - }); - } - const { COMPOSE_PATH } = paths(true); - await refreshGitlabToken(gitlabId); - const gitlabProvider = await findGitlabById(gitlabId); - const basePath = COMPOSE_PATH; - const outputPath = join(basePath, appName, "code"); - const repoClone = getGitlabRepoClone(gitlabProvider, gitlabPathNamespace); - const cloneUrl = getGitlabCloneUrl(gitlabProvider, repoClone); - try { - const command = ` - rm -rf ${outputPath}; - git clone --branch ${gitlabBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} - `; - await execAsyncRemote(serverId, command); - } catch (error) { - throw error; - } -}; - export const testGitlabConnection = async ( input: typeof apiGitlabTestConnection._type, ) => { @@ -476,7 +290,7 @@ export const validateGitlabProvider = async (gitlabProvider: Gitlab) => { while (true) { const response = await fetch( - `${gitlabProvider.gitlabUrl}/api/v4/projects?membership=true&owned=true&page=${page}&per_page=${perPage}`, + `${gitlabProvider.gitlabUrl}/api/v4/projects?membership=true&page=${page}&per_page=${perPage}`, { headers: { Authorization: `Bearer ${gitlabProvider.accessToken}`, diff --git a/packages/server/src/utils/providers/raw.ts b/packages/server/src/utils/providers/raw.ts index 34ba0012a..508df86ed 100644 --- a/packages/server/src/utils/providers/raw.ts +++ b/packages/server/src/utils/providers/raw.ts @@ -1,40 +1,10 @@ -import { createWriteStream } from "node:fs"; -import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { paths } from "@dokploy/server/constants"; import type { Compose } from "@dokploy/server/services/compose"; import { encodeBase64 } from "../docker/utils"; -import { recreateDirectory } from "../filesystem/directory"; -import { execAsyncRemote } from "../process/execAsync"; -export const createComposeFile = async (compose: Compose, logPath: string) => { - const { COMPOSE_PATH } = paths(); - const { appName, composeFile } = compose; - const writeStream = createWriteStream(logPath, { flags: "a" }); - const outputPath = join(COMPOSE_PATH, appName, "code"); - - try { - await recreateDirectory(outputPath); - writeStream.write( - `\nCreating File 'docker-compose.yml' to ${outputPath}: ✅\n`, - ); - - await writeFile(join(outputPath, "docker-compose.yml"), composeFile); - - writeStream.write(`\nFile 'docker-compose.yml' created: ✅\n`); - } catch (error) { - writeStream.write(`\nERROR Creating Compose File: ${error}: ❌\n`); - throw error; - } finally { - writeStream.end(); - } -}; - -export const getCreateComposeFileCommand = ( - compose: Compose, - logPath: string, -) => { - const { COMPOSE_PATH } = paths(true); +export const getCreateComposeFileCommand = (compose: Compose) => { + const { COMPOSE_PATH } = paths(!!compose.serverId); const { appName, composeFile } = compose; const outputPath = join(COMPOSE_PATH, appName, "code"); const filePath = join(outputPath, "docker-compose.yml"); @@ -43,39 +13,7 @@ export const getCreateComposeFileCommand = ( rm -rf ${outputPath}; mkdir -p ${outputPath}; echo "${encodedContent}" | base64 -d > "${filePath}"; - echo "File 'docker-compose.yml' created: ✅" >> ${logPath}; + echo "File 'docker-compose.yml' created: ✅"; `; return bashCommand; }; - -export const createComposeFileRaw = async (compose: Compose) => { - const { COMPOSE_PATH } = paths(); - const { appName, composeFile } = compose; - const outputPath = join(COMPOSE_PATH, appName, "code"); - const filePath = join(outputPath, "docker-compose.yml"); - try { - await recreateDirectory(outputPath); - await writeFile(filePath, composeFile); - } catch (error) { - throw error; - } -}; - -export const createComposeFileRawRemote = async (compose: Compose) => { - const { COMPOSE_PATH } = paths(true); - const { appName, composeFile, serverId } = compose; - const outputPath = join(COMPOSE_PATH, appName, "code"); - const filePath = join(outputPath, "docker-compose.yml"); - - try { - const encodedContent = encodeBase64(composeFile); - const command = ` - rm -rf ${outputPath}; - mkdir -p ${outputPath}; - echo "${encodedContent}" | base64 -d > "${filePath}"; - `; - await execAsyncRemote(serverId, command); - } catch (error) { - throw error; - } -}; diff --git a/packages/server/src/utils/restore/utils.ts b/packages/server/src/utils/restore/utils.ts index c46077238..23052e642 100644 --- a/packages/server/src/utils/restore/utils.ts +++ b/packages/server/src/utils/restore/utils.ts @@ -7,7 +7,7 @@ export const getPostgresRestoreCommand = ( database: string, databaseUser: string, ) => { - return `docker exec -i $CONTAINER_ID sh -c "pg_restore -U ${databaseUser} -d ${database} -O --clean --if-exists"`; + return `docker exec -i $CONTAINER_ID sh -c "pg_restore -U '${databaseUser}' -d ${database} -O --clean --if-exists"`; }; export const getMariadbRestoreCommand = ( @@ -15,14 +15,14 @@ export const getMariadbRestoreCommand = ( databaseUser: string, databasePassword: string, ) => { - return `docker exec -i $CONTAINER_ID sh -c "mariadb -u ${databaseUser} -p${databasePassword} ${database}"`; + return `docker exec -i $CONTAINER_ID sh -c "mariadb -u '${databaseUser}' -p'${databasePassword}' ${database}"`; }; export const getMysqlRestoreCommand = ( database: string, databasePassword: string, ) => { - return `docker exec -i $CONTAINER_ID sh -c "mysql -u root -p${databasePassword} ${database}"`; + return `docker exec -i $CONTAINER_ID sh -c "mysql -u root -p'${databasePassword}' ${database}"`; }; export const getMongoRestoreCommand = ( @@ -30,7 +30,7 @@ export const getMongoRestoreCommand = ( databaseUser: string, databasePassword: string, ) => { - return `docker exec -i $CONTAINER_ID sh -c "mongorestore --username ${databaseUser} --password ${databasePassword} --authenticationDatabase admin --db ${database} --archive"`; + return `docker exec -i $CONTAINER_ID sh -c "mongorestore --username '${databaseUser}' --password '${databasePassword}' --authenticationDatabase admin --db ${database} --archive"`; }; export const getComposeSearchCommand = ( diff --git a/packages/server/src/utils/tracking/hubspot.ts b/packages/server/src/utils/tracking/hubspot.ts new file mode 100644 index 000000000..d22a9591c --- /dev/null +++ b/packages/server/src/utils/tracking/hubspot.ts @@ -0,0 +1,125 @@ +interface HubSpotFormField { + objectTypeId: string; + name: string; + value: string; +} + +interface HubSpotFormData { + fields: HubSpotFormField[]; + context: { + pageUri: string; + pageName: string; + hutk?: string; // HubSpot UTK from cookies + }; +} + +interface SignUpFormData { + firstName?: string; + lastName?: string; + email?: string; +} + +/** + * Extract HubSpot UTK (User Token) from cookies + * This is used for tracking and attribution in HubSpot + */ +export function getHubSpotUTK(cookieHeader?: string): string | null { + if (!cookieHeader) return null; + + const name = "hubspotutk="; + const decodedCookie = decodeURIComponent(cookieHeader); + const cookieArray = decodedCookie.split(";"); + + for (let i = 0; i < cookieArray.length; i++) { + const cookie = cookieArray[i]?.trim(); + if (!cookie) continue; + if (cookie.indexOf(name) === 0) { + return cookie.substring(name.length, cookie.length); + } + } + return null; +} + +/** + * Convert contact form data to HubSpot form format + */ +export function formatContactDataForHubSpot( + contactData: SignUpFormData, + hutk?: string | null, +): HubSpotFormData { + const formData: HubSpotFormData = { + fields: [ + { + objectTypeId: "0-1", // Contact object type + name: "firstname", + value: contactData.firstName || "", + }, + { + objectTypeId: "0-1", + name: "lastname", + value: contactData.lastName || "", + }, + { + objectTypeId: "0-1", + name: "email", + value: contactData.email || "", + }, + ], + context: { + pageUri: "https://app.dokploy.com/register", + pageName: "Sign Up", + }, + }; + + // Add HubSpot UTK if available + if (hutk) { + formData.context.hutk = hutk; + } + + return formData; +} + +/** + * Submit form data to HubSpot Forms API + */ +export async function submitToHubSpot( + contactData: SignUpFormData, + hutk?: string | null, +): Promise { + try { + const portalId = process.env.HUBSPOT_PORTAL_ID; + const formGuid = process.env.HUBSPOT_FORM_GUID; + + if (!portalId || !formGuid) { + console.error( + "HubSpot configuration missing: HUBSPOT_PORTAL_ID or HUBSPOT_FORM_GUID not set", + ); + return false; + } + + const formData = formatContactDataForHubSpot(contactData, hutk); + const response = await fetch( + `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formGuid}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(formData), + }, + ); + + if (!response.ok) { + const errorText = await response.text(); + console.error("HubSpot API error:", response.status, errorText); + return false; + } + + const result = await response.json(); + console.log("HubSpot submission successful:", result); + return true; + } catch (error) { + console.error("Error submitting to HubSpot:", error); + return false; + } +} diff --git a/packages/server/src/utils/traefik/middleware.ts b/packages/server/src/utils/traefik/middleware.ts index 4897b94ee..681b0b831 100644 --- a/packages/server/src/utils/traefik/middleware.ts +++ b/packages/server/src/utils/traefik/middleware.ts @@ -46,8 +46,14 @@ export const deleteMiddleware = ( }; export const deleteAllMiddlewares = async (application: ApplicationNested) => { - const config = loadMiddlewares(); - const { security, appName, redirects } = application; + const { security, appName, redirects, serverId } = application; + let config: FileConfig; + + if (serverId) { + config = await loadRemoteMiddlewares(serverId); + } else { + config = loadMiddlewares(); + } if (config.http?.middlewares) { if (security.length > 0) { @@ -62,8 +68,8 @@ export const deleteAllMiddlewares = async (application: ApplicationNested) => { } } - if (application.serverId) { - await writeTraefikConfigRemote(config, "middlewares", application.serverId); + if (serverId) { + await writeTraefikConfigRemote(config, "middlewares", serverId); } else { writeMiddleware(config); } @@ -100,7 +106,7 @@ export const loadRemoteMiddlewares = async (serverId: string) => { throw new Error(`File not found: ${configPath}`); } }; -export const writeMiddleware = (config: T) => { +export const writeMiddleware = (config: FileConfig) => { const { DYNAMIC_TRAEFIK_PATH } = paths(); const configPath = join(DYNAMIC_TRAEFIK_PATH, "middlewares.yml"); const newYamlContent = stringify(config); @@ -111,6 +117,18 @@ export const createPathMiddlewares = async ( app: ApplicationNested, domain: Domain, ) => { + const { appName } = app; + const { uniqueConfigKey, internalPath, stripPath, path } = domain; + + // Early return if there's no path middleware to create + const needsInternalPathMiddleware = + internalPath && internalPath !== "/" && internalPath !== path; + const needsStripPathMiddleware = stripPath && path && path !== "/"; + + if (!needsInternalPathMiddleware && !needsStripPathMiddleware) { + return; + } + let config: FileConfig; if (app.serverId) { @@ -127,20 +145,19 @@ export const createPathMiddlewares = async ( } } - const { appName } = app; - const { uniqueConfigKey, internalPath, stripPath, path } = domain; - - if (!config.http) { + if (!config) { + config = { http: { middlewares: {} } }; + } else if (!config.http) { config.http = { middlewares: {} }; } - if (!config.http.middlewares) { - config.http.middlewares = {}; + if (!config.http?.middlewares) { + config.http!.middlewares = {}; } // Add internal path prefix middleware if (internalPath && internalPath !== "/" && internalPath !== path) { const middlewareName = `addprefix-${appName}-${uniqueConfigKey}`; - config.http.middlewares[middlewareName] = { + config.http!.middlewares[middlewareName] = { addPrefix: { prefix: internalPath, }, @@ -150,7 +167,7 @@ export const createPathMiddlewares = async ( // Strip external path middleware if needed if (stripPath && path && path !== "/") { const middlewareName = `stripprefix-${appName}-${uniqueConfigKey}`; - config.http.middlewares[middlewareName] = { + config.http!.middlewares[middlewareName] = { stripPrefix: { prefixes: [path], }, @@ -184,6 +201,10 @@ export const removePathMiddlewares = async ( } } + if (!config) { + return; + } + const { appName } = app; if (config.http?.middlewares) { @@ -194,6 +215,23 @@ export const removePathMiddlewares = async ( delete config.http.middlewares[stripPrefixMiddleware]; } + if ( + config?.http?.middlewares && + Object.keys(config.http.middlewares).length === 0 + ) { + // if there aren't any middlewares, remove the whole section + delete config.http.middlewares; + } + + // // If http section is empty, remove it completely + if (config?.http && Object.keys(config?.http).length === 0) { + delete config.http; + } + + if (config && Object.keys(config || {}).length === 0) { + config = {}; + } + if (app.serverId) { await writeTraefikConfigRemote(config, "middlewares", app.serverId); } else { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98be77cca..3a15db2d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -306,10 +306,10 @@ importers: version: 16.4.5 drizzle-orm: specifier: ^0.39.3 - version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4) + version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4) drizzle-zod: specifier: 0.5.1 - version: 0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4))(zod@3.25.32) + version: 0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4))(zod@3.25.32) fancy-ansi: specifier: ^0.1.3 version: 0.1.3 @@ -350,8 +350,8 @@ importers: specifier: ^3.9.17 version: 3.9.17(next@15.3.2(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) node-os-utils: - specifier: 1.3.7 - version: 1.3.7 + specifier: 2.0.1 + version: 2.0.1 node-pty: specifier: 1.0.0 version: 1.0.0 @@ -409,6 +409,9 @@ importers: rotating-file-stream: specifier: 3.2.3 version: 3.2.3 + shell-quote: + specifier: ^1.8.1 + version: 1.8.2 slugify: specifier: ^1.6.6 version: 1.6.6 @@ -476,9 +479,6 @@ importers: '@types/node': specifier: ^18.19.104 version: 18.19.104 - '@types/node-os-utils': - specifier: 1.3.4 - version: 1.3.4 '@types/node-schedule': specifier: 2.1.6 version: 2.1.6 @@ -494,6 +494,9 @@ importers: '@types/react-dom': specifier: 18.3.0 version: 18.3.0 + '@types/shell-quote': + specifier: ^1.7.5 + version: 1.7.5 '@types/ssh2': specifier: 1.15.1 version: 1.15.1 @@ -553,7 +556,7 @@ importers: version: 16.4.5 drizzle-orm: specifier: ^0.39.3 - version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4) + version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4) hono: specifier: ^4.7.10 version: 4.7.10 @@ -671,13 +674,13 @@ importers: version: 16.4.5 drizzle-dbml-generator: specifier: 0.10.0 - version: 0.10.0(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4)) + version: 0.10.0(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4)) drizzle-orm: specifier: ^0.39.3 - version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4) + version: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4) drizzle-zod: specifier: 0.5.1 - version: 0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4))(zod@3.25.32) + version: 0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4))(zod@3.25.32) hi-base32: specifier: ^0.5.1 version: 0.5.1 @@ -691,8 +694,8 @@ importers: specifier: 3.3.11 version: 3.3.11 node-os-utils: - specifier: 1.3.7 - version: 1.3.7 + specifier: 2.0.1 + version: 2.0.1 node-pty: specifier: 1.0.0 version: 1.0.0 @@ -732,6 +735,9 @@ importers: rotating-file-stream: specifier: 3.2.3 version: 3.2.3 + shell-quote: + specifier: ^1.8.1 + version: 1.8.2 slugify: specifier: ^1.6.6 version: 1.6.6 @@ -769,9 +775,6 @@ importers: '@types/node': specifier: ^18.19.104 version: 18.19.104 - '@types/node-os-utils': - specifier: 1.3.4 - version: 1.3.4 '@types/node-schedule': specifier: 2.1.6 version: 2.1.6 @@ -787,6 +790,9 @@ importers: '@types/react-dom': specifier: 18.3.0 version: 18.3.0 + '@types/shell-quote': + specifier: ^1.7.5 + version: 1.7.5 '@types/ssh2': specifier: 1.15.1 version: 1.15.1 @@ -907,6 +913,9 @@ packages: '@better-auth/utils@0.2.5': resolution: {integrity: sha512-uI2+/8h/zVsH8RrYdG8eUErbuGBk16rZKQfz8CjxQOyCE6v7BqFYEbFwvOkvl1KbUdxhqOnXp78+uE5h8qVEgQ==} + '@better-auth/utils@0.3.0': + resolution: {integrity: sha512-W+Adw6ZA6mgvnSnhOki270rwJ42t4XzSK6YWGF//BbVXL6SwCLWfyzBc1lN2m/4RM28KubdBKQ4X5VMoLRNPQw==} + '@better-fetch/fetch@1.1.18': resolution: {integrity: sha512-rEFOE1MYIsBmoMJtQbl32PGHHXuG2hDxvEd7rUHE0vCBoFQVSDqaVs9hkZEtHCxRoY+CljXKFCOuJ8uxqw1LcA==} @@ -1990,10 +1999,6 @@ packages: resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==} engines: {node: ^14.21.3 || >=16} - '@noble/hashes@1.8.0': - resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} - engines: {node: ^14.21.3 || >=16} - '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -2632,17 +2637,38 @@ packages: '@peculiar/asn1-android@2.3.16': resolution: {integrity: sha512-a1viIv3bIahXNssrOIkXZIlI2ePpZaNmR30d4aBL99mu2rO+mT9D6zBsp7H6eROWGtmwv0Ionp5olJurIo09dw==} - '@peculiar/asn1-ecc@2.3.15': - resolution: {integrity: sha512-/HtR91dvgog7z/WhCVdxZJ/jitJuIu8iTqiyWVgRE9Ac5imt2sT/E4obqIVGKQw7PIy+X6i8lVBoT6wC73XUgA==} + '@peculiar/asn1-cms@2.5.0': + resolution: {integrity: sha512-p0SjJ3TuuleIvjPM4aYfvYw8Fk1Hn/zAVyPJZTtZ2eE9/MIer6/18ROxX6N/e6edVSfvuZBqhxAj3YgsmSjQ/A==} - '@peculiar/asn1-rsa@2.3.15': - resolution: {integrity: sha512-p6hsanvPhexRtYSOHihLvUUgrJ8y0FtOM97N5UEpC+VifFYyZa0iZ5cXjTkZoDwxJ/TTJ1IJo3HVTB2JJTpXvg==} + '@peculiar/asn1-csr@2.5.0': + resolution: {integrity: sha512-ioigvA6WSYN9h/YssMmmoIwgl3RvZlAYx4A/9jD2qaqXZwGcNlAxaw54eSx2QG1Yu7YyBC5Rku3nNoHrQ16YsQ==} - '@peculiar/asn1-schema@2.3.15': - resolution: {integrity: sha512-QPeD8UA8axQREpgR5UTAfu2mqQmm97oUqahDtNdBcfj3qAnoXzFdQW+aNf/tD2WVXF8Fhmftxoj0eMIT++gX2w==} + '@peculiar/asn1-ecc@2.5.0': + resolution: {integrity: sha512-t4eYGNhXtLRxaP50h3sfO6aJebUCDGQACoeexcelL4roMFRRVgB20yBIu2LxsPh/tdW9I282gNgMOyg3ywg/mg==} - '@peculiar/asn1-x509@2.3.15': - resolution: {integrity: sha512-0dK5xqTqSLaxv1FHXIcd4Q/BZNuopg+u1l23hT9rOmQ1g4dNtw0g/RnEi+TboB0gOwGtrWn269v27cMgchFIIg==} + '@peculiar/asn1-pfx@2.5.0': + resolution: {integrity: sha512-Vj0d0wxJZA+Ztqfb7W+/iu8Uasw6hhKtCdLKXLG/P3kEPIQpqGI4P4YXlROfl7gOCqFIbgsj1HzFIFwQ5s20ug==} + + '@peculiar/asn1-pkcs8@2.5.0': + resolution: {integrity: sha512-L7599HTI2SLlitlpEP8oAPaJgYssByI4eCwQq2C9eC90otFpm8MRn66PpbKviweAlhinWQ3ZjDD2KIVtx7PaVw==} + + '@peculiar/asn1-pkcs9@2.5.0': + resolution: {integrity: sha512-UgqSMBLNLR5TzEZ5ZzxR45Nk6VJrammxd60WMSkofyNzd3DQLSNycGWSK5Xg3UTYbXcDFyG8pA/7/y/ztVCa6A==} + + '@peculiar/asn1-rsa@2.5.0': + resolution: {integrity: sha512-qMZ/vweiTHy9syrkkqWFvbT3eLoedvamcUdnnvwyyUNv5FgFXA3KP8td+ATibnlZ0EANW5PYRm8E6MJzEB/72Q==} + + '@peculiar/asn1-schema@2.5.0': + resolution: {integrity: sha512-YM/nFfskFJSlHqv59ed6dZlLZqtZQwjRVJ4bBAiWV08Oc+1rSd5lDZcBEx0lGDHfSoH3UziI2pXt2UM33KerPQ==} + + '@peculiar/asn1-x509-attr@2.5.0': + resolution: {integrity: sha512-9f0hPOxiJDoG/bfNLAFven+Bd4gwz/VzrCIIWc1025LEI4BXO0U5fOCTNDPbbp2ll+UzqKsZ3g61mpBp74gk9A==} + + '@peculiar/asn1-x509@2.5.0': + resolution: {integrity: sha512-CpwtMCTJvfvYTFMuiME5IH+8qmDe3yEWzKHe7OOADbGfq7ohxeLaXwQo0q4du3qs0AII3UbLCvb9NF/6q0oTKQ==} + + '@peculiar/x509@1.14.0': + resolution: {integrity: sha512-Yc4PDxN3OrxUPiXgU63c+ZRXKGE8YKF2McTciYhUHFtHVB0KMnjeFSU0qpztGhsp4P0uKix4+J2xEpIEDu8oXg==} '@petamoriken/float16@3.9.2': resolution: {integrity: sha512-VgffxawQde93xKxT3qap3OH+meZf7VaSB5Sqd4Rqc+FP5alWbpOyan/7tRbOAvynjpG3GpdtAuGU/NdhQpmrog==} @@ -3676,11 +3702,11 @@ packages: '@selderee/plugin-htmlparser2@0.11.0': resolution: {integrity: sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==} - '@simplewebauthn/browser@13.1.0': - resolution: {integrity: sha512-WuHZ/PYvyPJ9nxSzgHtOEjogBhwJfC8xzYkPC+rR/+8chl/ft4ngjiK8kSU5HtRJfczupyOh33b25TjYbvwAcg==} + '@simplewebauthn/browser@13.2.2': + resolution: {integrity: sha512-FNW1oLQpTJyqG5kkDg5ZsotvWgmBaC6jCHR7Ej0qUNep36Wl9tj2eZu7J5rP+uhXgHaLk+QQ3lqcw2vS5MX1IA==} - '@simplewebauthn/server@13.1.1': - resolution: {integrity: sha512-1hsLpRHfSuMB9ee2aAdh0Htza/X3f4djhYISrggqGe3xopNjOcePiSDkDDoPzDYaaMCrbqGP1H2TYU7bgL9PmA==} + '@simplewebauthn/server@13.2.2': + resolution: {integrity: sha512-HcWLW28yTMGXpwE9VLx9J+N2KEUaELadLrkPEEI9tpI5la70xNEVEsu/C+m3u7uoq4FulLqZQhgBCzR9IZhFpA==} engines: {node: '>=20.0.0'} '@sinclair/typebox@0.27.8': @@ -3983,9 +4009,6 @@ packages: '@types/mysql@2.15.26': resolution: {integrity: sha512-DSLCOXhkvfS5WNNPbfn2KdICAmk8lLc+/PNvnPnF7gOdMZCxopXduqv0OQ13y/yA/zXTSikZZqVgybUxOEg6YQ==} - '@types/node-os-utils@1.3.4': - resolution: {integrity: sha512-BCUYrbdoO4FUbx6MB9atLNFnkxdliFaxdiTJMIPPiecXIApc5zf4NIqV5G1jWv/ReZvtYyHLs40RkBjHX+vykA==} - '@types/node-schedule@2.1.6': resolution: {integrity: sha512-6AlZSUiNTdaVmH5jXYxX9YgmF1zfOlbjUqw0EllTBmZCnN1R5RR/m/u3No1OiWR05bnQ4jM4/+w4FcGvkAtnKQ==} @@ -4025,6 +4048,9 @@ packages: '@types/readable-stream@4.0.20': resolution: {integrity: sha512-eLgbR5KwUh8+6pngBDxS32MymdCsCHnGtwHTrC0GDorbc7NbcnkZAWptDLgZiRk9VRas+B6TyRgPDucq4zRs8g==} + '@types/shell-quote@1.7.5': + resolution: {integrity: sha512-+UE8GAGRPbJVQDdxi16dgadcBfQ+KG2vgZhV1+3A1XmHbmwcdwhCUwIdy+d3pAGrbvgRoVSjeI9vOWyq376Yzw==} + '@types/shimmer@1.2.0': resolution: {integrity: sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==} @@ -4309,8 +4335,8 @@ packages: better-auth@1.2.8-beta.7: resolution: {integrity: sha512-gVApvvhnPVqMCYYLMhxUfbTi5fJYfp9rcsoJSjjTOMV+CIc7KVlYN6Qo8E7ju1JeRU5ae1Wl1NdXrolRJHjmaQ==} - better-call@1.0.9: - resolution: {integrity: sha512-Qfm0gjk0XQz0oI7qvTK1hbqTsBY4xV2hsHAxF8LZfUYl3RaECCIifXuVqtPpZJWvlCCMlQSvkvhhyuApGUba6g==} + better-call@1.0.19: + resolution: {integrity: sha512-sI3GcA1SCVa3H+CDHl8W8qzhlrckwXOTKhqq3OOPXjgn5aTOMIqGY34zLY/pHA6tRRMjTUC3lz5Mi7EbDA24Kw==} bignumber.js@9.3.1: resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} @@ -5757,9 +5783,9 @@ packages: keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} - kysely@0.28.2: - resolution: {integrity: sha512-4YAVLoF0Sf0UTqlhgQMFU9iQECdah7n+13ANkiuVfRvlK+uI0Etbgd7bVP36dKlG+NXWbhGua8vnGt+sdhvT7A==} - engines: {node: '>=18.0.0'} + kysely@0.28.7: + resolution: {integrity: sha512-u/cAuTL4DRIiO2/g4vNGRgklEKNIj5Q3CG7RoUB5DV5SfEC2hMvPxKi0GWPmnzwL2ryIeud2VTcEEmqzTzEPNw==} + engines: {node: '>=20.0.0'} leac@0.6.0: resolution: {integrity: sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==} @@ -6302,8 +6328,9 @@ packages: '@types/node': optional: true - node-os-utils@1.3.7: - resolution: {integrity: sha512-fvnX9tZbR7WfCG5BAy3yO/nCLyjVWD6MghEq0z5FDfN+ZXpLWNITBdbifxQkQ25ebr16G0N7eRWJisOcMEHG3Q==} + node-os-utils@2.0.1: + resolution: {integrity: sha512-rH2N3qHZETLhdgTGhMMCE8zU3gsWO4we1MFtrSiAI7tYWrnJRc6dk2PseV4co3Lb0v/MbRONLQI2biHQYbpTpg==} + engines: {node: '>=18.0.0'} node-pty@1.0.0: resolution: {integrity: sha512-wtBMWWS7dFZm/VgqElrTvtfMq4GzJ6+edFI0Y0zyzygUSZMgZdraDUMUhCIvkjhJjme15qWmbyJbtAx4ot4uZA==} @@ -6939,6 +6966,9 @@ packages: redux@5.0.1: resolution: {integrity: sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==} + reflect-metadata@0.2.2: + resolution: {integrity: sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==} + refractor@3.6.0: resolution: {integrity: sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==} @@ -7459,6 +7489,9 @@ packages: typescript: optional: true + tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -7467,6 +7500,10 @@ packages: engines: {node: '>=18.0.0'} hasBin: true + tsyringe@4.10.0: + resolution: {integrity: sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==} + engines: {node: '>= 6.0.0'} + tweetnacl@0.14.5: resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} @@ -7926,6 +7963,8 @@ snapshots: typescript: 5.8.3 uncrypto: 0.1.3 + '@better-auth/utils@0.3.0': {} + '@better-fetch/fetch@1.1.18': {} '@biomejs/biome@2.1.1': @@ -8746,8 +8785,6 @@ snapshots: '@noble/hashes@1.7.1': {} - '@noble/hashes@1.8.0': {} - '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -9650,37 +9687,100 @@ snapshots: '@peculiar/asn1-android@2.3.16': dependencies: - '@peculiar/asn1-schema': 2.3.15 + '@peculiar/asn1-schema': 2.5.0 asn1js: 3.0.6 tslib: 2.8.1 - '@peculiar/asn1-ecc@2.3.15': + '@peculiar/asn1-cms@2.5.0': dependencies: - '@peculiar/asn1-schema': 2.3.15 - '@peculiar/asn1-x509': 2.3.15 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + '@peculiar/asn1-x509-attr': 2.5.0 asn1js: 3.0.6 tslib: 2.8.1 - '@peculiar/asn1-rsa@2.3.15': + '@peculiar/asn1-csr@2.5.0': dependencies: - '@peculiar/asn1-schema': 2.3.15 - '@peculiar/asn1-x509': 2.3.15 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 asn1js: 3.0.6 tslib: 2.8.1 - '@peculiar/asn1-schema@2.3.15': + '@peculiar/asn1-ecc@2.5.0': + dependencies: + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-pfx@2.5.0': + dependencies: + '@peculiar/asn1-cms': 2.5.0 + '@peculiar/asn1-pkcs8': 2.5.0 + '@peculiar/asn1-rsa': 2.5.0 + '@peculiar/asn1-schema': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-pkcs8@2.5.0': + dependencies: + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-pkcs9@2.5.0': + dependencies: + '@peculiar/asn1-cms': 2.5.0 + '@peculiar/asn1-pfx': 2.5.0 + '@peculiar/asn1-pkcs8': 2.5.0 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + '@peculiar/asn1-x509-attr': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-rsa@2.5.0': + dependencies: + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-schema@2.5.0': dependencies: asn1js: 3.0.6 pvtsutils: 1.3.6 tslib: 2.8.1 - '@peculiar/asn1-x509@2.3.15': + '@peculiar/asn1-x509-attr@2.5.0': dependencies: - '@peculiar/asn1-schema': 2.3.15 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + asn1js: 3.0.6 + tslib: 2.8.1 + + '@peculiar/asn1-x509@2.5.0': + dependencies: + '@peculiar/asn1-schema': 2.5.0 asn1js: 3.0.6 pvtsutils: 1.3.6 tslib: 2.8.1 + '@peculiar/x509@1.14.0': + dependencies: + '@peculiar/asn1-cms': 2.5.0 + '@peculiar/asn1-csr': 2.5.0 + '@peculiar/asn1-ecc': 2.5.0 + '@peculiar/asn1-pkcs9': 2.5.0 + '@peculiar/asn1-rsa': 2.5.0 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + pvtsutils: 1.3.6 + reflect-metadata: 0.2.2 + tslib: 2.8.1 + tsyringe: 4.10.0 + '@petamoriken/float16@3.9.2': {} '@pkgjs/parseargs@0.11.0': @@ -10691,17 +10791,18 @@ snapshots: domhandler: 5.0.3 selderee: 0.11.0 - '@simplewebauthn/browser@13.1.0': {} + '@simplewebauthn/browser@13.2.2': {} - '@simplewebauthn/server@13.1.1': + '@simplewebauthn/server@13.2.2': dependencies: '@hexagon/base64': 1.1.28 '@levischuck/tiny-cbor': 0.2.11 '@peculiar/asn1-android': 2.3.16 - '@peculiar/asn1-ecc': 2.3.15 - '@peculiar/asn1-rsa': 2.3.15 - '@peculiar/asn1-schema': 2.3.15 - '@peculiar/asn1-x509': 2.3.15 + '@peculiar/asn1-ecc': 2.5.0 + '@peculiar/asn1-rsa': 2.5.0 + '@peculiar/asn1-schema': 2.5.0 + '@peculiar/asn1-x509': 2.5.0 + '@peculiar/x509': 1.14.0 '@sinclair/typebox@0.27.8': {} @@ -11257,8 +11358,6 @@ snapshots: dependencies: '@types/node': 20.17.51 - '@types/node-os-utils@1.3.4': {} - '@types/node-schedule@2.1.6': dependencies: '@types/node': 20.17.51 @@ -11312,6 +11411,8 @@ snapshots: dependencies: '@types/node': 20.17.51 + '@types/shell-quote@1.7.5': {} + '@types/shimmer@1.2.0': {} '@types/ssh2@1.15.1': @@ -11615,18 +11716,19 @@ snapshots: '@better-auth/utils': 0.2.5 '@better-fetch/fetch': 1.1.18 '@noble/ciphers': 0.6.0 - '@noble/hashes': 1.8.0 - '@simplewebauthn/browser': 13.1.0 - '@simplewebauthn/server': 13.1.1 - better-call: 1.0.9 + '@noble/hashes': 1.7.1 + '@simplewebauthn/browser': 13.2.2 + '@simplewebauthn/server': 13.2.2 + better-call: 1.0.19 defu: 6.1.4 jose: 5.10.0 - kysely: 0.28.2 + kysely: 0.28.7 nanostores: 0.11.4 zod: 3.25.32 - better-call@1.0.9: + better-call@1.0.19: dependencies: + '@better-auth/utils': 0.3.0 '@better-fetch/fetch': 1.1.18 rou3: 0.5.1 set-cookie-parser: 2.7.1 @@ -12194,9 +12296,9 @@ snapshots: drange@1.1.1: {} - drizzle-dbml-generator@0.10.0(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4)): + drizzle-dbml-generator@0.10.0(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4)): dependencies: - drizzle-orm: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4) + drizzle-orm: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4) drizzle-kit@0.30.6: dependencies: @@ -12208,16 +12310,16 @@ snapshots: transitivePeerDependencies: - supports-color - drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4): + drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4): optionalDependencies: '@opentelemetry/api': 1.9.0 '@types/pg': 8.6.1 - kysely: 0.28.2 + kysely: 0.28.7 postgres: 3.4.4 - drizzle-zod@0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4))(zod@3.25.32): + drizzle-zod@0.5.1(drizzle-orm@0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4))(zod@3.25.32): dependencies: - drizzle-orm: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.4) + drizzle-orm: 0.39.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.7)(postgres@3.4.4) zod: 3.25.32 dunder-proto@1.0.1: @@ -13151,7 +13253,7 @@ snapshots: dependencies: json-buffer: 3.0.1 - kysely@0.28.2: {} + kysely@0.28.7: {} leac@0.6.0: {} @@ -13778,7 +13880,7 @@ snapshots: optionalDependencies: '@types/node': 18.19.104 - node-os-utils@1.3.7: {} + node-os-utils@2.0.1: {} node-pty@1.0.0: dependencies: @@ -14447,6 +14549,8 @@ snapshots: redux@5.0.1: {} + reflect-metadata@0.2.2: {} + refractor@3.6.0: dependencies: hastscript: 6.0.0 @@ -15054,6 +15158,8 @@ snapshots: optionalDependencies: typescript: 5.8.3 + tslib@1.14.1: {} + tslib@2.8.1: {} tsx@4.16.2: @@ -15063,6 +15169,10 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + tsyringe@4.10.0: + dependencies: + tslib: 1.14.1 + tweetnacl@0.14.5: {} type-detect@4.1.0: {}