Skip to content

Commit 4f2268e

Browse files
authored
Merge pull request #2976 from Dokploy/2838-endpoint-mode-configuration-solves-networking-issues-inside-lxc-containers
Refactor user schema and update database references: rename 'users_te…
2 parents 1ce1533 + b99d532 commit 4f2268e

File tree

33 files changed

+7108
-183
lines changed

33 files changed

+7108
-183
lines changed

apps/dokploy/__test__/drop/drop.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const baseApp: ApplicationNested = {
4242
triggerType: "push",
4343
appName: "",
4444
autoDeploy: true,
45+
endpointSpecSwarm: null,
4546
serverId: "",
4647
registryUrl: "",
4748
branch: null,

apps/dokploy/__test__/traefik/traefik.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const baseApp: ApplicationNested = {
1515
giteaId: "",
1616
cleanCache: false,
1717
applicationStatus: "done",
18+
endpointSpecSwarm: null,
1819
appName: "",
1920
autoDeploy: true,
2021
enableSubmodules: false,

apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ const NetworkSwarmSchema = z.array(
122122

123123
const LabelsSwarmSchema = z.record(z.string());
124124

125+
const EndpointPortConfigSwarmSchema = z
126+
.object({
127+
Protocol: z.string().optional(),
128+
TargetPort: z.number().optional(),
129+
PublishedPort: z.number().optional(),
130+
PublishMode: z.string().optional(),
131+
})
132+
.strict();
133+
134+
const EndpointSpecSwarmSchema = z
135+
.object({
136+
Mode: z.string().optional(),
137+
Ports: z.array(EndpointPortConfigSwarmSchema).optional(),
138+
})
139+
.strict();
140+
125141
const createStringToJSONSchema = (schema: z.ZodTypeAny) => {
126142
return z
127143
.string()
@@ -178,6 +194,9 @@ const addSwarmSettings = z.object({
178194
labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(),
179195
networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(),
180196
stopGracePeriodSwarm: z.bigint().nullable(),
197+
endpointSpecSwarm: createStringToJSONSchema(
198+
EndpointSpecSwarmSchema,
199+
).nullable(),
181200
});
182201

183202
type AddSwarmSettings = z.infer<typeof addSwarmSettings>;
@@ -234,6 +253,7 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
234253
labelsSwarm: null,
235254
networkSwarm: null,
236255
stopGracePeriodSwarm: null,
256+
endpointSpecSwarm: null,
237257
},
238258
resolver: zodResolver(addSwarmSettings),
239259
});
@@ -275,6 +295,9 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
275295
? JSON.stringify(data.networkSwarm, null, 2)
276296
: null,
277297
stopGracePeriodSwarm: normalizedStopGracePeriod,
298+
endpointSpecSwarm: data.endpointSpecSwarm
299+
? JSON.stringify(data.endpointSpecSwarm, null, 2)
300+
: null,
278301
});
279302
}
280303
}, [form, form.reset, data]);
@@ -296,6 +319,7 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
296319
labelsSwarm: data.labelsSwarm,
297320
networkSwarm: data.networkSwarm,
298321
stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null,
322+
endpointSpecSwarm: data.endpointSpecSwarm,
299323
})
300324
.then(async () => {
301325
toast.success("Swarm settings updated");
@@ -846,6 +870,67 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
846870
</FormItem>
847871
)}
848872
/>
873+
<FormField
874+
control={form.control}
875+
name="endpointSpecSwarm"
876+
render={({ field }) => (
877+
<FormItem className="relative ">
878+
<FormLabel>Endpoint Spec</FormLabel>
879+
<TooltipProvider delayDuration={0}>
880+
<Tooltip>
881+
<TooltipTrigger asChild>
882+
<FormDescription className="break-all w-fit flex flex-row gap-1 items-center">
883+
Check the interface
884+
<HelpCircle className="size-4 text-muted-foreground" />
885+
</FormDescription>
886+
</TooltipTrigger>
887+
<TooltipContent
888+
className="w-full z-[999]"
889+
align="start"
890+
side="bottom"
891+
>
892+
<code>
893+
<pre>
894+
{`{
895+
Mode?: string | undefined;
896+
Ports?: Array<{
897+
Protocol?: string | undefined;
898+
TargetPort?: number | undefined;
899+
PublishedPort?: number | undefined;
900+
PublishMode?: string | undefined;
901+
}> | undefined;
902+
}`}
903+
</pre>
904+
</code>
905+
</TooltipContent>
906+
</Tooltip>
907+
</TooltipProvider>
908+
909+
<FormControl>
910+
<CodeEditor
911+
language="json"
912+
placeholder={`{
913+
"Mode": "dnsrr",
914+
"Ports": [
915+
{
916+
"Protocol": "tcp",
917+
"TargetPort": 5432,
918+
"PublishedPort": 5432,
919+
"PublishMode": "host"
920+
}
921+
]
922+
}`}
923+
className="h-[17rem] font-mono"
924+
{...field}
925+
value={field?.value || ""}
926+
/>
927+
</FormControl>
928+
<pre>
929+
<FormMessage />
930+
</pre>
931+
</FormItem>
932+
)}
933+
/>
849934
<DialogFooter className="flex w-full flex-row justify-end md:col-span-2 m-0 sticky bottom-0 right-0 bg-muted border">
850935
<Button
851936
isLoading={isLoading}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ALTER TABLE "user_temp" RENAME TO "user";--> statement-breakpoint
2+
ALTER TABLE "user" DROP CONSTRAINT "user_temp_email_unique";--> statement-breakpoint
3+
ALTER TABLE "account" DROP CONSTRAINT "account_user_id_user_temp_id_fk";
4+
--> statement-breakpoint
5+
ALTER TABLE "apikey" DROP CONSTRAINT "apikey_user_id_user_temp_id_fk";
6+
--> statement-breakpoint
7+
ALTER TABLE "invitation" DROP CONSTRAINT "invitation_inviter_id_user_temp_id_fk";
8+
--> statement-breakpoint
9+
ALTER TABLE "member" DROP CONSTRAINT "member_user_id_user_temp_id_fk";
10+
--> statement-breakpoint
11+
ALTER TABLE "organization" DROP CONSTRAINT "organization_owner_id_user_temp_id_fk";
12+
--> statement-breakpoint
13+
ALTER TABLE "two_factor" DROP CONSTRAINT "two_factor_user_id_user_temp_id_fk";
14+
--> statement-breakpoint
15+
ALTER TABLE "backup" DROP CONSTRAINT "backup_userId_user_temp_id_fk";
16+
--> statement-breakpoint
17+
ALTER TABLE "git_provider" DROP CONSTRAINT "git_provider_userId_user_temp_id_fk";
18+
--> statement-breakpoint
19+
ALTER TABLE "schedule" DROP CONSTRAINT "schedule_userId_user_temp_id_fk";
20+
--> statement-breakpoint
21+
ALTER TABLE "session_temp" DROP CONSTRAINT "session_temp_user_id_user_temp_id_fk";
22+
--> statement-breakpoint
23+
ALTER TABLE "application" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
24+
ALTER TABLE "mariadb" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
25+
ALTER TABLE "mongo" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
26+
ALTER TABLE "mysql" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
27+
ALTER TABLE "postgres" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
28+
ALTER TABLE "redis" ADD COLUMN "endpointSpecSwarm" json;--> statement-breakpoint
29+
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
30+
ALTER TABLE "apikey" ADD CONSTRAINT "apikey_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
31+
ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
32+
ALTER TABLE "member" ADD CONSTRAINT "member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
33+
ALTER TABLE "organization" ADD CONSTRAINT "organization_owner_id_user_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
34+
ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
35+
ALTER TABLE "backup" ADD CONSTRAINT "backup_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
36+
ALTER TABLE "git_provider" ADD CONSTRAINT "git_provider_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
37+
ALTER TABLE "schedule" ADD CONSTRAINT "schedule_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
38+
ALTER TABLE "session_temp" ADD CONSTRAINT "session_temp_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
39+
ALTER TABLE "user" ADD CONSTRAINT "user_email_unique" UNIQUE("email");

0 commit comments

Comments
 (0)