mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-29 11:05:33 +02:00
Merge pull request #2124 from Dokploy/feat/add-ports-publish-mode
Feat/add ports publish mode
This commit is contained in:
@@ -35,6 +35,9 @@ import { z } from "zod";
|
|||||||
|
|
||||||
const AddPortSchema = z.object({
|
const AddPortSchema = z.object({
|
||||||
publishedPort: z.number().int().min(1).max(65535),
|
publishedPort: z.number().int().min(1).max(65535),
|
||||||
|
publishMode: z.enum(["ingress", "host"], {
|
||||||
|
required_error: "Publish mode is required",
|
||||||
|
}),
|
||||||
targetPort: z.number().int().min(1).max(65535),
|
targetPort: z.number().int().min(1).max(65535),
|
||||||
protocol: z.enum(["tcp", "udp"], {
|
protocol: z.enum(["tcp", "udp"], {
|
||||||
required_error: "Protocol is required",
|
required_error: "Protocol is required",
|
||||||
@@ -80,6 +83,7 @@ export const HandlePorts = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.reset({
|
form.reset({
|
||||||
publishedPort: data?.publishedPort ?? 0,
|
publishedPort: data?.publishedPort ?? 0,
|
||||||
|
publishMode: data?.publishMode ?? "ingress",
|
||||||
targetPort: data?.targetPort ?? 0,
|
targetPort: data?.targetPort ?? 0,
|
||||||
protocol: data?.protocol ?? "tcp",
|
protocol: data?.protocol ?? "tcp",
|
||||||
});
|
});
|
||||||
@@ -165,6 +169,32 @@ export const HandlePorts = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="publishMode"
|
||||||
|
render={({ field }) => {
|
||||||
|
return (
|
||||||
|
<FormItem className="md:col-span-2">
|
||||||
|
<FormLabel>Published Port Mode</FormLabel>
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
value={field.value}
|
||||||
|
>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select a publish mode for the port" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value={"ingress"}>Ingress</SelectItem>
|
||||||
|
<SelectItem value={"host"}>Host</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="targetPort"
|
name="targetPort"
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const ShowPorts = ({ applicationId }: Props) => {
|
|||||||
{data?.ports.map((port) => (
|
{data?.ports.map((port) => (
|
||||||
<div key={port.portId}>
|
<div key={port.portId}>
|
||||||
<div className="flex w-full flex-col sm:flex-row sm:items-center justify-between gap-4 sm:gap-10 border rounded-lg p-4">
|
<div className="flex w-full flex-col sm:flex-row sm:items-center justify-between gap-4 sm:gap-10 border rounded-lg p-4">
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 flex-col gap-4 sm:gap-8">
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 flex-col gap-4 sm:gap-8">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<span className="font-medium">Published Port</span>
|
<span className="font-medium">Published Port</span>
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
@@ -68,7 +68,13 @@ export const ShowPorts = ({ applicationId }: Props) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<span className="font-medium"> Target Port</span>
|
<span className="font-medium">Published Port Mode</span>
|
||||||
|
<span className="text-sm text-muted-foreground">
|
||||||
|
{port?.publishMode?.toUpperCase()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Target Port</span>
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
{port.targetPort}
|
{port.targetPort}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
2
apps/dokploy/drizzle/0099_wise_golden_guardian.sql
Normal file
2
apps/dokploy/drizzle/0099_wise_golden_guardian.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE TYPE "public"."publishModeType" AS ENUM('ingress', 'host');--> statement-breakpoint
|
||||||
|
ALTER TABLE "port" ADD COLUMN "publishMode" "publishModeType" DEFAULT 'host' NOT NULL;
|
||||||
5848
apps/dokploy/drizzle/meta/0099_snapshot.json
Normal file
5848
apps/dokploy/drizzle/meta/0099_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -694,6 +694,13 @@
|
|||||||
"when": 1751233265357,
|
"when": 1751233265357,
|
||||||
"tag": "0098_conscious_chat",
|
"tag": "0098_conscious_chat",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 99,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1751693569786,
|
||||||
|
"tag": "0099_wise_golden_guardian",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|||||||
import { applications } from "./application";
|
import { applications } from "./application";
|
||||||
|
|
||||||
export const protocolType = pgEnum("protocolType", ["tcp", "udp"]);
|
export const protocolType = pgEnum("protocolType", ["tcp", "udp"]);
|
||||||
|
export const publishModeType = pgEnum("publishModeType", ["ingress", "host"]);
|
||||||
|
|
||||||
export const ports = pgTable("port", {
|
export const ports = pgTable("port", {
|
||||||
portId: text("portId")
|
portId: text("portId")
|
||||||
@@ -13,6 +14,7 @@ export const ports = pgTable("port", {
|
|||||||
.primaryKey()
|
.primaryKey()
|
||||||
.$defaultFn(() => nanoid()),
|
.$defaultFn(() => nanoid()),
|
||||||
publishedPort: integer("publishedPort").notNull(),
|
publishedPort: integer("publishedPort").notNull(),
|
||||||
|
publishMode: publishModeType("publishMode").notNull().default("host"),
|
||||||
targetPort: integer("targetPort").notNull(),
|
targetPort: integer("targetPort").notNull(),
|
||||||
protocol: protocolType("protocol").notNull(),
|
protocol: protocolType("protocol").notNull(),
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@ const createSchema = createInsertSchema(ports, {
|
|||||||
portId: z.string().min(1),
|
portId: z.string().min(1),
|
||||||
applicationId: z.string().min(1),
|
applicationId: z.string().min(1),
|
||||||
publishedPort: z.number(),
|
publishedPort: z.number(),
|
||||||
|
publishMode: z.enum(["ingress", "host"]).default("ingress"),
|
||||||
targetPort: z.number(),
|
targetPort: z.number(),
|
||||||
protocol: z.enum(["tcp", "udp"]).default("tcp"),
|
protocol: z.enum(["tcp", "udp"]).default("tcp"),
|
||||||
});
|
});
|
||||||
@@ -39,6 +42,7 @@ const createSchema = createInsertSchema(ports, {
|
|||||||
export const apiCreatePort = createSchema
|
export const apiCreatePort = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
publishedPort: true,
|
publishedPort: true,
|
||||||
|
publishMode: true,
|
||||||
targetPort: true,
|
targetPort: true,
|
||||||
protocol: true,
|
protocol: true,
|
||||||
applicationId: true,
|
applicationId: true,
|
||||||
@@ -55,6 +59,7 @@ export const apiUpdatePort = createSchema
|
|||||||
.pick({
|
.pick({
|
||||||
portId: true,
|
portId: true,
|
||||||
publishedPort: true,
|
publishedPort: true,
|
||||||
|
publishMode: true,
|
||||||
targetPort: true,
|
targetPort: true,
|
||||||
protocol: true,
|
protocol: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ export const mechanizeDockerContainer = async (
|
|||||||
RollbackConfig,
|
RollbackConfig,
|
||||||
EndpointSpec: {
|
EndpointSpec: {
|
||||||
Ports: ports.map((port) => ({
|
Ports: ports.map((port) => ({
|
||||||
|
PublishMode: port.publishMode,
|
||||||
Protocol: port.protocol,
|
Protocol: port.protocol,
|
||||||
TargetPort: port.targetPort,
|
TargetPort: port.targetPort,
|
||||||
PublishedPort: port.publishedPort,
|
PublishedPort: port.publishedPort,
|
||||||
|
|||||||
Reference in New Issue
Block a user