Skip to content

Commit 9451958

Browse files
authored
Merge pull request #3632 from Dokploy/1591-gitea-git-provider-fails-after-the-authorize-application-stage-self-hosted-on-private-network
feat(gitea): add optional internal URL for Gitea integration
2 parents 325a0ae + 1a81079 commit 9451958

10 files changed

Lines changed: 7328 additions & 2 deletions

File tree

apps/dokploy/components/dashboard/settings/git/gitea/add-gitea-provider.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
FormControl,
2222
FormField,
2323
FormItem,
24+
FormDescription,
2425
FormLabel,
2526
FormMessage,
2627
} from "@/components/ui/form";
@@ -39,6 +40,10 @@ const Schema = z.object({
3940
giteaUrl: z.string().min(1, {
4041
message: "Gitea URL is required",
4142
}),
43+
giteaInternalUrl: z
44+
.union([z.string().url(), z.literal("")])
45+
.optional()
46+
.transform((v) => (v === "" ? undefined : v)),
4247
clientId: z.string().min(1, {
4348
message: "Client ID is required",
4449
}),
@@ -70,6 +75,7 @@ export const AddGiteaProvider = () => {
7075
redirectUri: webhookUrl,
7176
name: "",
7277
giteaUrl: "https://gitea.com",
78+
giteaInternalUrl: "",
7379
},
7480
resolver: zodResolver(Schema),
7581
});
@@ -83,6 +89,7 @@ export const AddGiteaProvider = () => {
8389
redirectUri: webhookUrl,
8490
name: "",
8591
giteaUrl: "https://gitea.com",
92+
giteaInternalUrl: "",
8693
});
8794
}, [form, webhookUrl, isOpen]);
8895

@@ -95,6 +102,7 @@ export const AddGiteaProvider = () => {
95102
name: data.name,
96103
redirectUri: data.redirectUri,
97104
giteaUrl: data.giteaUrl,
105+
giteaInternalUrl: data.giteaInternalUrl || undefined,
98106
organizationName: data.organizationName,
99107
})) as unknown as GiteaProviderResponse;
100108

@@ -223,6 +231,29 @@ export const AddGiteaProvider = () => {
223231
)}
224232
/>
225233

234+
<FormField
235+
control={form.control}
236+
name="giteaInternalUrl"
237+
render={({ field }) => (
238+
<FormItem>
239+
<FormLabel>Internal URL (Optional)</FormLabel>
240+
<FormControl>
241+
<Input
242+
placeholder="http://gitea:3000"
243+
{...field}
244+
value={field.value ?? ""}
245+
/>
246+
</FormControl>
247+
<FormDescription>
248+
Use when Gitea runs on the same instance as Dokploy.
249+
Used for OAuth token exchange to reach Gitea via
250+
internal network (e.g. Docker service name).
251+
</FormDescription>
252+
<FormMessage />
253+
</FormItem>
254+
)}
255+
/>
256+
226257
<FormField
227258
control={form.control}
228259
name="redirectUri"

apps/dokploy/components/dashboard/settings/git/gitea/edit-gitea-provider.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
FormControl,
2020
FormField,
2121
FormItem,
22+
FormDescription,
2223
FormLabel,
2324
FormMessage,
2425
} from "@/components/ui/form";
@@ -30,6 +31,10 @@ import { useUrl } from "@/utils/hooks/use-url";
3031
const formSchema = z.object({
3132
name: z.string().min(1, "Name is required"),
3233
giteaUrl: z.string().min(1, "Gitea URL is required"),
34+
giteaInternalUrl: z
35+
.union([z.string().url(), z.literal("")])
36+
.optional()
37+
.transform((v) => (v === "" ? undefined : v)),
3338
clientId: z.string().min(1, "Client ID is required"),
3439
clientSecret: z.string().min(1, "Client Secret is required"),
3540
});
@@ -94,6 +99,7 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
9499
defaultValues: {
95100
name: "",
96101
giteaUrl: "https://gitea.com",
102+
giteaInternalUrl: "",
97103
clientId: "",
98104
clientSecret: "",
99105
},
@@ -104,6 +110,7 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
104110
form.reset({
105111
name: gitea.gitProvider?.name || "",
106112
giteaUrl: gitea.giteaUrl || "https://gitea.com",
113+
giteaInternalUrl: gitea.giteaInternalUrl || "",
107114
clientId: gitea.clientId || "",
108115
clientSecret: gitea.clientSecret || "",
109116
});
@@ -116,6 +123,7 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
116123
gitProviderId: gitea?.gitProvider?.gitProviderId || "",
117124
name: values.name,
118125
giteaUrl: values.giteaUrl,
126+
giteaInternalUrl: values.giteaInternalUrl ?? null,
119127
clientId: values.clientId,
120128
clientSecret: values.clientSecret,
121129
})
@@ -224,6 +232,28 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
224232
</FormItem>
225233
)}
226234
/>
235+
<FormField
236+
control={form.control}
237+
name="giteaInternalUrl"
238+
render={({ field }) => (
239+
<FormItem>
240+
<FormLabel>Internal URL (Optional)</FormLabel>
241+
<FormControl>
242+
<Input
243+
placeholder="http://gitea:3000"
244+
{...field}
245+
value={field.value ?? ""}
246+
/>
247+
</FormControl>
248+
<FormDescription>
249+
Use when Gitea runs on the same instance as Dokploy. Used
250+
for OAuth token exchange to reach Gitea via internal network
251+
(e.g. Docker service name).
252+
</FormDescription>
253+
<FormMessage />
254+
</FormItem>
255+
)}
256+
/>
227257
<FormField
228258
control={form.control}
229259
name="clientId"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "gitea" ADD COLUMN "giteaInternalUrl" text;

0 commit comments

Comments
 (0)