diff --git a/apps/dokploy/__test__/deploy/github-webhook-handler.test.ts b/apps/dokploy/__test__/deploy/github-webhook-handler.test.ts index 6b61c97d7..43594848a 100644 --- a/apps/dokploy/__test__/deploy/github-webhook-handler.test.ts +++ b/apps/dokploy/__test__/deploy/github-webhook-handler.test.ts @@ -63,6 +63,7 @@ vi.mock("@dokploy/server/db", () => ({ })); vi.mock("@dokploy/server", () => ({ + DEPLOY_WEBHOOK_MAX_BODY_SIZE: 25 * 1024 * 1024, IS_CLOUD: false, shouldDeploy: mocks.shouldDeploy, checkUserRepositoryPermissions: vi.fn(), diff --git a/apps/dokploy/pages/api/deploy/[refreshToken].ts b/apps/dokploy/pages/api/deploy/[refreshToken].ts index 988a344d4..5fa176bdf 100644 --- a/apps/dokploy/pages/api/deploy/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/[refreshToken].ts @@ -1,5 +1,6 @@ import { type Bitbucket, + DEPLOY_WEBHOOK_MAX_BODY_SIZE, getBitbucketHeaders, IS_CLOUD, shouldDeploy, @@ -35,7 +36,7 @@ const getPackageVersion = (headers: any, body: any) => { export const config = { api: { bodyParser: { - sizeLimit: "25mb", + sizeLimit: DEPLOY_WEBHOOK_MAX_BODY_SIZE, }, }, }; diff --git a/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts b/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts index 06b4e768d..f11f96c10 100644 --- a/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts @@ -1,4 +1,8 @@ -import { IS_CLOUD, shouldDeploy } from "@dokploy/server"; +import { + DEPLOY_WEBHOOK_MAX_BODY_SIZE, + IS_CLOUD, + shouldDeploy, +} from "@dokploy/server"; import { db } from "@dokploy/server/db"; import { eq } from "drizzle-orm"; import type { NextApiRequest, NextApiResponse } from "next"; @@ -18,7 +22,7 @@ import { export const config = { api: { bodyParser: { - sizeLimit: "25mb", + sizeLimit: DEPLOY_WEBHOOK_MAX_BODY_SIZE, }, }, }; diff --git a/apps/dokploy/pages/api/deploy/github.ts b/apps/dokploy/pages/api/deploy/github.ts index bb39ed7d5..713e93d79 100644 --- a/apps/dokploy/pages/api/deploy/github.ts +++ b/apps/dokploy/pages/api/deploy/github.ts @@ -2,6 +2,7 @@ import { checkUserRepositoryPermissions, createPreviewDeployment, createSecurityBlockedComment, + DEPLOY_WEBHOOK_MAX_BODY_SIZE, findGithubById, findPreviewDeploymentByApplicationId, findPreviewDeploymentsByPullRequestId, @@ -29,7 +30,7 @@ const getGithubRepositoryOwner = (githubBody: any) => export const config = { api: { bodyParser: { - sizeLimit: "25mb", + sizeLimit: DEPLOY_WEBHOOK_MAX_BODY_SIZE, }, }, }; diff --git a/packages/server/src/constants/index.ts b/packages/server/src/constants/index.ts index c303041f3..133a09f7a 100644 --- a/packages/server/src/constants/index.ts +++ b/packages/server/src/constants/index.ts @@ -13,7 +13,7 @@ export const DOKPLOY_DOCKER_PORT = process.env.DOKPLOY_DOCKER_PORT export const CLEANUP_CRON_JOB = "50 23 * * *"; -// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts). +// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts) and the deploy webhooks (pages/api/deploy/*). const parseByteSize = (envVar: string, fallback: number): number => { const raw = process.env[envVar]; if (!raw) return fallback; @@ -35,6 +35,11 @@ export const OPENAPI_MAX_UPLOAD_SIZE = parseByteSize( 1024 * 1024 * 1024, // 1gb ); +export const DEPLOY_WEBHOOK_MAX_BODY_SIZE = parseByteSize( + "DEPLOY_WEBHOOK_MAX_BODY_SIZE", + 25 * 1024 * 1024, // 25mb, GitHub's max webhook payload +); + type DockerSocketCandidate = { label: string; path: string;