mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-26 09:35:29 +02:00
Merge pull request #3048 from Bima42/fix/update-pg-data-path
fix: update pg data path for latest docker version
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
findEnvironmentById,
|
||||
findPostgresById,
|
||||
findProjectById,
|
||||
getMountPath,
|
||||
IS_CLOUD,
|
||||
rebuildDatabase,
|
||||
removePostgresById,
|
||||
@@ -37,6 +38,7 @@ import {
|
||||
postgres as postgresTable,
|
||||
} from "@/server/db/schema";
|
||||
import { cancelJobs } from "@/server/utils/backup";
|
||||
|
||||
export const postgresRouter = createTRPCRouter({
|
||||
create: protectedProcedure
|
||||
.input(apiCreatePostgres)
|
||||
@@ -79,11 +81,13 @@ export const postgresRouter = createTRPCRouter({
|
||||
);
|
||||
}
|
||||
|
||||
const mountPath = getMountPath(input.dockerImage);
|
||||
|
||||
await createMount({
|
||||
serviceId: newPostgres.postgresId,
|
||||
serviceType: "postgres",
|
||||
volumeName: `${newPostgres.appName}-data`,
|
||||
mountPath: "/var/lib/postgresql/data",
|
||||
mountPath: mountPath,
|
||||
type: "volume",
|
||||
});
|
||||
|
||||
@@ -367,6 +371,7 @@ export const postgresRouter = createTRPCRouter({
|
||||
message: "You are not authorized to update this Postgres",
|
||||
});
|
||||
}
|
||||
|
||||
const service = await updatePostgresById(postgresId, {
|
||||
...rest,
|
||||
});
|
||||
|
||||
@@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export function getMountPath(dockerImage: string): string {
|
||||
const versionMatch = dockerImage.match(/postgres:(\d+)/);
|
||||
|
||||
if (versionMatch?.[1]) {
|
||||
const version = Number.parseInt(versionMatch[1], 10);
|
||||
if (version >= 18) {
|
||||
return `/var/lib/postgresql/${version}/data`;
|
||||
}
|
||||
}
|
||||
return "/var/lib/postgresql/data";
|
||||
}
|
||||
|
||||
export type Postgres = typeof postgres.$inferSelect;
|
||||
|
||||
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
||||
|
||||
Reference in New Issue
Block a user