@@ -130,8 +130,7 @@ public function build(Repository $config): array
130
130
[
131
131
'ports ' => [9000 ],
132
132
'depends_on ' => ['db ' ],
133
- 'volumes_from ' => ['appdata ' ],
134
- 'volumes ' => [$ this ->getMagentoVolume (true )],
133
+ 'volumes ' => $ this ->getMagentoVolumes (true ),
135
134
'env_file ' => [
136
135
'./docker/global.env ' ,
137
136
'./docker/config.env ' ,
@@ -145,33 +144,33 @@ public function build(Repository $config): array
145
144
$ config ->get (self ::NGINX_VERSION , self ::DEFAULT_NGINX_VERSION ),
146
145
[
147
146
'depends_on ' => ['fpm ' , 'db ' ],
148
- 'volumes_from ' => ['appdata ' ],
149
- 'volumes ' => [
150
- $ this ->getMagentoVolume (true ),
151
- ],
147
+ 'volumes ' => $ this ->getMagentoVolumes (true ),
152
148
'env_file ' => [
153
149
'./docker/global.env ' ,
154
150
'./docker/config.env ' ,
155
151
],
156
152
]
157
153
);
158
154
$ services ['cron ' ] = $ this ->getCronCliService ($ phpVersion , true , $ cliDepends , 'cron.magento2.docker ' );
159
- $ services ['appdata ' ] = [
160
- 'image ' => 'tianon/true ' ,
161
- 'volumes ' => [
162
- './docker/mnt:/mnt ' ,
163
- self ::DIR_MAGENTO . '/var ' ,
164
- self ::DIR_MAGENTO . '/app/etc ' ,
165
- self ::DIR_MAGENTO . '/pub/static ' ,
166
- self ::DIR_MAGENTO . '/pub/media ' ,
167
- self ::DIR_MAGENTO . '/vendor ' ,
168
- self ::DIR_MAGENTO . '/generated '
169
- ],
155
+
156
+ $ volumeConfig = [
157
+ 'driver_opts ' => [
158
+ 'type ' => 'tmpfs ' ,
159
+ 'device ' => 'tmpfs '
160
+ ]
170
161
];
171
162
172
163
return [
173
- 'version ' => '2 ' ,
164
+ 'version ' => '3 ' ,
174
165
'services ' => $ services ,
166
+ 'volumes ' => [
167
+ 'magento-vendor ' => $ volumeConfig ,
168
+ 'magento-generated ' => $ volumeConfig ,
169
+ 'magento-var ' => $ volumeConfig ,
170
+ 'magento-etc ' => $ volumeConfig ,
171
+ 'magento-static ' => $ volumeConfig ,
172
+ 'magento-media ' => $ volumeConfig ,
173
+ ]
175
174
];
176
175
}
177
176
@@ -185,13 +184,46 @@ public function getConfigPath(): string
185
184
186
185
/**
187
186
* @param bool $isReadOnly
188
- * @return string
187
+ * @return array
189
188
*/
190
- private function getMagentoVolume (bool $ isReadOnly ): string
189
+ private function getMagentoVolumes (bool $ isReadOnly ): array
191
190
{
192
- $ volume = '.: ' . self ::DIR_MAGENTO ;
191
+ $ flag = $ isReadOnly ? ':ro ' : ':rw ' ;
192
+
193
+ return [
194
+ './: ' . self ::DIR_MAGENTO . $ flag ,
195
+ 'magento-vendor: ' . self ::DIR_MAGENTO . '/vendor ' . $ flag ,
196
+ 'magento-generated: ' . self ::DIR_MAGENTO . '/generated ' . $ flag ,
197
+ 'magento-var: ' . self ::DIR_MAGENTO . '/var:rw ' ,
198
+ 'magento-etc: ' . self ::DIR_MAGENTO . '/app/etc:rw ' ,
199
+ 'magento-static: ' . self ::DIR_MAGENTO . '/pub/static:rw ' ,
200
+ 'magento-media: ' . self ::DIR_MAGENTO . '/pub/media:rw ' ,
201
+ ];
202
+ }
203
+
204
+ /***
205
+ * @return array
206
+ */
207
+ private function getComposerVolumes (): array
208
+ {
209
+ $ composeCacheDirectory = file_exists (getenv ('HOME ' ) . '/.cache/composer ' )
210
+ ? '~/.cache/composer '
211
+ : '~/.composer/cache ' ;
193
212
194
- return $ isReadOnly ? $ volume . ':ro ' : $ volume . ':rw ' ;
213
+ return [
214
+ $ composeCacheDirectory . ':/root/.composer/cache ' ,
215
+ ];
216
+ }
217
+
218
+ /**
219
+ * @return array
220
+ */
221
+ private function getSharedVolumes (): array
222
+ {
223
+ return [
224
+ './docker/mnt:/mnt ' ,
225
+ './docker/tmp:/tmp '
226
+ ];
195
227
}
196
228
197
229
/**
@@ -244,21 +276,17 @@ private function getCliService(
244
276
array $ depends ,
245
277
string $ hostname
246
278
): array {
247
- $ composeCacheDirectory = file_exists (getenv ('HOME ' ) . '/.cache/composer ' )
248
- ? '~/.cache/composer '
249
- : '~/.composer/cache ' ;
250
-
251
279
$ config = $ this ->serviceFactory ->create (
252
280
ServiceFactory::SERVICE_CLI ,
253
281
$ version ,
254
282
[
255
283
'hostname ' => $ hostname ,
256
284
'depends_on ' => $ depends ,
257
- 'volumes ' => [
258
- $ composeCacheDirectory . ' :/root/.composer/cache ' ,
259
- $ this ->getMagentoVolume ( $ isReadOnly ),
260
- ],
261
- ' volumes_from ' => [ ' appdata ' ] ,
285
+ 'volumes ' => array_merge (
286
+ $ this -> getMagentoVolumes ( $ isReadOnly ) ,
287
+ $ this ->getComposerVolumes ( ),
288
+ $ this -> getSharedVolumes ()
289
+ ) ,
262
290
'env_file ' => [
263
291
'./docker/global.env ' ,
264
292
'./docker/config.env ' ,
0 commit comments