Skip to content

Commit 5084a84

Browse files
committed
update devcontainer.json to execute our init .sh file
1 parent 9572d8d commit 5084a84

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.devcontainer/devcontainer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"name": "laravel9-mongodb-tutorial",
3+
24
// Mandatory definition for .devcontainer
35
//
46
// which service AS DEFINED IN .devcontainer/docker-compose.yml
@@ -10,6 +12,8 @@
1012
// so we'll use a compose .yml file instead of defining the services in devcontainer.json
1113
"dockerComposeFile": "./docker-compose.yml",
1214

15+
"shutdownAction": "stopCompose",
16+
1317
// Mandatory definition for .devcontainer
1418
//
1519
// workspaceFolder describes the CONTAINER folder
@@ -37,5 +41,8 @@
3741
}
3842
},
3943

40-
"forwardPorts": [80]
44+
"forwardPorts": [80],
45+
46+
// execute our one-time repo init if /vendor/ does not exist
47+
"postCreateCommand": "sh init_repo.sh"
4148
}

src/routes/api.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
return ['msg' => $msg];
5353
});
5454

55+
/*
56+
Laravel check on the MySQL connection
57+
*/
58+
Route::get('/test_mysql/', function (Request $request) {
59+
try {
60+
DB::connection()->getPdo();
61+
return ['status' => 'executed', 'data' => 'Successfully connected to the DB.' ];
62+
} catch (\Exception $e) {
63+
return ['status' => 'FAIL. exception', 'data' => $e ];
64+
}
65+
});
66+
5567
/*
5668
Create a new "customer" in our SQL database
5769
This is just to show the code looks identical to the MongoDB version
@@ -263,17 +275,4 @@
263275
$result = DB::connection('mongodb')->getCollection('laracoll')->createIndex($indexKeys, $indexOptions);
264276

265277
return ['status' => 'executed', 'data' => $result ];
266-
});
267-
268-
269-
/*
270-
Laravel check on the MySQL connection
271-
*/
272-
Route::get('/test_mysql/', function (Request $request) {
273-
try {
274-
DB::connection()->getPdo();
275-
return ['status' => 'executed', 'data' => 'Successfully connected to the DB.' ];
276-
} catch (\Exception $e) {
277-
return ['status' => 'FAIL. exception', 'data' => $e ];
278-
}
279278
});

0 commit comments

Comments
 (0)