@@ -33,8 +33,16 @@ services:
3333volumes:
3434 test-data:
3535` ,
36+ composeId : "compose-1" ,
37+ name : "raw-stack" ,
3638 composePath : "./docker-compose.yml" ,
3739 composeType : "stack" ,
40+ environment : {
41+ environmentId : "env-1" ,
42+ name : "production" ,
43+ projectId : "project-1" ,
44+ project : { name : "shop" , organizationId : "org-1" } ,
45+ } ,
3846 isolatedDeployment : false ,
3947 isolatedDeploymentsVolume : false ,
4048 randomize : false ,
@@ -54,6 +62,72 @@ volumes:
5462 } ,
5563 ] ) ;
5664 expect ( converted ?. services ?. test ?. tmpfs ) . toEqual ( [ "/cache" ] ) ;
65+ expect ( converted ?. services ?. test ?. labels ) . toEqual (
66+ expect . arrayContaining ( [
67+ "dokploy.organization.id=org-1" ,
68+ "dokploy.project=shop" ,
69+ "dokploy.service=test" ,
70+ ] ) ,
71+ ) ;
72+ expect ( converted ?. services ?. test ?. deploy ?. labels ) . toEqual (
73+ expect . arrayContaining ( [ "dokploy.organization.id=org-1" ] ) ,
74+ ) ;
5775 expect ( execAsyncRemote ) . not . toHaveBeenCalled ( ) ;
5876 } ) ;
77+
78+ it ( "escapes `$` in the Dokploy label values so compose keeps them literal" , async ( ) => {
79+ const compose = {
80+ appName : "dollar-stack" ,
81+ composeFile : `
82+ services:
83+ mapped:
84+ image: alpine:latest
85+ labels:
86+ custom: keep
87+ deploy:
88+ labels:
89+ custom: keep
90+ listed:
91+ image: alpine:latest
92+ labels:
93+ - custom=keep
94+ ` ,
95+ composeId : "compose-1" ,
96+ name : "app $DB_PASSWORD" ,
97+ composePath : "./docker-compose.yml" ,
98+ composeType : "stack" ,
99+ environment : {
100+ environmentId : "env-1" ,
101+ name : "env ${HOME}" ,
102+ projectId : "project-1" ,
103+ project : { name : "Budget $100" , organizationId : "org-1" } ,
104+ } ,
105+ isolatedDeployment : false ,
106+ isolatedDeploymentsVolume : false ,
107+ randomize : false ,
108+ serverId : null ,
109+ sourceType : "raw" ,
110+ suffix : "" ,
111+ } as unknown as Parameters < typeof addDomainToCompose > [ 0 ] ;
112+
113+ const converted = await addDomainToCompose ( compose , [ ] ) ;
114+ const escaped = {
115+ "dokploy.project" : "Budget $$100" ,
116+ "dokploy.environment" : "env $${HOME}" ,
117+ "dokploy.application" : "app $$DB_PASSWORD" ,
118+ } ;
119+
120+ const mapped = converted ?. services ?. mapped ;
121+ expect ( mapped ?. labels ) . toMatchObject ( { custom : "keep" , ...escaped } ) ;
122+ expect ( mapped ?. deploy ?. labels ) . toMatchObject ( {
123+ custom : "keep" ,
124+ ...escaped ,
125+ } ) ;
126+ const listed = converted ?. services ?. listed ;
127+ const asList = Object . entries ( escaped ) . map ( ( [ k , v ] ) => `${ k } =${ v } ` ) ;
128+ expect ( listed ?. labels ) . toEqual (
129+ expect . arrayContaining ( [ "custom=keep" , ...asList ] ) ,
130+ ) ;
131+ expect ( listed ?. deploy ?. labels ) . toEqual ( expect . arrayContaining ( asList ) ) ;
132+ } ) ;
59133} ) ;
0 commit comments