From 1b0d2e4dd8c34efb7c6c44ecea50f2a070df3e68 Mon Sep 17 00:00:00 2001 From: horsewin Date: Thu, 7 Oct 2021 21:09:46 +0900 Subject: [PATCH] doc: upodate README --- README.md | 33 ++++++++++++++++++++++++++++++++- cicd/buildspec_before.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 cicd/buildspec_before.yml diff --git a/README.md b/README.md index 1168995..fb19f16 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # sbcntr-resources -書籍用の各種リソースのダウンロードリポジトリ + +書籍用の各種リソースのダウンロードリポジトリです。 + +## リポジトリの構成 + +```bash +❯ tree . -d 1 +. +├── cicd +├── cloudformations +├── cloud9 +├── docker-ecs +├── fargate-bastion +├── firelens +├── iam +└── scan +``` + +それぞれのディレクトリと本書の関連付けは次の通りです。 + +| ディレクトリ | 本書の対象箇所 | 内容 | +|-----------------|------------------------------------------------------------|--------------------------------------------------| +| cicd | 5-2 運用設計:Codeシリーズを使った CI/CD | CI/CD設計で利用するビルド定義やタスク定義などを格納 | +| cloudformations | 4-2 ネットワークの構築, 4-4 コンテナレジストリの構築, 4-5 オーケストレータの構築, その他(おまけ) | ハンズオンで利用するCloudFormationを格納 | +| cloud9 | 4-4 コンテナレジストリの構築 | resize.shを格納 | +| docker-ecs | その他(おまけ) | 本書に盛り込めなかったdocker-ecsツールをCloud9で起動するための設定ファイルを格納 | +| fargate-bastion | 5-7 運用設計:FargateによるBastion(踏み台ホスト)の構築 | Fargate Bastionで利用するBastionコンテナの設定を格納 | +| firelens | 5-6 運用設計 &セキュリティ設計:ログ収集基盤の構築 | ログ収集基盤のFireLensコンテナに設定するログ設定を格納 | +| iam | 4章、5章全般 | 4章や5章の各所で利用するIAMポリシーのJSONファイルを格納 | +| scan | 5-8 セキュリティ設計: Trivy/Dockleによるセキュリティチェック | DevSecOpsを実現するためのCodeBuildのビルド定義を格納 | + +本書でPDFからコードをコピー&ペーストしたり、写経するのが難しい場合がありますので、是非ご活用ください。 \ No newline at end of file diff --git a/cicd/buildspec_before.yml b/cicd/buildspec_before.yml new file mode 100644 index 0000000..78ee30a --- /dev/null +++ b/cicd/buildspec_before.yml @@ -0,0 +1,28 @@ +version: 0.2 + +env: + variables: + AWS_REGION_NAME: ap-northeast-1 + ECR_REPOSITORY_NAME: sbcntr-backend + DOCKER_BUILDKIT: "1" + +phases: + install: + runtime-versions: + docker: 19 + + pre_build: + commands: + - AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) + - aws ecr --region ap-northeast-1 get-login-password | docker login --username AWS --password-stdin https://${AWS_ACCOUNT_ID}.dkr.ecr.ap-northeast-1.amazonaws.com/sbcntr-backend + - REPOSITORY_URI=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION_NAME}.amazonaws.com/${ECR_REPOSITORY_NAME} + # タグ名にGitのコミットハッシュを利用 + - IMAGE_TAG=$(echo ${CODEBUILD_RESOLVED_SOURCE_VERSION} | cut -c 1-7) + + build: + commands: + - docker image build -t ${REPOSITORY_URI}:${IMAGE_TAG} . + + post_build: + commands: + - docker push ${REPOSITORY_URI}:${IMAGE_TAG} \ No newline at end of file