質問編集履歴

3

コンテナのファイル群確認ログを追加

2022/08/25 02:17

投稿

takuya861
takuya861

スコア14

test CHANGED
File without changes
test CHANGED
@@ -406,17 +406,37 @@
406
406
  - default.confのupstreamをserver localhost:5000;に変更→“GET /api/v1/health_check HTTP/1.1" 500 71587 “-” “ELB-HealthChecker/2.0"
407
407
  パブリックIPアドレスやロードバランサーDNS名でブラウザにアクセスしようとしましたがアクセスできませんでした。
408
408
  [こちら](https://sakaishun.com/2022/01/28/rails-ecs-deploy/)の記事を参考にしましたが、
409
-
410
- Volumeを使ってファイルの参照ができるとありましたが、設定方法がおかしいのか調査中です。
411
- nginxからRailsに疎通できていないのかと思うのですが、どこが間違っている、不足しているのかわからない状況です。
412
-
413
409
  -ここから追加で試したこと-
414
410
  - タスク定義でボリュームの追加→名前:sockets ボリュームタイプ:Bind Mount
415
411
  - nginxコンテナでマウントポイントの追加→ソースボリューム:sockets コンテナパス:/back/tmp/sockets
416
412
  - RailsDockerfileにVOLUME追加→VOLUME /back/tmp/sockets
417
413
  - docker-compose.ymlにvolumesを追加→backのvolumesに - sockets:/back/tmp/sockets volumesにsockets
418
414
 
415
+ nginxコンテナからRailsコンテナのpublic配下は確認できるが、tmp配下はファイル群が存在していない。
416
+ Railsコンテナ
417
+ ```
418
+ Starting session with SessionId: ecs-execute-command-060aa63f924fee35b
419
+ # cd tmp
420
+ # cd sockets
421
+ # ls -a
422
+ . .. puma.sock
423
+ # pwd
419
- ※RailsのDockerfileも最新版に更新してあります
424
+ /back/tmp/sockets
425
+ ```
426
+ nginxコンテナ
427
+ ```
428
+ Starting session with SessionId: ecs-execute-command-05c9c71aac4d64b8c
429
+ # cd back
430
+ # ls -a
431
+ . .. public tmp
432
+ # cd public
433
+ # ls -a
434
+ . .. favicon.ico robots.txt uploads
435
+ # cd ..
436
+ # cd tmp
437
+ # ls -a
438
+ . ..
439
+ ```
420
440
 
421
441
  ### 補足情報(FW/ツールのバージョンなど)
422
442
  ruby 2.6.6

2

タスク定義JSON追加

2022/08/24 08:21

投稿

takuya861
takuya861

スコア14

test CHANGED
File without changes
test CHANGED
@@ -154,6 +154,252 @@
154
154
  COPY /back .
155
155
  ```
156
156
 
157
+ ```
158
+ {
159
+ "ipcMode": null,
160
+ "executionRoleArn": ":role/career-finder-ecsTaskExecutionRole",
161
+ "containerDefinitions": [
162
+ {
163
+ "dnsSearchDomains": null,
164
+ "environmentFiles": null,
165
+ "logConfiguration": {
166
+ "logDriver": "awslogs",
167
+ "secretOptions": null,
168
+ "options": {
169
+ "awslogs-group": "/ecs/staging-agt-careerfinder-api",
170
+ "awslogs-region": "ap-northeast-1",
171
+ "awslogs-stream-prefix": "ecs"
172
+ }
173
+ },
174
+ "entryPoint": null,
175
+ "portMappings": [
176
+ {
177
+ "hostPort": 5000,
178
+ "protocol": "tcp",
179
+ "containerPort": 5000
180
+ }
181
+ ],
182
+ "command": [
183
+ "bundle",
184
+ "exec",
185
+ "puma",
186
+ "-C",
187
+ "config/puma.rb"
188
+ ],
189
+ "linuxParameters": null,
190
+ "cpu": 0,
191
+ "environment": [],
192
+ "resourceRequirements": null,
193
+ "ulimits": null,
194
+ "dnsServers": null,
195
+ "mountPoints": [],
196
+ "workingDirectory": null,
197
+ "secrets": null,
198
+ "dockerSecurityOptions": null,
199
+ "memory": null,
200
+ "memoryReservation": null,
201
+ "volumesFrom": [],
202
+ "stopTimeout": null,
203
+ "image": "967906006845.dkr.ecr.ap-northeast-1.amazonaws.com/staging-agt-careerfinde-rails",
204
+ "startTimeout": null,
205
+ "firelensConfiguration": null,
206
+ "dependsOn": null,
207
+ "disableNetworking": null,
208
+ "interactive": null,
209
+ "healthCheck": {
210
+ "retries": 3,
211
+ "command": [
212
+ "CMD-SHELL",
213
+ "curl --unix-socket /back/tmp/sockets/puma.sock ./",
214
+ "|| exit 1"
215
+ ],
216
+ "timeout": 5,
217
+ "interval": 30,
218
+ "startPeriod": null
219
+ },
220
+ "essential": true,
221
+ "links": null,
222
+ "hostname": null,
223
+ "extraHosts": null,
224
+ "pseudoTerminal": null,
225
+ "user": null,
226
+ "readonlyRootFilesystem": null,
227
+ "dockerLabels": null,
228
+ "systemControls": null,
229
+ "privileged": null,
230
+ "name": "rails"
231
+ },
232
+ {
233
+ "dnsSearchDomains": null,
234
+ "environmentFiles": null,
235
+ "logConfiguration": {
236
+ "logDriver": "awslogs",
237
+ "secretOptions": null,
238
+ "options": {
239
+ "awslogs-group": "/ecs/staging-agt-careerfinder-api",
240
+ "awslogs-region": "ap-northeast-1",
241
+ "awslogs-stream-prefix": "ecs"
242
+ }
243
+ },
244
+ "entryPoint": null,
245
+ "portMappings": [
246
+ {
247
+ "hostPort": 80,
248
+ "protocol": "tcp",
249
+ "containerPort": 80
250
+ }
251
+ ],
252
+ "command": null,
253
+ "linuxParameters": null,
254
+ "cpu": 0,
255
+ "environment": [],
256
+ "resourceRequirements": null,
257
+ "ulimits": null,
258
+ "dnsServers": null,
259
+ "mountPoints": [
260
+ {
261
+ "readOnly": null,
262
+ "containerPath": "/back/tmp",
263
+ "sourceVolume": "sockets"
264
+ }
265
+ ],
266
+ "workingDirectory": null,
267
+ "secrets": null,
268
+ "dockerSecurityOptions": null,
269
+ "memory": null,
270
+ "memoryReservation": null,
271
+ "volumesFrom": [],
272
+ "stopTimeout": null,
273
+ "image": "967906006845.dkr.ecr.ap-northeast-1.amazonaws.com/staging-agt-careerfinde-nginx",
274
+ "startTimeout": null,
275
+ "firelensConfiguration": null,
276
+ "dependsOn": [
277
+ {
278
+ "containerName": "rails",
279
+ "condition": "HEALTHY"
280
+ }
281
+ ],
282
+ "disableNetworking": null,
283
+ "interactive": null,
284
+ "healthCheck": null,
285
+ "essential": true,
286
+ "links": null,
287
+ "hostname": null,
288
+ "extraHosts": null,
289
+ "pseudoTerminal": null,
290
+ "user": null,
291
+ "readonlyRootFilesystem": false,
292
+ "dockerLabels": null,
293
+ "systemControls": null,
294
+ "privileged": null,
295
+ "name": "nginx"
296
+ }
297
+ ],
298
+ "placementConstraints": [],
299
+ "memory": "1024",
300
+ "taskRoleArn": "arn:aws:iam::967906006845:role/career-finder-ecsTaskExecutionRole",
301
+ "compatibilities": [
302
+ "EC2",
303
+ "FARGATE"
304
+ ],
305
+ "taskDefinitionArn": "arn:aws:ecs:ap-northeast-1:967906006845:task-definition/staging-agt-careerfinder-api:56",
306
+ "family": "staging-agt-careerfinder-api",
307
+ "requiresAttributes": [
308
+ {
309
+ "targetId": null,
310
+ "targetType": null,
311
+ "value": null,
312
+ "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
313
+ },
314
+ {
315
+ "targetId": null,
316
+ "targetType": null,
317
+ "value": null,
318
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.24"
319
+ },
320
+ {
321
+ "targetId": null,
322
+ "targetType": null,
323
+ "value": null,
324
+ "name": "ecs.capability.execution-role-awslogs"
325
+ },
326
+ {
327
+ "targetId": null,
328
+ "targetType": null,
329
+ "value": null,
330
+ "name": "com.amazonaws.ecs.capability.ecr-auth"
331
+ },
332
+ {
333
+ "targetId": null,
334
+ "targetType": null,
335
+ "value": null,
336
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
337
+ },
338
+ {
339
+ "targetId": null,
340
+ "targetType": null,
341
+ "value": null,
342
+ "name": "com.amazonaws.ecs.capability.task-iam-role"
343
+ },
344
+ {
345
+ "targetId": null,
346
+ "targetType": null,
347
+ "value": null,
348
+ "name": "ecs.capability.container-health-check"
349
+ },
350
+ {
351
+ "targetId": null,
352
+ "targetType": null,
353
+ "value": null,
354
+ "name": "ecs.capability.container-ordering"
355
+ },
356
+ {
357
+ "targetId": null,
358
+ "targetType": null,
359
+ "value": null,
360
+ "name": "ecs.capability.execution-role-ecr-pull"
361
+ },
362
+ {
363
+ "targetId": null,
364
+ "targetType": null,
365
+ "value": null,
366
+ "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
367
+ },
368
+ {
369
+ "targetId": null,
370
+ "targetType": null,
371
+ "value": null,
372
+ "name": "ecs.capability.task-eni"
373
+ }
374
+ ],
375
+ "pidMode": null,
376
+ "requiresCompatibilities": [
377
+ "FARGATE"
378
+ ],
379
+ "networkMode": "awsvpc",
380
+ "runtimePlatform": {
381
+ "operatingSystemFamily": "LINUX",
382
+ "cpuArchitecture": null
383
+ },
384
+ "cpu": "512",
385
+ "revision": 56,
386
+ "status": "ACTIVE",
387
+ "inferenceAccelerators": null,
388
+ "proxyConfiguration": null,
389
+ "volumes": [
390
+ {
391
+ "fsxWindowsFileServerVolumeConfiguration": null,
392
+ "efsVolumeConfiguration": null,
393
+ "name": "sockets",
394
+ "host": {
395
+ "sourcePath": null
396
+ },
397
+ "dockerVolumeConfiguration": null
398
+ }
399
+ ]
400
+ }
401
+ ```
402
+
157
403
  ### 試したこと
158
404
  - railsDockerdileにVOLUME /back/tmpを追加して、タスク定義でnginxのコンテナのソースコンテナにrailsを指定→500エラーに変わりヘルスチェック通らず
159
405
  - VOLUME [“/back/tmp”]も試したが同様でした。

1

試したことの追加

2022/08/23 13:36

投稿

takuya861
takuya861

スコア14

test CHANGED
File without changes
test CHANGED
@@ -28,7 +28,6 @@
28
28
  ```
29
29
  upstream app {
30
30
  server unix:///back/tmp/sockets/puma.sock;
31
- # server localhost:5000;
32
31
  }
33
32
 
34
33
  server {
@@ -144,13 +143,15 @@
144
143
  ADD /back/Gemfile.lock .
145
144
  RUN bundle install
146
145
 
146
+ RUN mkdir -p /back/tmp/pids
147
+ RUN mkdir -p /back/tmp/sockets
148
+
147
149
  RUN yarn install --check-files
148
150
  # RUN WEBPACKER_PRECOMPILE=false bundle exec rails assets:precompile
149
151
 
150
- # VOLUME /back/tmp
152
+ VOLUME /back/tmp/sockets
151
153
 
152
154
  COPY /back .
153
- ADD . /back
154
155
  ```
155
156
 
156
157
  ### 試したこと
@@ -163,6 +164,14 @@
163
164
  Volumeを使ってファイルの参照ができるとありましたが、設定方法がおかしいのか調査中です。
164
165
  nginxからRailsに疎通できていないのかと思うのですが、どこが間違っている、不足しているのかわからない状況です。
165
166
 
167
+ -ここから追加で試したこと-
168
+ - タスク定義でボリュームの追加→名前:sockets ボリュームタイプ:Bind Mount
169
+ - nginxコンテナでマウントポイントの追加→ソースボリューム:sockets コンテナパス:/back/tmp/sockets
170
+ - RailsDockerfileにVOLUME追加→VOLUME /back/tmp/sockets
171
+ - docker-compose.ymlにvolumesを追加→backのvolumesに - sockets:/back/tmp/sockets volumesにsockets
172
+
173
+ ※RailsのDockerfileも最新版に更新してあります
174
+
166
175
  ### 補足情報(FW/ツールのバージョンなど)
167
176
  ruby 2.6.6
168
177
  rails 6.0.3