From 1b5b865c1446bfddb7a35ddf3829c5893054a901 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sun, 21 Mar 2021 19:11:25 +0900 Subject: [PATCH 01/14] Copy a view file from original (latest) repo * decidim-core/app/views/decidim/application/_collection.html.erb --- .../decidim/application/_collection.html.erb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/views/decidim/application/_collection.html.erb diff --git a/app/views/decidim/application/_collection.html.erb b/app/views/decidim/application/_collection.html.erb new file mode 100644 index 0000000000..f50093c939 --- /dev/null +++ b/app/views/decidim/application/_collection.html.erb @@ -0,0 +1,20 @@ +<% unless attachment_collection.unused? %> +
+ <%= icon "caret-right", class: "icon--small", role: "img", "aria-hidden": true %>  + <%= translated_attribute(attachment_collection.name) %> + + <% attachment_collection_documents_count = attachment_collection.attachments.select(&:document?).count %> + (<%= attachment_collection_documents_count %> <%= t("decidim.application.collection.documents", count: attachment_collection_documents_count) %>) + + +
+

<%= translated_attribute(attachment_collection.description) %>

+ +
+ <% documents.each do |document| %> + <%= render partial: "decidim/application/document.html", locals: { document: document } %> + <% end %> +
+
+
+<% end %> From 60c74b4926d9598cf4bc2d5f4c37912e93271fb4 Mon Sep 17 00:00:00 2001 From: takahashim Date: Thu, 8 Apr 2021 16:23:42 +0900 Subject: [PATCH 02/14] update locales/ja.yml --- config/locales/ja.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index d7ccbfd705..f6558e9199 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -147,6 +147,10 @@ ja: sortition_cancel_author: deleted: 退会者 verifications: + authorizations: + first_login: + actions: + user_extension_authorization_handler: ユーザー拡張属性対応用 postal_letter: admin: pending_authorizations: From 48945d51fc6ee60d98a70e7037e35618f542f6e5 Mon Sep 17 00:00:00 2001 From: komtaki Date: Wed, 31 Mar 2021 22:42:23 +0900 Subject: [PATCH 03/14] fix: move .ebextensions/ -> deployments/.ebextensions/ --- {.ebextensions => deployments/.ebextensions}/00_options.config | 0 {.ebextensions => deployments/.ebextensions}/01_swap.config | 0 {.ebextensions => deployments/.ebextensions}/02_packages.config | 0 {.ebextensions => deployments/.ebextensions}/03_sidekiq.config | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {.ebextensions => deployments/.ebextensions}/00_options.config (100%) rename {.ebextensions => deployments/.ebextensions}/01_swap.config (100%) rename {.ebextensions => deployments/.ebextensions}/02_packages.config (100%) rename {.ebextensions => deployments/.ebextensions}/03_sidekiq.config (100%) diff --git a/.ebextensions/00_options.config b/deployments/.ebextensions/00_options.config similarity index 100% rename from .ebextensions/00_options.config rename to deployments/.ebextensions/00_options.config diff --git a/.ebextensions/01_swap.config b/deployments/.ebextensions/01_swap.config similarity index 100% rename from .ebextensions/01_swap.config rename to deployments/.ebextensions/01_swap.config diff --git a/.ebextensions/02_packages.config b/deployments/.ebextensions/02_packages.config similarity index 100% rename from .ebextensions/02_packages.config rename to deployments/.ebextensions/02_packages.config diff --git a/.ebextensions/03_sidekiq.config b/deployments/.ebextensions/03_sidekiq.config similarity index 100% rename from .ebextensions/03_sidekiq.config rename to deployments/.ebextensions/03_sidekiq.config From 497a5b1f2e659b42b56eec10e379cc48a94ab952 Mon Sep 17 00:00:00 2001 From: komtaki Date: Wed, 31 Mar 2021 22:43:27 +0900 Subject: [PATCH 04/14] fix: delete aws db config on deployments/.ebextensions/00_options.config --- deployments/.ebextensions/00_options.config | 6 ------ 1 file changed, 6 deletions(-) diff --git a/deployments/.ebextensions/00_options.config b/deployments/.ebextensions/00_options.config index 3fae7a39b4..2427703ebd 100644 --- a/deployments/.ebextensions/00_options.config +++ b/deployments/.ebextensions/00_options.config @@ -14,12 +14,6 @@ option_settings: MeasureName: "CPUUtilization" Unit: "Percent" UpperThreshold: "200" - "aws:rds:dbinstance": - DBDeletionPolicy: "Snapshot" - DBAllocatedStorage: "10" - DBEngine: "postgres" - DBEngineVersion: "12.3" - DBInstanceClass: "db.t2.small" "aws:elasticbeanstalk:environment": LoadBalancerType: "application" "aws:elasticbeanstalk:command": From f525e13425fc0a803b29eacc3140026f65953680 Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Thu, 13 May 2021 14:56:33 +0900 Subject: [PATCH 05/14] Rename DEVLOPMENT.md to DEVELOPMENT.md The DEVELOPMENT link in README.md is 404. Fix the filename. --- DEVLOPMENT.md => DEVELOPMENT.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename DEVLOPMENT.md => DEVELOPMENT.md (100%) diff --git a/DEVLOPMENT.md b/DEVELOPMENT.md similarity index 100% rename from DEVLOPMENT.md rename to DEVELOPMENT.md From 3e6cc8c24067a8397ca5a0713a9d094ac1814901 Mon Sep 17 00:00:00 2001 From: komtaki Date: Wed, 31 Mar 2021 22:44:12 +0900 Subject: [PATCH 06/14] feat: add production deploy by ci --- .github/workflows/deploy.yml | 82 +++++++++++++++++-- deployments/.ebignore | 2 + .../00_options.config | 4 + deployments/staging/00_options.config | 26 ++++++ 4 files changed, 108 insertions(+), 6 deletions(-) rename deployments/{.ebextensions => production}/00_options.config (89%) create mode 100644 deployments/staging/00_options.config diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9329f1f43c..b5a162ee01 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,11 +4,45 @@ on: push: branches: - develop + - master + tags: + - 'v*' jobs: - deploy: + create-app-env: + runs-on: ubuntu-latest + timeout-minutes: 60 + outputs: + image-tag: ${{ steps.output-app-env.outputs.image-tag }} + eb-environment-name: ${{ steps.output-app-env.outputs.eb-environment-name }} + + steps: + - uses: actions/checkout@v2 + + - name: Set env to staging + id: set-env-staging + if: endsWith(github.ref, 'heads/develop') + run: | + echo "IMAGE_TAG_PREFIX=staging" >> $GITHUB_ENV + echo "EB_ENVIRONMENT_NAME=staging" >> $GITHUB_ENV + + - name: Set env to production + id: set-env-production + if: endsWith(github.ref, 'heads/master') || contains(github.ref, 'tags/v') + run: | + echo "IMAGE_TAG_PREFIX=production" >> $GITHUB_ENV + echo "EB_ENVIRONMENT_NAME=production" >> $GITHUB_ENV + + - name: Output App Env + id: output-app-env + run: | + echo "::set-output name=image-tag::${IMAGE_TAG_PREFIX}-${GITHUB_SHA::8}" + echo "::set-output name=eb-environment-name::${EB_ENVIRONMENT_NAME}" + + build: runs-on: ubuntu-latest timeout-minutes: 1200 + needs: create-app-env steps: - uses: actions/checkout@v2 @@ -25,14 +59,51 @@ jobs: uses: aws-actions/amazon-ecr-login@v1 - name: Build, tag, and push image to Amazon ECR + if: endsWith(github.ref, 'heads/master') || endsWith(github.ref, 'heads/develop') env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }} - IMAGE_TAG: staging + IMAGE_TAG: ${{ needs.create-app-env.outputs.image-tag }} run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + deploy: + runs-on: ubuntu-latest + timeout-minutes: 1200 + if: endsWith(github.ref, 'heads/develop') || contains(github.ref, 'tags/v') + needs: + - create-app-env + - build + + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Check if ECR Image exists with tag + if: contains(github.ref, 'tags/v') + env: + IMAGE_TAG: ${{ needs.create-app-env.outputs.image-tag }} + ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }} + run: | + EXIT_CODE=0 + aws ecr describe-images --repository-name=$ECR_REPOSITORY --image-ids=imageTag=$IMAGE_TAG 2> /dev/null || EXIT_CODE=$? + + if [[ $EXIT_CODE != 0 ]]; then + echo "${IMAGE_TAG} image tag not found" + exit 1 + fi + - uses: actions/setup-python@master with: python-version: "3.7" @@ -42,13 +113,12 @@ jobs: - name: Deploy to Elastic Beanstalk env: + EB_ENVIRONMENT_NAME: ${{ needs.create-app-env.outputs.eb-environment-name }} + IMAGE_TAG: ${{ needs.create-app-env.outputs.image-tag }} ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }} - IMAGE_TAG: staging - EB_ENVIRONMENT_NAME: staging run: | - cp -r .ebextensions/ deployments/.ebextensions cd deployments - sed -i -e "s|t2.small|t2.micro|g" .ebextensions/00_options.config + cp ${EB_ENVIRONMENT_NAME}/00_options.config .ebextensions/00_options.config sed -i -e "s|{RepositoryName}|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" Dockerrun.aws.json eb deploy ${EB_ENVIRONMENT_NAME} diff --git a/deployments/.ebignore b/deployments/.ebignore index c8d44f3bba..22c6c3d810 100644 --- a/deployments/.ebignore +++ b/deployments/.ebignore @@ -1 +1,3 @@ ./elasticbeanstalk +/staging +/production diff --git a/deployments/.ebextensions/00_options.config b/deployments/production/00_options.config similarity index 89% rename from deployments/.ebextensions/00_options.config rename to deployments/production/00_options.config index 2427703ebd..bbd8ac6ffa 100644 --- a/deployments/.ebextensions/00_options.config +++ b/deployments/production/00_options.config @@ -4,6 +4,9 @@ option_settings: EC2KeyName : "aws-eb" RootVolumeSize : "100" RootVolumeType : "gp2" + "aws:autoscaling:asg": + MinSize: 3 + MaxSize: 5 "aws:autoscaling:updatepolicy:rollingupdate": MaxBatchSize: "1" MinInstancesInService: "1" @@ -12,6 +15,7 @@ option_settings: "aws:autoscaling:trigger": LowerThreshold: "10" MeasureName: "CPUUtilization" + Statistic: "Maximum" Unit: "Percent" UpperThreshold: "200" "aws:elasticbeanstalk:environment": diff --git a/deployments/staging/00_options.config b/deployments/staging/00_options.config new file mode 100644 index 0000000000..4d52fcacce --- /dev/null +++ b/deployments/staging/00_options.config @@ -0,0 +1,26 @@ +option_settings: + "aws:autoscaling:launchconfiguration": + IamInstanceProfile : "aws-elasticbeanstalk-ec2-role" + EC2KeyName : "aws-eb" + RootVolumeSize : "100" + RootVolumeType : "gp2" + "aws:autoscaling:asg": + MinSize: 1 + MaxSize: 2 + "aws:autoscaling:updatepolicy:rollingupdate": + MaxBatchSize: "1" + MinInstancesInService: "1" + RollingUpdateEnabled: "true" + RollingUpdateType: "Health" + "aws:autoscaling:trigger": + LowerThreshold: "10" + MeasureName: "CPUUtilization" + Statistic: "Maximum" + Unit: "Percent" + UpperThreshold: "200" + "aws:elasticbeanstalk:environment": + LoadBalancerType: "application" + "aws:elasticbeanstalk:command": + BatchSize: "30" + "aws:ec2:instances": + InstanceTypes: "t2.micro" From 2c1efcfa76a4149b6ce8cf672c3f82a91f497776 Mon Sep 17 00:00:00 2001 From: komtaki Date: Wed, 31 Mar 2021 22:45:03 +0900 Subject: [PATCH 07/14] refactor: delete nginx.conf for eb ruby platform --- .platform/nginx/nginx.conf | 117 ------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 .platform/nginx/nginx.conf diff --git a/.platform/nginx/nginx.conf b/.platform/nginx/nginx.conf deleted file mode 100644 index 07d45ff72d..0000000000 --- a/.platform/nginx/nginx.conf +++ /dev/null @@ -1,117 +0,0 @@ -# For more information on configuration, see: -# * Official English Documentation: http://nginx.org/en/docs/ -# * Official Russian Documentation: http://nginx.org/ru/docs/ - -user nginx; -worker_processes auto; -error_log /var/log/nginx/error.log; -pid /var/run/nginx.pid; - -# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. -include /usr/share/nginx/modules/*.conf; - -events { - worker_connections 1024; -} - -http { - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - server_tokens off; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 4096; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # Load modular configuration files from the /etc/nginx/conf.d directory. - # See http://nginx.org/en/docs/ngx_core_module.html#include - # for more information. - include /etc/nginx/conf.d/*.conf; - - index index.html index.htm; - - server { - listen 80; - listen [::]:80; - server_name _; - root /usr/share/nginx/html; - - # Load configuration files for the default server block. - include /etc/nginx/default.d/*.conf; - - # redirect server error pages to the static page /40x.html - # - error_page 404 /404.html; - location = /40x.html { - } - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - } - - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} - - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} - } - -# Settings for a TLS enabled server. -# -# server { -# listen 443 ssl http2; -# listen [::]:443 ssl http2; -# server_name _; -# root /usr/share/nginx/html; -# -# ssl_certificate "/etc/pki/nginx/server.crt"; -# ssl_certificate_key "/etc/pki/nginx/private/server.key"; -# # It is *strongly* recommended to generate unique DH parameters -# # Generate them with: openssl dhparam -out /etc/pki/nginx/dhparams.pem 2048 -# #ssl_dhparam "/etc/pki/nginx/dhparams.pem"; -# ssl_session_cache shared:SSL:1m; -# ssl_session_timeout 10m; -# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; -# ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP; -# ssl_prefer_server_ciphers on; -# -# # Load configuration files for the default server block. -# include /etc/nginx/default.d/*.conf; -# -# error_page 404 /404.html; -# location = /40x.html { -# } -# -# error_page 500 502 503 504 /50x.html; -# location = /50x.html { -# } -# } - -} From b2b21fc618095c3120d9ed46e8b840f51eea4a38 Mon Sep 17 00:00:00 2001 From: komtaki Date: Tue, 11 May 2021 19:08:57 +0900 Subject: [PATCH 08/14] doc: add description of ci/cd on DEPLOYMENT.md --- DEPLOYMENT.md | 109 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 18 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 17781364bb..6a116b46c2 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -1,3 +1,72 @@ +# ※GUIでElastic Beanstalkの設定をいじらないでください。デプロイで戻ります。 + +Elastic Beanstalkの設定はコードで管理されています。 + +インスタンスタイプやオートスケールの設定が違うため、stagingとproductionで一部ファイルが別です。それ以外の共通の設定は同じファイルを使っているので気を付けて下さい。 + +共通: [deployments/.ebextensions](deployments/.ebextensions) + +staging: [deployments/staging](deployments/staging) +production: [deployments/production](deployments/production) + +デプロイの際に上記の設定ファイルを元にデプロイが実行されます。コードでの設定がある場合、インフラも含め反映されます。 + +急ぎで、GUIで変更することはあると思います。しかし、GUIだけ変更してソースコードを変更しないと、デプロイの際に戻って事故の原因になります。なので、ソースコードに反映してください。 + +現状、認証情報等の非公開情報の設定方法が検討中なので、環境変数だけはGUIから設定してください。 + +GUIの設定とコードの書き方は、[公式](https://docs.aws.amazon.com/ja_jp/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-elasticbeanstalkapplicationenvironment)を参考にしてください。 + +# GitHubからデプロイ + +ワークフローの設定:[.github/workflows/deploy.yml](.github/workflows/deploy.yml) +デプロイの基本設定: [./deployments/](./deployments/) + +1. ECRにログイン +1. Dockerコンテナをbuild +1. short commit hashを含む環境ごとのタグで、ECRにDockerイメージをpush +1. elastic beanstalkに該当のイメージを指定してデプロイ + +Dockerイメージのタグ例: staging-dfasfste + +``` +[デプロイされる環境名]-[commit-hash] +``` + +## GitHubに必要な環境変数 + +- AWS_ACCESS_KEY_ID +- AWS_SECRET_ACCESS_KEY +- AWS_ECR_REPO_NAME + +## デプロイ手順 + +### production + +切り戻しを早くするため、masterマージの際、Dockerイメージは毎回buildします。 + +パイプラインが通ったのを確認後、git上でデプロイしたいコミットに、v○○とタグを打ちます。 +タグはvから始まる必要があります。すぐにeb deployが実行されます。 + +例: v1.0.0 + +### staging + +developブランチにpushすると自動でデプロイされます。 + +## 切り戻し + +### production + +普通にデプロイするのと同様に戻したい先commitに対してタグを打ちます。 +バグの場合、バグが発生したcommitの1つ前のcommitにたいしてタグを打ちます。 + +コンテナイメージはbuild済みなので、すぐにeb deployが実行されます。 + +### staging + +revetしてdevelopブランチにpushしてください。 + # CfJ Decidim AWS への Install(Beanstalk 編) ## 1. Install AWS tools and setup user @@ -21,11 +90,22 @@ bundle install ## 4. Elastic Beanstalk に 環境をセットアップする -[https://platoniq.github.io/decidim-install/decidim-aws/] 手順書の手順3に従って環境を作る +手順書の[手順3](https://platoniq.github.io/decidim-install/decidim-aws/#3-initialize-elasticbeanstalk)に従って環境を作る + + +[Dockerrun.aws.json](./deployment/Dockerrun.aws.json)の`{RepositoryName}`をECRのデプロイしたいイメージパスに修正。作成したい環境の設定をコピー。 + +[deployments/.elasticbeanstalk/config.yml](deployments/.elasticbeanstalk/config.yml)に設定があるので、基本的に何も聞かれないはずです。 -eb create を実施 ```bash +cd deployments + +// production +cp deployments/production/00_options.config .ebextensions/00_options.config +// staging(台数とかインスタンスタイプが小さい) +cp deployments/staging/00_options.config .ebextensions/00_options.config + eb create production ``` @@ -39,40 +119,33 @@ eb setenv SECRET_KEY_BASE=$(bin/rails secret) ## 5. Postgres データベースを作成する -EB コンソールの該当環境から、Configuration を選択、Database を選択し、Edit をする - 必要な設定を行い、DBを立ち上げる その後`eb deploy`を実行 -## 6. Healthcheck の条件を変更 - -`/` が301を返すので、一旦 301 でもOKにする - -Elastic Beanstalk の Configuration 画面で、Health Check を選び、Process の条件を 80 から 301 にする - -![img](https://i.imgur.com/VNZDQxA.png) -![img2](https://i.imgur.com/j595JQF.png) - -## 7. CNAME 設定とSSL設定 +## 6. CNAME 設定とSSL設定 Elastic Beanstalk のインスタンスをAレコードとして割り当てる ロードバランサの設定をする(手順[6.2 Configure SSL](https://platoniq.github.io/decidim-install/decidim-aws/#62-configure-ssl)) -## 8. 最初のユーザを作る +## 7. 最初のユーザを作る [6.3 Create the first admin user](https://platoniq.github.io/decidim-install/decidim-aws/#63-create-the-first-admin-user) に従う(root で) -## 9. SES の設定をする +## 8. SES の設定をする [6.4 Setup email](https://platoniq.github.io/decidim-install/decidim-aws/#64-setup-email) -## 10. REDIS の設定をする +## 9. REDIS の設定をする [6.5 Configure the job system with Sidekiq and Redis](https://platoniq.github.io/decidim-install/decidim-aws/#65-configure-the-job-system-with-sidekiq-and-redis) -## 11. S3 の設定をする +stagingはcloud formationで作成しています。 + +[.cloudformation/elastic_cache.yml](.cloudformation/elastic_cache.yml) + +## 10. S3 の設定をする [6.6 File storage](https://platoniq.github.io/decidim-install/decidim-aws/#66-file-storage) From 8b71e6e2ea2dbcb92e7fdb2aaa5cbdf353ce13c6 Mon Sep 17 00:00:00 2001 From: komtaki Date: Sat, 15 May 2021 21:44:39 +0900 Subject: [PATCH 09/14] refactor: fix autoscaling min-max metrics on 00_options.config --- deployments/production/00_options.config | 4 ++-- deployments/staging/00_options.config | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployments/production/00_options.config b/deployments/production/00_options.config index bbd8ac6ffa..dd9972138a 100644 --- a/deployments/production/00_options.config +++ b/deployments/production/00_options.config @@ -13,11 +13,11 @@ option_settings: RollingUpdateEnabled: "true" RollingUpdateType: "Health" "aws:autoscaling:trigger": - LowerThreshold: "10" + LowerThreshold: "30" MeasureName: "CPUUtilization" Statistic: "Maximum" Unit: "Percent" - UpperThreshold: "200" + UpperThreshold: "60" "aws:elasticbeanstalk:environment": LoadBalancerType: "application" "aws:elasticbeanstalk:command": diff --git a/deployments/staging/00_options.config b/deployments/staging/00_options.config index 4d52fcacce..d3c106b07c 100644 --- a/deployments/staging/00_options.config +++ b/deployments/staging/00_options.config @@ -13,11 +13,11 @@ option_settings: RollingUpdateEnabled: "true" RollingUpdateType: "Health" "aws:autoscaling:trigger": - LowerThreshold: "10" + LowerThreshold: "30" MeasureName: "CPUUtilization" Statistic: "Maximum" Unit: "Percent" - UpperThreshold: "200" + UpperThreshold: "60" "aws:elasticbeanstalk:environment": LoadBalancerType: "application" "aws:elasticbeanstalk:command": From 002ac0707ece9a52a7550a42dfc756eca82f2e34 Mon Sep 17 00:00:00 2001 From: komtaki Date: Sat, 15 May 2021 23:01:47 +0900 Subject: [PATCH 10/14] feat: add cloud watch log stream --- deployments/production/00_options.config | 4 ++++ deployments/staging/00_options.config | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/deployments/production/00_options.config b/deployments/production/00_options.config index dd9972138a..326c8428d8 100644 --- a/deployments/production/00_options.config +++ b/deployments/production/00_options.config @@ -24,3 +24,7 @@ option_settings: BatchSize: "30" "aws:ec2:instances": InstanceTypes: "t2.small" + "aws:elasticbeanstalk:cloudwatch:logs": + StreamLogs: true + DeleteOnTerminate: false + RetentionInDays: 7 diff --git a/deployments/staging/00_options.config b/deployments/staging/00_options.config index d3c106b07c..aaeadda69d 100644 --- a/deployments/staging/00_options.config +++ b/deployments/staging/00_options.config @@ -24,3 +24,7 @@ option_settings: BatchSize: "30" "aws:ec2:instances": InstanceTypes: "t2.micro" + "aws:elasticbeanstalk:cloudwatch:logs": + StreamLogs: true + DeleteOnTerminate: true + RetentionInDays: 3 From e50ff855736654e7f65b75bca8964c9c23d567bb Mon Sep 17 00:00:00 2001 From: komtaki Date: Mon, 17 May 2021 19:22:33 +0900 Subject: [PATCH 11/14] feat: add health check status code 301 --- deployments/production/00_options.config | 2 ++ deployments/staging/00_options.config | 2 ++ 2 files changed, 4 insertions(+) diff --git a/deployments/production/00_options.config b/deployments/production/00_options.config index 326c8428d8..beb8820c01 100644 --- a/deployments/production/00_options.config +++ b/deployments/production/00_options.config @@ -20,6 +20,8 @@ option_settings: UpperThreshold: "60" "aws:elasticbeanstalk:environment": LoadBalancerType: "application" + "aws:elasticbeanstalk:environment:process:default": + MatcherHTTPCode: 301 "aws:elasticbeanstalk:command": BatchSize: "30" "aws:ec2:instances": diff --git a/deployments/staging/00_options.config b/deployments/staging/00_options.config index aaeadda69d..60bd027019 100644 --- a/deployments/staging/00_options.config +++ b/deployments/staging/00_options.config @@ -20,6 +20,8 @@ option_settings: UpperThreshold: "60" "aws:elasticbeanstalk:environment": LoadBalancerType: "application" + "aws:elasticbeanstalk:environment:process:default": + MatcherHTTPCode: 301 "aws:elasticbeanstalk:command": BatchSize: "30" "aws:ec2:instances": From a7316111ef4462e30934a94b325761cf85b005a2 Mon Sep 17 00:00:00 2001 From: komtaki Date: Wed, 19 May 2021 09:01:52 +0900 Subject: [PATCH 12/14] refactor: add eb deploy timeout option --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b5a162ee01..61c6cb43b0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -70,7 +70,7 @@ jobs: deploy: runs-on: ubuntu-latest - timeout-minutes: 1200 + timeout-minutes: 1800 if: endsWith(github.ref, 'heads/develop') || contains(github.ref, 'tags/v') needs: - create-app-env @@ -121,4 +121,4 @@ jobs: cd deployments cp ${EB_ENVIRONMENT_NAME}/00_options.config .ebextensions/00_options.config sed -i -e "s|{RepositoryName}|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" Dockerrun.aws.json - eb deploy ${EB_ENVIRONMENT_NAME} + eb deploy ${EB_ENVIRONMENT_NAME} --timeout=20 From ec94299c1906f71981aa996104a04948df6f7f8a Mon Sep 17 00:00:00 2001 From: komtaki Date: Thu, 20 May 2021 08:27:51 +0900 Subject: [PATCH 13/14] feat: RAILS_LOG_TO_STDOUT environment valiable in dcokerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e3d20fed5..82a35296fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,9 @@ ENV LANG=C.UTF-8 \ BUNDLER_VERSION=1.17.3 \ APP_HOME=/app \ RAILS_ENV=${RAILS_ENV} \ - SECRET_KEY_BASE=placeholder \ - RAILS_SERVE_STATIC_FILES=true + RAILS_LOG_TO_STDOUT=true \ + RAILS_SERVE_STATIC_FILES=true \ + SECRET_KEY_BASE=placeholder WORKDIR $APP_HOME From 7317cb385b19a06a27101a9ade294e3f24d03354 Mon Sep 17 00:00:00 2001 From: komtaki Date: Thu, 20 May 2021 08:57:47 +0900 Subject: [PATCH 14/14] feat: change newrelic log type to stdout from file --- config/newrelic.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/newrelic.yml b/config/newrelic.yml index ff79dd7e3b..36f3e79c2c 100644 --- a/config/newrelic.yml +++ b/config/newrelic.yml @@ -24,9 +24,11 @@ common: &default_settings # To disable the agent regardless of other settings, uncomment the following: # agent_enabled: false - # Logging level for log/newrelic_agent.log + # Logging level log_level: info + log_file_path: STDOUT + # Environment-specific settings are in this section. # RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.