From d23e184de3c2b3ee43883298c8b5550e8928d544 Mon Sep 17 00:00:00 2001 From: sigma <50137312+RyosukeDTomita@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:57:00 +0900 Subject: [PATCH 1/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 242a40b..ea664a9 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ copilot pipeline deploy - 一度pipelineをデプロイすると以後,指定したGitHubのブランチにマージされるたびにCode Pipelineを通してデプロイが進むようになる。 #### CodePipelineにimage scanを追加する - [./copilot/pipelines/react-app-pipeline/buildspec.yml](./copilot/pipelines/react-app-pipeline/buildspec.yml)を編集してtrivyによるimage scanを追加する。 +> [ECRのイメージスキャン機能](https://docs.aws.amazon.com/ja_jp/AmazonECR/latest/userguide/image-scanning.html)はデフォルトであるので併用してもよいかも。 ``` install: @@ -182,6 +183,7 @@ xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/react-app/dev-svc:xxxxxx-xxxxx-xxxx- ``` + ****** From 34cba75755fa689a974c342735b76dc9ddfd451f Mon Sep 17 00:00:00 2001 From: sigma <50137312+RyosukeDTomita@users.noreply.github.com> Date: Fri, 22 Dec 2023 18:00:41 +0900 Subject: [PATCH 2/5] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ea664a9..1e2d497 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,14 @@ # ENVIRONMENT -- AWS +- AWS: ECS on FargateにCode Pipeline経由でデプロイする。サンプルではdevとprod環境を用意し、dev環境で動作確認後に承認ボタンを押すとprod環境にもデプロイが進む形になっている。 - Github Actions -- node:20 +- アプリ: React sample ****** # ABOUT Sample for DevSecOps environment. -If you need help or questions, please contact [twitter](https://twitter.com/sigma5736394841), issues. ## AWS - app-infrastructure-roles ![app-infrastructure-roles](./doc/fig/cfn/app-infrastructure-roles.png) From 5b4a2bcba82691b5146c51055c366e24ce9b4961 Mon Sep 17 00:00:00 2001 From: sigma <50137312+RyosukeDTomita@users.noreply.github.com> Date: Fri, 22 Dec 2023 18:18:15 +0900 Subject: [PATCH 3/5] fix comment docker_test.sh --- docker_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_test.sh b/docker_test.sh index 3730dbb..23ef4ef 100755 --- a/docker_test.sh +++ b/docker_test.sh @@ -11,4 +11,4 @@ docker rmi react-app:latest -f docker build -t react-app:latest . --no-cache docker run -p 80:8080 react-app:latest # -p localport:containerport -# open your browser and go to `localhost:80`. +# open your browser and go to `localhost:8080`. From 6aa3279d6a21b135deab6787357143e18930f1ef Mon Sep 17 00:00:00 2001 From: sigma <50137312+RyosukeDTomita@users.noreply.github.com> Date: Fri, 22 Dec 2023 18:30:43 +0900 Subject: [PATCH 4/5] Add common error. --- README.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e2d497..ed78ad9 100644 --- a/README.md +++ b/README.md @@ -214,5 +214,45 @@ git secrets --register-aws # awsのクレデンシャル検知ルールを登録 # MEMO -## nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) +## Code Buildのエラー +以下コマンドでログが見れる。 + +```shell +copilot svc logs --previous +``` + +### nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) - [ECSの仕様で非特権ユーザを使用したコンテナでは80番ポートが使えないっぽい](https://repost.aws/questions/QU1bCV9wT4T5iBrrP1c2ISfg/container-cannot-bind-to-port-80-running-as-non-root-user-on-ecs-fargate) --> つまり,localのdockerで80でサービスが起動できてもECSだと権限エラーになる。このため,コンテナで開放するportは8080としている(ALBに対して8080がマッピングされているためブラウザからは80でアクセスできる)。 +### toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit +- Docker Hubに短期間にアクセスしすぎているだけなので放置でOK +### Error response from daemon: dockerfile parse error +- DockerfileのRUNをヒアドキュメントで書いていたら怒られた(ローカルでは動いてたのに...) + +``` +# 修正前Dockerfile +RUN < Date: Thu, 28 Dec 2023 00:47:41 +0900 Subject: [PATCH 5/5] use instead docker compose --- docker-compose.yml | 10 ++++++++++ docker_test.sh | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..51e546e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' + +services: + react-app: + build: + context: ./ + dockerfile: Dockerfile + image: react-app:latest + ports: + - 80:8080 # localport:dockerport diff --git a/docker_test.sh b/docker_test.sh index 23ef4ef..bb77bf4 100755 --- a/docker_test.sh +++ b/docker_test.sh @@ -8,7 +8,8 @@ # Date: 2023/12/06 ########################################################################## docker rmi react-app:latest -f -docker build -t react-app:latest . --no-cache -docker run -p 80:8080 react-app:latest # -p localport:containerport +#docker build -t react-app:latest . --no-cache +#docker run -p 80:8080 react-app:latest # -p localport:containerport +docker compose up -# open your browser and go to `localhost:8080`. +# open your browser and go to `localhost:80`.