mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-21 03:18:47 +00: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,
|
findEnvironmentById,
|
||||||
findPostgresById,
|
findPostgresById,
|
||||||
findProjectById,
|
findProjectById,
|
||||||
|
getMountPath,
|
||||||
IS_CLOUD,
|
IS_CLOUD,
|
||||||
rebuildDatabase,
|
rebuildDatabase,
|
||||||
removePostgresById,
|
removePostgresById,
|
||||||
@@ -37,6 +38,7 @@ import {
|
|||||||
postgres as postgresTable,
|
postgres as postgresTable,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { cancelJobs } from "@/server/utils/backup";
|
import { cancelJobs } from "@/server/utils/backup";
|
||||||
|
|
||||||
export const postgresRouter = createTRPCRouter({
|
export const postgresRouter = createTRPCRouter({
|
||||||
create: protectedProcedure
|
create: protectedProcedure
|
||||||
.input(apiCreatePostgres)
|
.input(apiCreatePostgres)
|
||||||
@@ -79,11 +81,13 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mountPath = getMountPath(input.dockerImage);
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
serviceId: newPostgres.postgresId,
|
serviceId: newPostgres.postgresId,
|
||||||
serviceType: "postgres",
|
serviceType: "postgres",
|
||||||
volumeName: `${newPostgres.appName}-data`,
|
volumeName: `${newPostgres.appName}-data`,
|
||||||
mountPath: "/var/lib/postgresql/data",
|
mountPath: mountPath,
|
||||||
type: "volume",
|
type: "volume",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -367,6 +371,7 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
message: "You are not authorized to update this Postgres",
|
message: "You are not authorized to update this Postgres",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const service = await updatePostgresById(postgresId, {
|
const service = await updatePostgresById(postgresId, {
|
||||||
...rest,
|
...rest,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server";
|
|||||||
import { eq, getTableColumns } from "drizzle-orm";
|
import { eq, getTableColumns } from "drizzle-orm";
|
||||||
import { validUniqueServerAppName } from "./project";
|
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 type Postgres = typeof postgres.$inferSelect;
|
||||||
|
|
||||||
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user