feat: add docker registry upload

This commit is contained in:
Mauricio Siu
2024-05-13 01:18:27 -06:00
parent e9245cee2c
commit 6c792564ae
41 changed files with 18267 additions and 1072 deletions

View File

@@ -61,6 +61,7 @@ export const findApplicationById = async (applicationId: string) => {
redirects: true,
security: true,
ports: true,
registry: true,
},
});
if (!application) {

View File

@@ -2,14 +2,20 @@ import { type apiCreateRegistry, registry } from "@/server/db/schema";
import { TRPCError } from "@trpc/server";
import { db } from "@/server/db";
import { eq } from "drizzle-orm";
import { findAdmin } from "./admin";
import { removeSelfHostedRegistry } from "@/server/utils/traefik/registry";
import { removeService } from "@/server/utils/docker/utils";
export type Registry = typeof registry.$inferSelect;
export const createRegistry = async (input: typeof apiCreateRegistry._type) => {
const admin = await findAdmin();
const newRegistry = await db
.insert(registry)
.values({
...input,
adminId: admin.adminId,
})
.returning()
.then((value) => value[0]);
@@ -38,6 +44,11 @@ export const removeRegistry = async (registryId: string) => {
});
}
if (response.registryType === "selfHosted") {
await removeSelfHostedRegistry();
await removeService("dokploy-registry");
}
return response;
} catch (error) {
throw new TRPCError({
@@ -82,3 +93,8 @@ export const findRegistryById = async (registryId: string) => {
}
return registryResponse;
};
export const findAllRegistry = async () => {
const registryResponse = await db.query.registry.findMany();
return registryResponse;
};