Skip to content

Commit

Permalink
Merge pull request #247 from codeforjapan/develop
Browse files Browse the repository at this point in the history
update some Development Implements
  • Loading branch information
ayuki-joto authored Jun 22, 2021
2 parents 60ecec8 + 9392180 commit e0b8cf9
Show file tree
Hide file tree
Showing 21 changed files with 211 additions and 196 deletions.
30 changes: 30 additions & 0 deletions .cloudformation/ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ Resources:
"action": {
"type": "expire"
}
},
{
"action": {
"type": "expire"
},
"selection": {
"countType": "imageCountMoreThan",
"countNumber": 7,
"tagStatus": "tagged",
"tagPrefixList": [
"staging-"
]
},
"description": "stagingイメージの削除",
"rulePriority": 2
},
{
"action": {
"type": "expire"
},
"selection": {
"countType": "imageCountMoreThan",
"countNumber": 7,
"tagStatus": "tagged",
"tagPrefixList": [
"production-"
]
},
"description": "productionイメージの削除",
"rulePriority": 3
}
]
}
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ jobs:
run: |
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} --timeout=20
sed -i -e "s|{RepositoryName}|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" docker-compose.yml
sed -i -e "s|{EBEnvironment}|$EB_ENVIRONMENT_NAME|g" docker-compose.yml
eb deploy ${EB_ENVIRONMENT_NAME} --timeout=20 --process
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Change Log

## [v0.23.0-2021-5-31](https://github.com/codeforjapan/decidim-cfj/releases/tag/v0.23.0-2021-5-31)

### Fixed

- Fix locale file of proposals [#233](https://github.com/codeforjapan/decidim-cfj/issues/233)

## [v0.23.0-2021-5-24](https://github.com/codeforjapan/decidim-cfj/releases/tag/v0.23.0-2021-5-24)

### Developer improvements

- production deploy by GitHub Actions [#232](https://github.com/codeforjapan/decidim-cfj/pull/232)
11 changes: 6 additions & 5 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ bundle install

## 4. Elastic Beanstalk に 環境をセットアップする

手順書の[手順3](https://platoniq.github.io/decidim-install/decidim-aws/#3-initialize-elasticbeanstalk)に従って環境を作る


[Dockerrun.aws.json](./deployment/Dockerrun.aws.json)`{RepositoryName}`をECRのデプロイしたいイメージパスに修正。作成したい環境の設定をコピー。
1. [docker-compose.yml](deployments/docker-compose.yml)`{RepositoryName}`をデプロイしたいECRのイメージパスに修正。
1. [docker-compose.yml](deployments/docker-compose.yml)`{EBEnvironment}}`をデプロイする環境名に修正。
1. 作成したい環境の設定をコピー。

[deployments/.elasticbeanstalk/config.yml](deployments/.elasticbeanstalk/config.yml)に設定があるので、基本的に何も聞かれないはずです。

Expand All @@ -103,7 +102,7 @@ cd deployments

// production
cp deployments/production/00_options.config .ebextensions/00_options.config
// staging(台数とかインスタンスタイプが小さい)
// staging(台数とかログの保持期間が小さい)
cp deployments/staging/00_options.config .ebextensions/00_options.config

eb create production
Expand Down Expand Up @@ -142,6 +141,8 @@ Elastic Beanstalk のインスタンスをAレコードとして割り当てる

[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)

sidekiqの設定をする必要はありません。dockerでデプロイされています。

stagingはcloud formationで作成しています。

[.cloudformation/elastic_cache.yml](.cloudformation/elastic_cache.yml)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apk update \
build-base \
curl-dev \
git \
&& apk add --no-cache \
&& apk add --no-cache \
imagemagick \
postgresql-dev \
tzdata \
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
config.log_level = :info

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

Redis.exists_returns_integer = true
2 changes: 1 addition & 1 deletion config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:concurrency: 6
:concurrency: 3
:queues:
- default
- mailers
Expand Down
25 changes: 25 additions & 0 deletions deployments/.ebextensions/02_common_options.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
option_settings:
"aws:autoscaling:launchconfiguration":
IamInstanceProfile: aws-elasticbeanstalk-ec2-role
EC2KeyName: aws-eb
RootVolumeSize: 100
RootVolumeType: gp2
"aws:autoscaling:updatepolicy:rollingupdate":
MaxBatchSize: 1
MinInstancesInService: 1
RollingUpdateEnabled: true
RollingUpdateType: Health
"aws:autoscaling:trigger":
LowerThreshold: 30
MeasureName: CPUUtilization
Statistic: Maximum
Unit: Percent
UpperThreshold: 60
"aws:elasticbeanstalk:environment":
LoadBalancerType: application
"aws:elasticbeanstalk:environment:proxy":
ProxyServer: none
"aws:elasticbeanstalk:environment:process:default":
MatcherHTTPCode: 301
"aws:elasticbeanstalk:command":
BatchSize: 30
4 changes: 0 additions & 4 deletions deployments/.ebextensions/02_packages.config

This file was deleted.

4 changes: 4 additions & 0 deletions deployments/.ebextensions/03_nginx.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
container_commands:
01-healthd-configure:
command: |
chmod -R 777 /var/log/nginx/healthd
66 changes: 0 additions & 66 deletions deployments/.ebextensions/03_sidekiq.config

This file was deleted.

54 changes: 0 additions & 54 deletions deployments/.platform/nginx/nginx.conf

This file was deleted.

13 changes: 0 additions & 13 deletions deployments/Dockerrun.aws.json

This file was deleted.

38 changes: 38 additions & 0 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3.8"

services:
nginx-proxy:
image: nginx:1.21
volumes:
- ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./etc/nginx/conf.d:/etc/nginx/conf.d
- /var/log/nginx:/var/log/nginx
- static-public:/app/public
environment:
TZ: Asia/Tokyo
ports:
- 80:80
links:
- app
depends_on:
- app

app:
image: "{RepositoryName}"
volumes:
- static-public:/app/public
environment:
NEW_RELIC_APP_NAME: decidem-app({EBEnvironment})
env_file:
- .env

sidekiq:
image: "{RepositoryName}"
command: bundle exec sidekiq -C /app/config/sidekiq.yml
environment:
NEW_RELIC_APP_NAME: decidem-sidekiq({EBEnvironment})
env_file:
- .env

volumes:
static-public:
30 changes: 30 additions & 0 deletions deployments/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
server {
listen 80 default_server;

gzip on;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}

access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;

root /app/public;

try_files $uri $uri @app;

location @app {
proxy_pass http://app:3000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
32 changes: 32 additions & 0 deletions deployments/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 32137;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

log_format healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';

include conf.d/*.conf;

map $http_upgrade $connection_upgrade {
default "upgrade";
}

server_tokens off;
}
Loading

0 comments on commit e0b8cf9

Please sign in to comment.