@@ -27,7 +27,7 @@ public function getRootVolume(Config $config, bool $isReadOnly): array
2727
2828 return [
2929 $ this ->getMagentoVolume ($ config ) => [
30- 'path ' => BuilderInterface::DIR_MAGENTO ,
30+ 'target ' => BuilderInterface::TARGET_ROOT ,
3131 'volume ' => '/ ' ,
3232 'mode ' => $ mode
3333 ]
@@ -44,7 +44,7 @@ public function getDevVolumes(Config $config, bool $hasTest): array
4444 if ($ hasTest ) {
4545 return [
4646 $ this ->getMagentoDevVolume ($ config ) => [
47- 'path ' => BuilderInterface::DIR_MAGENTO . '/dev ' ,
47+ 'target ' => BuilderInterface::TARGET_ROOT . '/dev ' ,
4848 'volume ' => '/dev ' ,
4949 'mode ' => 'rw,delegated '
5050 ]
@@ -55,25 +55,35 @@ public function getDevVolumes(Config $config, bool $hasTest): array
5555 }
5656
5757 /**
58+ * @param Config $config
5859 * @param bool $isReadOnly
5960 * @param bool $hasGenerated
6061 * @return array
62+ * @throws ConfigurationMismatchException
6163 */
62- public function getDefaultMagentoVolumes (bool $ isReadOnly , bool $ hasGenerated = true ): array
64+ public function getDefaultMagentoVolumes (Config $ config , bool $ isReadOnly , bool $ hasGenerated = true ): array
6365 {
6466 $ mode = $ isReadOnly ? 'ro,delegated ' : 'rw,delegated ' ;
6567
6668 $ volumes = [
67- BuilderInterface::VOLUME_MAGENTO_VENDOR => [
68- 'path ' => BuilderInterface::DIR_MAGENTO . '/vendor ' ,
69+ $ this ->getVolume (
70+ $ config ,
71+ BuilderInterface::VOLUME_MAGENTO_VENDOR ,
72+ BuilderInterface::VOLUME_MAGENTO_VENDOR
73+ ) => [
74+ 'target ' => BuilderInterface::TARGET_ROOT . '/vendor ' ,
6975 'volume ' => '/vendor ' ,
7076 'mode ' => $ mode ,
7177 ]
7278 ];
7379
7480 if ($ hasGenerated ) {
75- $ volumes [BuilderInterface::VOLUME_MAGENTO_GENERATED ] = [
76- 'path ' => BuilderInterface::DIR_MAGENTO . '/generated ' ,
81+ $ volumes [$ this ->getVolume (
82+ $ config ,
83+ BuilderInterface::VOLUME_MAGENTO_GENERATED ,
84+ BuilderInterface::VOLUME_MAGENTO_GENERATED
85+ )] = [
86+ 'target ' => BuilderInterface::TARGET_ROOT . '/generated ' ,
7787 'volume ' => '/generated ' ,
7888 'mode ' => $ mode
7989 ];
@@ -83,24 +93,23 @@ public function getDefaultMagentoVolumes(bool $isReadOnly, bool $hasGenerated =
8393 }
8494
8595 /**
86- * @param array $mounts
96+ * @param Config $config
8797 * @param bool $isReadOnly
8898 * @param bool $hasGenerated
89- * @return array
99+ * @return string[][]
100+ * @throws ConfigurationMismatchException
90101 */
91102 public function getMagentoVolumes (
92- array $ mounts ,
103+ Config $ config ,
93104 bool $ isReadOnly ,
94105 bool $ hasGenerated = true
95106 ): array {
96- $ volumes = $ this ->getDefaultMagentoVolumes ($ isReadOnly , $ hasGenerated );
107+ $ volumes = $ this ->getDefaultMagentoVolumes ($ config , $ isReadOnly , $ hasGenerated );
97108
98- foreach ($ mounts as $ volumeData ) {
109+ foreach ($ config -> getMounts () as $ name => $ volumeData ) {
99110 $ path = $ volumeData ['path ' ];
100- $ volumeName = 'magento- ' . str_replace ('/ ' , '- ' , $ path );
101-
102- $ volumes [$ volumeName ] = [
103- 'path ' => BuilderInterface::DIR_MAGENTO . '/ ' . $ path ,
111+ $ volumes [$ this ->getVolume ($ config , $ name , $ path )] = [
112+ 'target ' => BuilderInterface::TARGET_ROOT . '/ ' . $ path ,
104113 'volume ' => '/ ' . $ path ,
105114 'mode ' => 'rw,delegated '
106115 ];
@@ -116,7 +125,7 @@ public function getComposerVolumes(): array
116125 {
117126 return [
118127 '~/.composer/cache ' => [
119- 'path ' => '/root/.composer/cache ' ,
128+ 'target ' => '/root/.composer/cache ' ,
120129 'mode ' => 'rw,delegated '
121130 ]
122131 ];
@@ -131,7 +140,7 @@ public function getMountVolumes(bool $hasTmpMounts): array
131140 if ($ hasTmpMounts ) {
132141 return [
133142 BuilderInterface::VOLUME_DOCKER_MNT => [
134- 'path ' => '/mnt ' ,
143+ 'target ' => '/mnt ' ,
135144 'mode ' => 'rw,delegated '
136145 ],
137146 ];
@@ -154,7 +163,7 @@ public function normalize(array $volumes): array
154163 $ normalized [] = sprintf (
155164 '%s:%s:%s ' ,
156165 $ name ,
157- $ config ['path ' ],
166+ $ config ['target ' ],
158167 $ config ['mode ' ] ?? 'rw,delegated '
159168 );
160169 }
@@ -181,4 +190,20 @@ public function getMagentoDevVolume(Config $config): string
181190 {
182191 return $ config ->getRootDirectory () . '/dev ' ;
183192 }
193+
194+ /**
195+ * @param Config $config
196+ * @param string $name
197+ * @param string $path
198+ * @return string
199+ * @throws ConfigurationMismatchException
200+ */
201+ private function getVolume (Config $ config , string $ name , string $ path ): string
202+ {
203+ if ($ config ->getSyncEngine () === BuilderInterface::SYNC_ENGINE_NATIVE ) {
204+ return $ config ->getRootDirectory () . '/ ' . $ path ;
205+ }
206+
207+ return $ config ->getNameWithPrefix () . str_replace ('/ ' , '- ' , $ name );
208+ }
184209}
0 commit comments