File tree Expand file tree Collapse file tree 4 files changed +20
-12
lines changed Expand file tree Collapse file tree 4 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,21 @@ protected function buildDockerCompose(array $services)
39
39
$ composePath = base_path ('docker-compose.yml ' );
40
40
$ appService = 'laravel.test ' ;
41
41
42
- $ compose = file_exists ($ composePath )
43
- ? Yaml::parseFile ($ composePath )
44
- : Yaml::parse (str_replace (
45
- 'APP_SERVICE ' ,
46
- $ appService ,
47
- file_get_contents (Sail::baseTemplate ())
48
- ));
42
+ if (file_exists ($ composePath )) {
43
+ $ compose = Yaml::parseFile ($ composePath );
44
+ } else {
45
+ $ template = str_replace (
46
+ '{{APP}}: ' ,
47
+ $ appService .': ' ,
48
+ file_get_contents (Sail::baseTemplate ()),
49
+ $ count
50
+ );
51
+ if ($ count === 0 ) {
52
+ $ this ->error ('Missing app service in the base template. Make sure you have it with the {{APP}} placeholder. ' );
53
+ exit (1 );
54
+ }
55
+ $ compose = Yaml::parse ($ template );
56
+ }
49
57
50
58
// Prepare the installation of the "mariadb-client" package if the MariaDB service is used...
51
59
if (in_array ('mariadb ' , $ services )) {
@@ -166,7 +174,7 @@ protected function installDevContainer()
166
174
file_put_contents (
167
175
$ this ->laravel ->basePath ('.devcontainer/devcontainer.json ' ),
168
176
str_replace (
169
- 'APP_SERVICE ' ,
177
+ '{{APP}} ' ,
170
178
'laravel.test ' ,
171
179
file_get_contents (__DIR__ .'/../../../stubs/devcontainer.stub ' ) ?: ''
172
180
)
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ public function __construct()
174
174
}
175
175
176
176
/**
177
- * Set the base Docker Compose template containing a php service named as 'APP_SERVICE '
177
+ * Set the base Docker Compose template containing a php service named as '{{APP}} '
178
178
*
179
179
* @param string $stub Path to the base Docker Compose stub
180
180
* @return $this
@@ -324,7 +324,7 @@ public function isPersistent(string $service): bool
324
324
}
325
325
326
326
/**
327
- * Check if a service is required by APP_SERVICE
327
+ * Check if a service is required by {{APP}} service
328
328
*
329
329
* @param string $service
330
330
* @return bool
Original file line number Diff line number Diff line change 4
4
"dockerComposeFile": [
5
5
"../docker-compose.yml"
6
6
],
7
- "service": "APP_SERVICE ",
7
+ "service": "{{APP}} ",
8
8
"workspaceFolder": "/var/www/html",
9
9
"customizations": {
10
10
"vscode": {
Original file line number Diff line number Diff line change 1
1
# For more information: https://laravel.com/docs/sail
2
2
services:
3
- APP_SERVICE :
3
+ {{APP}} :
4
4
build:
5
5
context: ./vendor/laravel/sail/runtimes/{{PHP_VERSION}}
6
6
dockerfile: Dockerfile
You can’t perform that action at this time.
0 commit comments