File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
apps/dokploy/server/api/routers
packages/server/src/services Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 88 findEnvironmentById ,
99 findPostgresById ,
1010 findProjectById ,
11+ getMountPath ,
1112 IS_CLOUD ,
1213 rebuildDatabase ,
1314 removePostgresById ,
@@ -37,6 +38,7 @@ import {
3738 postgres as postgresTable ,
3839} from "@/server/db/schema" ;
3940import { cancelJobs } from "@/server/utils/backup" ;
41+
4042export const postgresRouter = createTRPCRouter ( {
4143 create : protectedProcedure
4244 . input ( apiCreatePostgres )
@@ -79,11 +81,13 @@ export const postgresRouter = createTRPCRouter({
7981 ) ;
8082 }
8183
84+ const mountPath = getMountPath ( input . dockerImage ) ;
85+
8286 await createMount ( {
8387 serviceId : newPostgres . postgresId ,
8488 serviceType : "postgres" ,
8589 volumeName : `${ newPostgres . appName } -data` ,
86- mountPath : "/var/lib/postgresql/data" ,
90+ mountPath : mountPath ,
8791 type : "volume" ,
8892 } ) ;
8993
@@ -367,6 +371,7 @@ export const postgresRouter = createTRPCRouter({
367371 message : "You are not authorized to update this Postgres" ,
368372 } ) ;
369373 }
374+
370375 const service = await updatePostgresById ( postgresId , {
371376 ...rest ,
372377 } ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server";
1313import { eq , getTableColumns } from "drizzle-orm" ;
1414import { validUniqueServerAppName } from "./project" ;
1515
16+ export function getMountPath ( dockerImage : string ) : string {
17+ const versionMatch = dockerImage . match ( / p o s t g r e s : ( \d + ) / ) ;
18+
19+ if ( versionMatch ?. [ 1 ] ) {
20+ const version = Number . parseInt ( versionMatch [ 1 ] , 10 ) ;
21+ if ( version >= 18 ) {
22+ return `/var/lib/postgresql/${ version } /data` ;
23+ }
24+ }
25+ return "/var/lib/postgresql/data" ;
26+ }
27+
1628export type Postgres = typeof postgres . $inferSelect ;
1729
1830export const createPostgres = async ( input : typeof apiCreatePostgres . _type ) => {
You can’t perform that action at this time.
0 commit comments