Skip to content

Commit 437c44d

Browse files
committed
feat(compose): add configurable MTU for isolated networks
1 parent 4a1b428 commit 437c44d

6 files changed

Lines changed: 51 additions & 1 deletion

File tree

apps/dokploy/components/dashboard/compose/advanced/add-isolation.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import {
2828
FormField,
2929
FormItem,
3030
FormLabel,
31+
FormMessage,
3132
} from "@/components/ui/form";
3233

34+
import { Input } from "@/components/ui/input";
3335
import { Switch } from "@/components/ui/switch";
3436
import { api } from "@/utils/api";
3537

@@ -40,6 +42,7 @@ interface Props {
4042
// Schema for Isolated Deployment
4143
const isolatedSchema = z.object({
4244
isolatedDeployment: z.boolean().optional(),
45+
isolatedNetworkMtu: z.number().int().min(68).max(9000).nullable().optional(),
4346
});
4447

4548
type IsolatedSchema = z.infer<typeof isolatedSchema>;
@@ -63,6 +66,7 @@ export const IsolatedDeploymentTab = ({ composeId }: Props) => {
6366
const form = useForm<IsolatedSchema>({
6467
defaultValues: {
6568
isolatedDeployment: false,
69+
isolatedNetworkMtu: null,
6670
},
6771
resolver: zodResolver(isolatedSchema),
6872
});
@@ -71,6 +75,7 @@ export const IsolatedDeploymentTab = ({ composeId }: Props) => {
7175
if (data) {
7276
form.reset({
7377
isolatedDeployment: data?.isolatedDeployment || false,
78+
isolatedNetworkMtu: data?.isolatedNetworkMtu ?? null,
7479
});
7580
}
7681
}, [form, form.reset, form.formState.isSubmitSuccessful, data]);
@@ -79,6 +84,7 @@ export const IsolatedDeploymentTab = ({ composeId }: Props) => {
7984
await updateCompose({
8085
composeId,
8186
isolatedDeployment: formData?.isolatedDeployment || false,
87+
isolatedNetworkMtu: formData?.isolatedNetworkMtu ?? null,
8288
})
8389
.then(async (_data) => {
8490
await refetch();
@@ -180,6 +186,41 @@ export const IsolatedDeploymentTab = ({ composeId }: Props) => {
180186
/>
181187
</div>
182188

189+
{form.watch("isolatedDeployment") && (
190+
<div>
191+
<FormField
192+
control={form.control}
193+
name="isolatedNetworkMtu"
194+
render={({ field }) => (
195+
<FormItem className="mt-4 rounded-lg border p-3 shadow-sm">
196+
<div className="space-y-0.5">
197+
<FormLabel>
198+
Network MTU (optional)
199+
</FormLabel>
200+
<FormDescription>
201+
Set a custom MTU for the isolated network. Leave empty for Docker default (1500). Use 1350 for environments behind VPN/overlay networks.
202+
</FormDescription>
203+
</div>
204+
<FormControl>
205+
<Input
206+
type="number"
207+
min={68}
208+
max={9000}
209+
placeholder="1500"
210+
value={field.value ?? ""}
211+
onChange={(e) => {
212+
const val = e.target.value;
213+
field.onChange(val === "" ? null : Number(val));
214+
}}
215+
/>
216+
</FormControl>
217+
<FormMessage />
218+
</FormItem>
219+
)}
220+
/>
221+
</div>
222+
)}
223+
183224
<div className="flex flex-col lg:flex-row gap-4 w-full items-end justify-end">
184225
<Button
185226
form="isolated-deployment-form"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "compose" ADD COLUMN "isolatedNetworkMtu" integer;
File renamed without changes.

apps/dokploy/drizzle/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,13 @@
11561156
"when": 1775369858244,
11571157
"tag": "0164_slippery_sasquatch",
11581158
"breakpoints": true
1159+
},
1160+
{
1161+
"idx": 165,
1162+
"version": "7",
1163+
"when": 1774490000000,
1164+
"tag": "0165_add_isolated_network_mtu",
1165+
"breakpoints": true
11591166
}
11601167
]
11611168
}

packages/server/src/db/schema/compose.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const compose = pgTable("compose", {
8080
suffix: text("suffix").notNull().default(""),
8181
randomize: boolean("randomize").notNull().default(false),
8282
isolatedDeployment: boolean("isolatedDeployment").notNull().default(false),
83+
isolatedNetworkMtu: integer("isolatedNetworkMtu"),
8384
// Keep this for backward compatibility since we will not add the prefix anymore to volumes
8485
isolatedDeploymentsVolume: boolean("isolatedDeploymentsVolume")
8586
.notNull()

packages/server/src/utils/builders/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Compose Type: ${composeType} ✅`;
5353
5454
cd "${projectPath}";
5555
56-
${compose.isolatedDeployment ? `docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create ${compose.composeType === "stack" ? "--driver overlay" : ""} --attachable ${compose.appName}` : ""}
56+
${compose.isolatedDeployment ? `docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create ${compose.composeType === "stack" ? "--driver overlay" : ""} --attachable ${compose.composeType !== "stack" && compose.isolatedNetworkMtu ? `--opt com.docker.network.driver.mtu=${compose.isolatedNetworkMtu}` : ""} ${compose.appName}` : ""}
5757
env -i PATH="$PATH" ${exportEnvCommand} docker ${command.split(" ").join(" ")} 2>&1 || { echo "Error: ❌ Docker command failed"; exit 1; }
5858
${compose.isolatedDeployment ? `docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1` : ""}
5959

0 commit comments

Comments
 (0)