質問編集履歴

1

タスクの起動順序とタスク定義のJSONを追記いたしました。

2021/11/08 07:34

投稿

uchida_yuma
uchida_yuma

スコア44

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,636 @@
36
36
 
37
37
 
38
38
 
39
+ #### 起動順序
40
+
41
+
42
+
43
+ 1. MariaDB
44
+
45
+ 2. Laravel
46
+
47
+
48
+
49
+ MariaDBがHEALTHを確認した後、Laravelが起動
50
+
51
+
52
+
53
+ ```
54
+
55
+ mysqladmin ping -u root -ppassword -h 127.0.0.1
56
+
57
+ ```
58
+
59
+
60
+
61
+ この後、Laravelコンテナ起動
62
+
63
+ ↓ 初期スクリプト
64
+
65
+
66
+
67
+ ```sh
68
+
69
+ #!/usr/bin/env bash
70
+
71
+ php artisan migrate --force
72
+
73
+ chmod -R 777 bootstrap
74
+
75
+ chmod -R 777 storage
76
+
77
+ /usr/sbin/apache2ctl -D FOREGROUND
78
+
79
+ ```
80
+
81
+
82
+
83
+ といった流れでタスクが起動していきます。
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ #### タスク定義
92
+
93
+
94
+
95
+ ```json
96
+
97
+ {
98
+
99
+ "ipcMode": null,
100
+
101
+ "executionRoleArn": "arn:aws:iam::****:role/ecsTaskExecutionRole",
102
+
103
+ "containerDefinitions": [
104
+
105
+ {
106
+
107
+ "dnsSearchDomains": null,
108
+
109
+ "environmentFiles": null,
110
+
111
+ "logConfiguration": {
112
+
113
+ "logDriver": "awslogs",
114
+
115
+ "secretOptions": null,
116
+
117
+ "options": {
118
+
119
+ "awslogs-group": "/ecs/simplememo",
120
+
121
+ "awslogs-region": "ap-northeast-1",
122
+
123
+ "awslogs-stream-prefix": "ecs"
124
+
125
+ }
126
+
127
+ },
128
+
129
+ "entryPoint": null,
130
+
131
+ "portMappings": [
132
+
133
+ {
134
+
135
+ "hostPort": 80,
136
+
137
+ "protocol": "tcp",
138
+
139
+ "containerPort": 80
140
+
141
+ }
142
+
143
+ ],
144
+
145
+ "command": null,
146
+
147
+ "linuxParameters": null,
148
+
149
+ "cpu": 0,
150
+
151
+ "environment": [],
152
+
153
+ "resourceRequirements": null,
154
+
155
+ "ulimits": null,
156
+
157
+ "dnsServers": null,
158
+
159
+ "mountPoints": [],
160
+
161
+ "workingDirectory": null,
162
+
163
+ "secrets": null,
164
+
165
+ "dockerSecurityOptions": null,
166
+
167
+ "memory": null,
168
+
169
+ "memoryReservation": 128,
170
+
171
+ "volumesFrom": [],
172
+
173
+ "stopTimeout": null,
174
+
175
+ "image": "****.dkr.ecr.ap-northeast-1.amazonaws.com/laravelecs:latest",
176
+
177
+ "startTimeout": null,
178
+
179
+ "firelensConfiguration": null,
180
+
181
+ "dependsOn": [
182
+
183
+ {
184
+
185
+ "containerName": "mariadb",
186
+
187
+ "condition": "HEALTHY"
188
+
189
+ }
190
+
191
+ ],
192
+
193
+ "disableNetworking": null,
194
+
195
+ "interactive": null,
196
+
197
+ "healthCheck": null,
198
+
199
+ "essential": true,
200
+
201
+ "links": null,
202
+
203
+ "hostname": null,
204
+
205
+ "extraHosts": null,
206
+
207
+ "pseudoTerminal": null,
208
+
209
+ "user": null,
210
+
211
+ "readonlyRootFilesystem": null,
212
+
213
+ "dockerLabels": null,
214
+
215
+ "systemControls": null,
216
+
217
+ "privileged": null,
218
+
219
+ "name": "laravel"
220
+
221
+ },
222
+
223
+ {
224
+
225
+ "dnsSearchDomains": null,
226
+
227
+ "environmentFiles": null,
228
+
229
+ "logConfiguration": {
230
+
231
+ "logDriver": "awslogs",
232
+
233
+ "secretOptions": null,
234
+
235
+ "options": {
236
+
237
+ "awslogs-group": "/ecs/simplememo",
238
+
239
+ "awslogs-region": "ap-northeast-1",
240
+
241
+ "awslogs-stream-prefix": "ecs"
242
+
243
+ }
244
+
245
+ },
246
+
247
+ "entryPoint": null,
248
+
249
+ "portMappings": [
250
+
251
+ {
252
+
253
+ "hostPort": 3306,
254
+
255
+ "protocol": "tcp",
256
+
257
+ "containerPort": 3306
258
+
259
+ }
260
+
261
+ ],
262
+
263
+ "command": null,
264
+
265
+ "linuxParameters": null,
266
+
267
+ "cpu": 0,
268
+
269
+ "environment": [
270
+
271
+ {
272
+
273
+ "name": "MYSQL_DATABASE",
274
+
275
+ "value": "simplememo"
276
+
277
+ },
278
+
279
+ {
280
+
281
+ "name": "MYSQL_PASSWORD",
282
+
283
+ "value": "simplememodbuser"
284
+
285
+ },
286
+
287
+ {
288
+
289
+ "name": "MYSQL_ROOT_PASSWORD",
290
+
291
+ "value": "password"
292
+
293
+ },
294
+
295
+ {
296
+
297
+ "name": "MYSQL_USER",
298
+
299
+ "value": "dbuser"
300
+
301
+ }
302
+
303
+ ],
304
+
305
+ "resourceRequirements": null,
306
+
307
+ "ulimits": null,
308
+
309
+ "dnsServers": null,
310
+
311
+ "mountPoints": [
312
+
313
+ {
314
+
315
+ "readOnly": null,
316
+
317
+ "containerPath": "/var/lib/mysql/simplememo",
318
+
319
+ "sourceVolume": "efs"
320
+
321
+ }
322
+
323
+ ],
324
+
325
+ "workingDirectory": null,
326
+
327
+ "secrets": null,
328
+
329
+ "dockerSecurityOptions": null,
330
+
331
+ "memory": null,
332
+
333
+ "memoryReservation": 256,
334
+
335
+ "volumesFrom": [],
336
+
337
+ "stopTimeout": null,
338
+
339
+ "image": "******.dkr.ecr.ap-northeast-1.amazonaws.com/mariadbecs:latest",
340
+
341
+ "startTimeout": null,
342
+
343
+ "firelensConfiguration": null,
344
+
345
+ "dependsOn": null,
346
+
347
+ "disableNetworking": null,
348
+
349
+ "interactive": null,
350
+
351
+ "healthCheck": {
352
+
353
+ "retries": 5,
354
+
355
+ "command": [
356
+
357
+ "CMD-SHELL",
358
+
359
+ "mysqladmin ping -u dbuser -psimplememodbuser -h 127.0.0.1 || exit 1"
360
+
361
+ ],
362
+
363
+ "timeout": 3,
364
+
365
+ "interval": 10,
366
+
367
+ "startPeriod": null
368
+
369
+ },
370
+
371
+ "essential": true,
372
+
373
+ "links": null,
374
+
375
+ "hostname": null,
376
+
377
+ "extraHosts": null,
378
+
379
+ "pseudoTerminal": null,
380
+
381
+ "user": null,
382
+
383
+ "readonlyRootFilesystem": null,
384
+
385
+ "dockerLabels": null,
386
+
387
+ "systemControls": null,
388
+
389
+ "privileged": null,
390
+
391
+ "name": "mariadb"
392
+
393
+ }
394
+
395
+ ],
396
+
397
+ "placementConstraints": [],
398
+
399
+ "memory": "512",
400
+
401
+ "taskRoleArn": "arn:aws:iam::200144044244:role/ecsTaskExecutionRole",
402
+
403
+ "compatibilities": [
404
+
405
+ "EC2",
406
+
407
+ "FARGATE"
408
+
409
+ ],
410
+
411
+ "taskDefinitionArn": "arn:aws:ecs:ap-northeast-1:200144044244:task-definition/simplememo:39",
412
+
413
+ "family": "simplememo",
414
+
415
+ "requiresAttributes": [
416
+
417
+ {
418
+
419
+ "targetId": null,
420
+
421
+ "targetType": null,
422
+
423
+ "value": null,
424
+
425
+ "name": "ecs.capability.execution-role-awslogs"
426
+
427
+ },
428
+
429
+ {
430
+
431
+ "targetId": null,
432
+
433
+ "targetType": null,
434
+
435
+ "value": null,
436
+
437
+ "name": "com.amazonaws.ecs.capability.ecr-auth"
438
+
439
+ },
440
+
441
+ {
442
+
443
+ "targetId": null,
444
+
445
+ "targetType": null,
446
+
447
+ "value": null,
448
+
449
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
450
+
451
+ },
452
+
453
+ {
454
+
455
+ "targetId": null,
456
+
457
+ "targetType": null,
458
+
459
+ "value": null,
460
+
461
+ "name": "com.amazonaws.ecs.capability.task-iam-role"
462
+
463
+ },
464
+
465
+ {
466
+
467
+ "targetId": null,
468
+
469
+ "targetType": null,
470
+
471
+ "value": null,
472
+
473
+ "name": "ecs.capability.container-health-check"
474
+
475
+ },
476
+
477
+ {
478
+
479
+ "targetId": null,
480
+
481
+ "targetType": null,
482
+
483
+ "value": null,
484
+
485
+ "name": "ecs.capability.execution-role-ecr-pull"
486
+
487
+ },
488
+
489
+ {
490
+
491
+ "targetId": null,
492
+
493
+ "targetType": null,
494
+
495
+ "value": null,
496
+
497
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
498
+
499
+ },
500
+
501
+ {
502
+
503
+ "targetId": null,
504
+
505
+ "targetType": null,
506
+
507
+ "value": null,
508
+
509
+ "name": "ecs.capability.task-eni"
510
+
511
+ },
512
+
513
+ {
514
+
515
+ "targetId": null,
516
+
517
+ "targetType": null,
518
+
519
+ "value": null,
520
+
521
+ "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
522
+
523
+ },
524
+
525
+ {
526
+
527
+ "targetId": null,
528
+
529
+ "targetType": null,
530
+
531
+ "value": null,
532
+
533
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.24"
534
+
535
+ },
536
+
537
+ {
538
+
539
+ "targetId": null,
540
+
541
+ "targetType": null,
542
+
543
+ "value": null,
544
+
545
+ "name": "ecs.capability.efsAuth"
546
+
547
+ },
548
+
549
+ {
550
+
551
+ "targetId": null,
552
+
553
+ "targetType": null,
554
+
555
+ "value": null,
556
+
557
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
558
+
559
+ },
560
+
561
+ {
562
+
563
+ "targetId": null,
564
+
565
+ "targetType": null,
566
+
567
+ "value": null,
568
+
569
+ "name": "ecs.capability.efs"
570
+
571
+ },
572
+
573
+ {
574
+
575
+ "targetId": null,
576
+
577
+ "targetType": null,
578
+
579
+ "value": null,
580
+
581
+ "name": "ecs.capability.container-ordering"
582
+
583
+ },
584
+
585
+ {
586
+
587
+ "targetId": null,
588
+
589
+ "targetType": null,
590
+
591
+ "value": null,
592
+
593
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.25"
594
+
595
+ }
596
+
597
+ ],
598
+
599
+ "pidMode": null,
600
+
601
+ "requiresCompatibilities": [
602
+
603
+ "FARGATE"
604
+
605
+ ],
606
+
607
+ "networkMode": "awsvpc",
608
+
609
+ "runtimePlatform": {
610
+
611
+ "operatingSystemFamily": "LINUX",
612
+
613
+ "cpuArchitecture": null
614
+
615
+ },
616
+
617
+ "cpu": "256",
618
+
619
+ "revision": 39,
620
+
621
+ "status": "ACTIVE",
622
+
623
+ "inferenceAccelerators": null,
624
+
625
+ "proxyConfiguration": null,
626
+
627
+ "volumes": [
628
+
629
+ {
630
+
631
+ "fsxWindowsFileServerVolumeConfiguration": null,
632
+
633
+ "efsVolumeConfiguration": {
634
+
635
+ "transitEncryptionPort": null,
636
+
637
+ "fileSystemId": "fs-004f119dfa09acb35",
638
+
639
+ "authorizationConfig": {
640
+
641
+ "iam": "DISABLED",
642
+
643
+ "accessPointId": null
644
+
645
+ },
646
+
647
+ "transitEncryption": "DISABLED",
648
+
649
+ "rootDirectory": "/"
650
+
651
+ },
652
+
653
+ "name": "efs",
654
+
655
+ "host": null,
656
+
657
+ "dockerVolumeConfiguration": null
658
+
659
+ }
660
+
661
+ ]
662
+
663
+ }
664
+
665
+ ```
666
+
667
+
668
+
39
669
  ### 発生している問題・エラーメッセージ
40
670
 
41
671