mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #520 from Dokploy/487-private-docker-container-pull-failed-despite-having-docker-registry-configured-in-registry
fix(registry): add option to login the registry in the remote server
This commit is contained in:
@@ -17,10 +17,18 @@ import {
|
|||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectLabel,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { AlertTriangle, Container } from "lucide-react";
|
import { AlertTriangle, Container } from "lucide-react";
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
@@ -36,10 +44,9 @@ const AddRegistrySchema = z.object({
|
|||||||
password: z.string().min(1, {
|
password: z.string().min(1, {
|
||||||
message: "Password is required",
|
message: "Password is required",
|
||||||
}),
|
}),
|
||||||
registryUrl: z.string().min(1, {
|
registryUrl: z.string(),
|
||||||
message: "Registry URL is required",
|
|
||||||
}),
|
|
||||||
imagePrefix: z.string(),
|
imagePrefix: z.string(),
|
||||||
|
serverId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type AddRegistry = z.infer<typeof AddRegistrySchema>;
|
type AddRegistry = z.infer<typeof AddRegistrySchema>;
|
||||||
@@ -48,9 +55,9 @@ export const AddRegistry = () => {
|
|||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const { mutateAsync, error, isError } = api.registry.create.useMutation();
|
const { mutateAsync, error, isError } = api.registry.create.useMutation();
|
||||||
|
const { data: servers } = api.server.withSSHKey.useQuery();
|
||||||
const { mutateAsync: testRegistry, isLoading } =
|
const { mutateAsync: testRegistry, isLoading } =
|
||||||
api.registry.testRegistry.useMutation();
|
api.registry.testRegistry.useMutation();
|
||||||
const router = useRouter();
|
|
||||||
const form = useForm<AddRegistry>({
|
const form = useForm<AddRegistry>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
username: "",
|
username: "",
|
||||||
@@ -58,6 +65,7 @@ export const AddRegistry = () => {
|
|||||||
registryUrl: "",
|
registryUrl: "",
|
||||||
imagePrefix: "",
|
imagePrefix: "",
|
||||||
registryName: "",
|
registryName: "",
|
||||||
|
serverId: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(AddRegistrySchema),
|
resolver: zodResolver(AddRegistrySchema),
|
||||||
});
|
});
|
||||||
@@ -67,6 +75,7 @@ export const AddRegistry = () => {
|
|||||||
const registryUrl = form.watch("registryUrl");
|
const registryUrl = form.watch("registryUrl");
|
||||||
const registryName = form.watch("registryName");
|
const registryName = form.watch("registryName");
|
||||||
const imagePrefix = form.watch("imagePrefix");
|
const imagePrefix = form.watch("imagePrefix");
|
||||||
|
const serverId = form.watch("serverId");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.reset({
|
form.reset({
|
||||||
@@ -74,6 +83,7 @@ export const AddRegistry = () => {
|
|||||||
password: "",
|
password: "",
|
||||||
registryUrl: "",
|
registryUrl: "",
|
||||||
imagePrefix: "",
|
imagePrefix: "",
|
||||||
|
serverId: "",
|
||||||
});
|
});
|
||||||
}, [form, form.reset, form.formState.isSubmitSuccessful]);
|
}, [form, form.reset, form.formState.isSubmitSuccessful]);
|
||||||
|
|
||||||
@@ -85,6 +95,7 @@ export const AddRegistry = () => {
|
|||||||
registryUrl: data.registryUrl,
|
registryUrl: data.registryUrl,
|
||||||
registryType: "cloud",
|
registryType: "cloud",
|
||||||
imagePrefix: data.imagePrefix,
|
imagePrefix: data.imagePrefix,
|
||||||
|
serverId: data.serverId,
|
||||||
})
|
})
|
||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
await utils.registry.all.invalidate();
|
await utils.registry.all.invalidate();
|
||||||
@@ -211,34 +222,77 @@ export const AddRegistry = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter className="flex flex-row w-full sm:justify-between gap-4 flex-wrap">
|
<DialogFooter className="flex flex-col w-full sm:justify-between gap-4 flex-wrap sm:flex-col">
|
||||||
<Button
|
<div className="flex flex-col gap-4 border p-2 rounded-lg">
|
||||||
type="button"
|
<span className="text-sm text-muted-foreground">
|
||||||
variant={"secondary"}
|
Select a server to test the registry. If you don't have a
|
||||||
isLoading={isLoading}
|
server choose the default one.
|
||||||
onClick={async () => {
|
</span>
|
||||||
await testRegistry({
|
<FormField
|
||||||
username: username,
|
control={form.control}
|
||||||
password: password,
|
name="serverId"
|
||||||
registryUrl: registryUrl,
|
render={({ field }) => (
|
||||||
registryName: registryName,
|
<FormItem>
|
||||||
registryType: "cloud",
|
<FormLabel>Server (Optional)</FormLabel>
|
||||||
imagePrefix: imagePrefix,
|
<FormControl>
|
||||||
})
|
<Select
|
||||||
.then((data) => {
|
onValueChange={field.onChange}
|
||||||
if (data) {
|
defaultValue={field.value}
|
||||||
toast.success("Registry Tested Successfully");
|
>
|
||||||
} else {
|
<SelectTrigger className="w-full">
|
||||||
toast.error("Registry Test Failed");
|
<SelectValue placeholder="Select a server" />
|
||||||
}
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectLabel>Servers</SelectLabel>
|
||||||
|
{servers?.map((server) => (
|
||||||
|
<SelectItem
|
||||||
|
key={server.serverId}
|
||||||
|
value={server.serverId}
|
||||||
|
>
|
||||||
|
{server.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
<SelectItem value={"none"}>None</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant={"secondary"}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onClick={async () => {
|
||||||
|
await testRegistry({
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
registryUrl: registryUrl,
|
||||||
|
registryName: registryName,
|
||||||
|
registryType: "cloud",
|
||||||
|
imagePrefix: imagePrefix,
|
||||||
|
serverId: serverId,
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.then((data) => {
|
||||||
toast.error("Error to test the registry");
|
if (data) {
|
||||||
});
|
toast.success("Registry Tested Successfully");
|
||||||
}}
|
} else {
|
||||||
>
|
toast.error("Registry Test Failed");
|
||||||
Test Registry
|
}
|
||||||
</Button>
|
})
|
||||||
|
.catch(() => {
|
||||||
|
toast.error("Error to test the registry");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Test Registry
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button isLoading={form.formState.isSubmitting} type="submit">
|
<Button isLoading={form.formState.isSubmitting} type="submit">
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ import {
|
|||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectLabel,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@@ -34,10 +43,9 @@ const updateRegistry = z.object({
|
|||||||
message: "Username is required",
|
message: "Username is required",
|
||||||
}),
|
}),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
registryUrl: z.string().min(1, {
|
registryUrl: z.string(),
|
||||||
message: "Registry URL is required",
|
|
||||||
}),
|
|
||||||
imagePrefix: z.string(),
|
imagePrefix: z.string(),
|
||||||
|
serverId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type UpdateRegistry = z.infer<typeof updateRegistry>;
|
type UpdateRegistry = z.infer<typeof updateRegistry>;
|
||||||
@@ -48,6 +56,8 @@ interface Props {
|
|||||||
|
|
||||||
export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
|
const { data: servers } = api.server.withSSHKey.useQuery();
|
||||||
|
|
||||||
const { mutateAsync: testRegistry, isLoading } =
|
const { mutateAsync: testRegistry, isLoading } =
|
||||||
api.registry.testRegistry.useMutation();
|
api.registry.testRegistry.useMutation();
|
||||||
const { data, refetch } = api.registry.one.useQuery(
|
const { data, refetch } = api.registry.one.useQuery(
|
||||||
@@ -69,15 +79,19 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
registryUrl: "",
|
registryUrl: "",
|
||||||
|
serverId: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(updateRegistry),
|
resolver: zodResolver(updateRegistry),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(form.formState.errors);
|
||||||
|
|
||||||
const password = form.watch("password");
|
const password = form.watch("password");
|
||||||
const username = form.watch("username");
|
const username = form.watch("username");
|
||||||
const registryUrl = form.watch("registryUrl");
|
const registryUrl = form.watch("registryUrl");
|
||||||
const registryName = form.watch("registryName");
|
const registryName = form.watch("registryName");
|
||||||
const imagePrefix = form.watch("imagePrefix");
|
const imagePrefix = form.watch("imagePrefix");
|
||||||
|
const serverId = form.watch("serverId");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -87,6 +101,7 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
username: data.username || "",
|
username: data.username || "",
|
||||||
password: "",
|
password: "",
|
||||||
registryUrl: data.registryUrl || "",
|
registryUrl: data.registryUrl || "",
|
||||||
|
serverId: "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [form, form.reset, data]);
|
}, [form, form.reset, data]);
|
||||||
@@ -99,6 +114,7 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
username: data.username,
|
username: data.username,
|
||||||
registryUrl: data.registryUrl,
|
registryUrl: data.registryUrl,
|
||||||
imagePrefix: data.imagePrefix,
|
imagePrefix: data.imagePrefix,
|
||||||
|
serverId: data.serverId,
|
||||||
})
|
})
|
||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
toast.success("Registry Updated");
|
toast.success("Registry Updated");
|
||||||
@@ -224,13 +240,47 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<DialogFooter
|
<DialogFooter className="flex flex-col w-full sm:justify-between gap-4 flex-wrap sm:flex-col">
|
||||||
className={cn(
|
<div className="flex flex-col gap-4 border p-2 rounded-lg">
|
||||||
isCloud ? "sm:justify-between " : "",
|
<span className="text-sm text-muted-foreground">
|
||||||
"flex flex-row w-full gap-4 flex-wrap",
|
Select a server to test the registry. If you don't have a server
|
||||||
)}
|
choose the default one.
|
||||||
>
|
</span>
|
||||||
{isCloud && (
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="serverId"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Server (Optional)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
defaultValue={field.value}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full">
|
||||||
|
<SelectValue placeholder="Select a server" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectLabel>Servers</SelectLabel>
|
||||||
|
{servers?.map((server) => (
|
||||||
|
<SelectItem
|
||||||
|
key={server.serverId}
|
||||||
|
value={server.serverId}
|
||||||
|
>
|
||||||
|
{server.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
<SelectItem value={"none"}>None</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant={"secondary"}
|
variant={"secondary"}
|
||||||
@@ -243,6 +293,7 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
registryName: registryName,
|
registryName: registryName,
|
||||||
registryType: "cloud",
|
registryType: "cloud",
|
||||||
imagePrefix: imagePrefix,
|
imagePrefix: imagePrefix,
|
||||||
|
serverId: serverId,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -258,12 +309,12 @@ export const UpdateDockerRegistry = ({ registryId }: Props) => {
|
|||||||
>
|
>
|
||||||
Test Registry
|
Test Registry
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
isLoading={form.formState.isSubmitting}
|
isLoading={form.formState.isSubmitting}
|
||||||
form="hook-form"
|
|
||||||
type="submit"
|
type="submit"
|
||||||
|
form="hook-form"
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
1
apps/dokploy/drizzle/0038_rapid_landau.sql
Normal file
1
apps/dokploy/drizzle/0038_rapid_landau.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "registry" ALTER COLUMN "registryUrl" SET DEFAULT '';
|
||||||
3824
apps/dokploy/drizzle/meta/0038_snapshot.json
Normal file
3824
apps/dokploy/drizzle/meta/0038_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -267,6 +267,13 @@
|
|||||||
"when": 1726988289562,
|
"when": 1726988289562,
|
||||||
"tag": "0037_legal_namor",
|
"tag": "0037_legal_namor",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 38,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1727942090102,
|
||||||
|
"tag": "0038_rapid_landau",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
apiUpdateRegistry,
|
apiUpdateRegistry,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { initializeRegistry } from "@/server/setup/registry-setup";
|
import { initializeRegistry } from "@/server/setup/registry-setup";
|
||||||
import { execAsync } from "@/server/utils/process/execAsync";
|
import { execAsync, execAsyncRemote } from "@/server/utils/process/execAsync";
|
||||||
import { manageRegistry } from "@/server/utils/traefik/registry";
|
import { manageRegistry } from "@/server/utils/traefik/registry";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import {
|
import {
|
||||||
@@ -58,7 +58,13 @@ export const registryRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
try {
|
try {
|
||||||
const loginCommand = `echo ${input.password} | docker login ${input.registryUrl} --username ${input.username} --password-stdin`;
|
const loginCommand = `echo ${input.password} | docker login ${input.registryUrl} --username ${input.username} --password-stdin`;
|
||||||
await execAsync(loginCommand);
|
|
||||||
|
if (input.serverId && input.serverId !== "none") {
|
||||||
|
await execAsyncRemote(input.serverId, loginCommand);
|
||||||
|
} else {
|
||||||
|
await execAsync(loginCommand);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error Registry:", error);
|
console.log("Error Registry:", error);
|
||||||
@@ -78,6 +84,7 @@ export const registryRouter = createTRPCRouter({
|
|||||||
? input.registryUrl
|
? input.registryUrl
|
||||||
: "dokploy-registry.docker.localhost",
|
: "dokploy-registry.docker.localhost",
|
||||||
imagePrefix: null,
|
imagePrefix: null,
|
||||||
|
serverId: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manageRegistry(selfHostedRegistry);
|
await manageRegistry(selfHostedRegistry);
|
||||||
@@ -86,3 +93,17 @@ export const registryRouter = createTRPCRouter({
|
|||||||
return selfHostedRegistry;
|
return selfHostedRegistry;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const shellEscape = (str: string) => {
|
||||||
|
const ret = [];
|
||||||
|
let s = str;
|
||||||
|
if (/[^A-Za-z0-9_\/:=-]/.test(s)) {
|
||||||
|
s = `'${s.replace(/'/g, "'\\''")}'`;
|
||||||
|
s = s
|
||||||
|
.replace(/^(?:'')+/g, "") // unduplicate single-quote at the beginning
|
||||||
|
.replace(/\\'''/g, "\\'"); // remove non-escaped single-quote if there are enclosed between 2 escaped
|
||||||
|
}
|
||||||
|
ret.push(s);
|
||||||
|
|
||||||
|
return ret.join(" ");
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { db } from "@/server/db";
|
|||||||
import { type apiCreateRegistry, registry } from "@/server/db/schema";
|
import { type apiCreateRegistry, registry } from "@/server/db/schema";
|
||||||
import { initializeRegistry } from "@/server/setup/registry-setup";
|
import { initializeRegistry } from "@/server/setup/registry-setup";
|
||||||
import { removeService } from "@/server/utils/docker/utils";
|
import { removeService } from "@/server/utils/docker/utils";
|
||||||
import { execAsync } from "@/server/utils/process/execAsync";
|
import { execAsync, execAsyncRemote } from "@/server/utils/process/execAsync";
|
||||||
import {
|
import {
|
||||||
manageRegistry,
|
manageRegistry,
|
||||||
removeSelfHostedRegistry,
|
removeSelfHostedRegistry,
|
||||||
@@ -32,9 +32,10 @@ export const createRegistry = async (input: typeof apiCreateRegistry._type) => {
|
|||||||
message: "Error input: Inserting registry",
|
message: "Error input: Inserting registry",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const loginCommand = `echo ${input.password} | docker login ${input.registryUrl} --username ${input.username} --password-stdin`;
|
||||||
if (newRegistry.registryType === "cloud") {
|
if (input.serverId && input.serverId !== "none") {
|
||||||
const loginCommand = `echo ${input.password} | docker login ${input.registryUrl} --username ${input.username} --password-stdin`;
|
await execAsyncRemote(input.serverId, loginCommand);
|
||||||
|
} else if (newRegistry.registryType === "cloud") {
|
||||||
await execAsync(loginCommand);
|
await execAsync(loginCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ export const removeRegistry = async (registryId: string) => {
|
|||||||
|
|
||||||
export const updateRegistry = async (
|
export const updateRegistry = async (
|
||||||
registryId: string,
|
registryId: string,
|
||||||
registryData: Partial<Registry>,
|
registryData: Partial<Registry> & { serverId?: string | null },
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const response = await db
|
const response = await db
|
||||||
@@ -92,6 +93,13 @@ export const updateRegistry = async (
|
|||||||
await manageRegistry(response);
|
await manageRegistry(response);
|
||||||
await initializeRegistry(response.username, response.password);
|
await initializeRegistry(response.username, response.password);
|
||||||
}
|
}
|
||||||
|
const loginCommand = `echo ${response?.password} | docker login ${response?.registryUrl} --username ${response?.username} --password-stdin`;
|
||||||
|
|
||||||
|
if (registryData?.serverId && registryData?.serverId !== "none") {
|
||||||
|
await execAsyncRemote(registryData.serverId, loginCommand);
|
||||||
|
} else if (response?.registryType === "cloud") {
|
||||||
|
await execAsync(loginCommand);
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const registry = pgTable("registry", {
|
|||||||
imagePrefix: text("imagePrefix"),
|
imagePrefix: text("imagePrefix"),
|
||||||
username: text("username").notNull(),
|
username: text("username").notNull(),
|
||||||
password: text("password").notNull(),
|
password: text("password").notNull(),
|
||||||
registryUrl: text("registryUrl").notNull(),
|
registryUrl: text("registryUrl").notNull().default(""),
|
||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
@@ -45,7 +45,7 @@ const createSchema = createInsertSchema(registry, {
|
|||||||
registryName: z.string().min(1),
|
registryName: z.string().min(1),
|
||||||
username: z.string().min(1),
|
username: z.string().min(1),
|
||||||
password: z.string().min(1),
|
password: z.string().min(1),
|
||||||
registryUrl: z.string().min(1),
|
registryUrl: z.string(),
|
||||||
adminId: z.string().min(1),
|
adminId: z.string().min(1),
|
||||||
registryId: z.string().min(1),
|
registryId: z.string().min(1),
|
||||||
registryType: z.enum(["selfHosted", "cloud"]),
|
registryType: z.enum(["selfHosted", "cloud"]),
|
||||||
@@ -62,7 +62,10 @@ export const apiCreateRegistry = createSchema
|
|||||||
registryType: z.enum(["selfHosted", "cloud"]),
|
registryType: z.enum(["selfHosted", "cloud"]),
|
||||||
imagePrefix: z.string().nullable().optional(),
|
imagePrefix: z.string().nullable().optional(),
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.extend({
|
||||||
|
serverId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const apiTestRegistry = createSchema.pick({}).extend({
|
export const apiTestRegistry = createSchema.pick({}).extend({
|
||||||
registryName: z.string().min(1),
|
registryName: z.string().min(1),
|
||||||
@@ -71,6 +74,7 @@ export const apiTestRegistry = createSchema.pick({}).extend({
|
|||||||
registryUrl: z.string(),
|
registryUrl: z.string(),
|
||||||
registryType: z.enum(["selfHosted", "cloud"]),
|
registryType: z.enum(["selfHosted", "cloud"]),
|
||||||
imagePrefix: z.string().nullable().optional(),
|
imagePrefix: z.string().nullable().optional(),
|
||||||
|
serverId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiRemoveRegistry = createSchema
|
export const apiRemoveRegistry = createSchema
|
||||||
@@ -87,6 +91,7 @@ export const apiFindOneRegistry = createSchema
|
|||||||
|
|
||||||
export const apiUpdateRegistry = createSchema.partial().extend({
|
export const apiUpdateRegistry = createSchema.partial().extend({
|
||||||
registryId: z.string().min(1),
|
registryId: z.string().min(1),
|
||||||
|
serverId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiEnableSelfHostedRegistry = createSchema
|
export const apiEnableSelfHostedRegistry = createSchema
|
||||||
|
|||||||
Reference in New Issue
Block a user