modulorails 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38bfc28b69038bd12e6db5b86c5a81fc29aab339896ee1b2b47429ed6d12c4fe
4
- data.tar.gz: 0b0a203652556def30c6e3471acd7e35fecf834310d94d21f58766acafaf9f5b
3
+ metadata.gz: 6a06133e9c157d574ab3cc83ffd931e7e61873d7c8deff63c22b8a0657def075
4
+ data.tar.gz: d345aa7aa32575496041762e43f198001260a003dc811c69ae704f889dde0411
5
5
  SHA512:
6
- metadata.gz: d68c37e214e7e996b586775a4f74c805d78c6d6a9f1745e1abfe38ca323b7ce82265f94c89219f2bfa811c92b02b4c160daa8751097019cc1be919844b184009
7
- data.tar.gz: 346739b57ded95ac5c96684c4e9d91af1867b4713741d7e71d6484b3ddc68ec651feef1c863c318ab6684f2fa9a93df8ddfb20956880a37e9a87962f21f9414e
6
+ metadata.gz: 1594ae1f801bf28f08ec2a86ecc6040f48c513d2c47a2dfb9f0a8a3b69bf2dd7f04d6465aff1041faf80759fb70610ff57a8b02b83bddf4cbdc3ab9c553bdb9b
7
+ data.tar.gz: 4e4652c68c1ba65d1ce429c5acffbb5e11c8f82effdcdd55735d91cb8c12e442f6a00b5b5099a316b26f8620ef20873c96b5349df4ea58ec24566aaebe75abb1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  This file is used to list changes made in each version of the gem.
4
4
 
5
+ # 1.3.1
6
+
7
+ - Update templates according to new devops standards:
8
+ - Add exec commands in entrypoints.
9
+ - Upgrade PG and Redis version in docker-compose files.
10
+ - Upgrade PG and Redis version in test stage in CI.
11
+ - Add default SECRET_KEY_BASE and optional `yarn install` in `Dockerfile.prod` templates.
12
+ - Add templates for Kubernetes values files.
13
+ - Append sidekiq in Kubernetes values files in Sidekiq generator.
14
+
5
15
  # 1.3.0
6
16
 
7
17
  - Update redis configuration in generators.
data/README.md CHANGED
@@ -28,6 +28,9 @@ Modulorails.configure do |config|
28
28
  config.project_manager 'The email of the project manager of the application'
29
29
  config.endpoint 'The url to the intranet'
30
30
  config.api_key 'The API key'
31
+ config.review_base_url 'The base url for the review environments' # optional
32
+ config.staging_url 'The url for the staging environment' # optional
33
+ config.production_url 'The url for the production environment' # optional
31
34
  end
32
35
  ```
33
36
 
@@ -8,6 +8,12 @@ class Modulorails::DockerGenerator < Rails::Generators::Base
8
8
  desc 'This generator creates Dockerfiles for an app'
9
9
 
10
10
  def create_config_file
11
+ @data = Modulorails.data
12
+ @adapter = data.adapter
13
+ @webpack_container_needed = data.webpacker_version.present?
14
+ @image_name = @data.name.parameterize
15
+ @environment_name = @data.environment_name
16
+
11
17
  template 'Dockerfile'
12
18
  template 'Dockerfile.prod'
13
19
  template 'docker-compose.yml'
@@ -18,7 +24,7 @@ class Modulorails::DockerGenerator < Rails::Generators::Base
18
24
  template 'config/cable.yml'
19
25
 
20
26
  # Useless unless project is using Webpacker
21
- if Modulorails.data.webpacker_version.present?
27
+ if @webpack_container_needed
22
28
  template 'entrypoints/webpack-entrypoint.sh'
23
29
  chmod 'entrypoints/webpack-entrypoint.sh', 0755
24
30
  end
@@ -1,7 +1,8 @@
1
1
  # BUILD IMAGE
2
- FROM ruby:<%= Modulorails.data.ruby_version %>-alpine as builder
2
+ FROM ruby:<%= @data.ruby_version %>-alpine as builder
3
3
 
4
- ENV RAILS_ENV=production
4
+ ENV RAILS_ENV=production \
5
+ SECRET_KEY_BASE=1
5
6
  WORKDIR /app
6
7
 
7
8
  RUN apk add --update --no-cache \
@@ -11,27 +12,28 @@ RUN apk add --update --no-cache \
11
12
  yarn \
12
13
  shared-mime-info \
13
14
  gcompat \
14
- <%- adapter = Modulorails.data.adapter -%>
15
- <%- if adapter =~ /mysql/ -%>
15
+ <%- if @adapter =~ /mysql/ -%>
16
16
  mysql-dev
17
17
  <%- else -%>
18
18
  postgresql-dev
19
19
  <%- end -%>
20
- RUN gem install bundler -v <%= Modulorails.data.bundler_version %>
20
+ RUN gem install bundler -v <%= @data.bundler_version %>
21
21
 
22
22
  COPY Gemfile Gemfile.lock ./
23
23
  RUN bundle config set --local deployment 'true'
24
24
  RUN bundle check || bundle install --jobs=2 \
25
25
  && rm -rf vendor/bundle/ruby/*/cache/*
26
26
 
27
+ <%- if @webpack_container_needed -%>
27
28
  COPY package.json yarn.lock ./
28
29
  RUN yarn install
30
+ <%- end-%>
29
31
 
30
32
  COPY . .
31
33
  RUN bundle exec rake assets:precompile
32
34
 
33
35
  # FINAL IMAGE
34
- FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
36
+ FROM ruby:<%= @data.ruby_version %>-alpine
35
37
 
36
38
  ENV RAILS_ENV=development
37
39
  ENV EDITOR=vim
@@ -44,8 +46,7 @@ RUN apk add --update --no-cache \
44
46
  tzdata \
45
47
  shared-mime-info \
46
48
  vim \
47
- <%- adapter = Modulorails.data.adapter -%>
48
- <%- if adapter =~ /mysql/ -%>
49
+ <%- if @adapter =~ /mysql/ -%>
49
50
  mysql-dev \
50
51
  <%- else -%>
51
52
  postgresql-dev \
@@ -1,4 +1,4 @@
1
- FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
1
+ FROM ruby:<%= @data.ruby_version %>-alpine
2
2
 
3
3
  ENV RAILS_ENV=development
4
4
  ENV EDITOR=vim
@@ -11,13 +11,12 @@ RUN apk add --update --no-cache \
11
11
  tzdata \
12
12
  gcompat \
13
13
  vim \
14
- <%- adapter = Modulorails.data.adapter -%>
15
- <%- if adapter =~ /mysql/ -%>
14
+ <%- if @adapter =~ /mysql/ -%>
16
15
  mysql-dev
17
16
  <%- else -%>
18
17
  postgresql-dev
19
18
  <%- end -%>
20
- RUN gem install bundler -v <%= Modulorails.data.bundler_version %>
19
+ RUN gem install bundler -v <%= @data.bundler_version %>
21
20
 
22
21
  COPY Gemfile Gemfile.lock ./
23
22
  RUN bundle install --jobs=2
@@ -1,29 +1,26 @@
1
- <%- image_name = Modulorails.data.name.parameterize -%>
2
- <%- environment_name = Modulorails.data.environment_name -%>
3
- <%- adapter = Modulorails.data.adapter -%>
4
- <%- if adapter =~ /mysql/ -%>
1
+ <%- if @adapter =~ /mysql/ -%>
5
2
  development: &default
6
3
  adapter: mysql2
7
4
  encoding: utf8mb4
8
5
  collation: utf8mb4_unicode_ci
9
- database: <%%= ENV.fetch('<%= environment_name %>_DATABASE_NAME', '<%= image_name %>') %>
10
- username: <%%= ENV.fetch('<%= environment_name %>_DATABASE_USERNAME', 'root') %>
11
- password: <%%= ENV.fetch('<%= environment_name %>_DATABASE_PASSWORD', '') %>
12
- host: <%%= ENV.fetch('<%= environment_name %>_DATABASE_HOST', 'database') %>
13
- port: <%%= ENV.fetch('<%= environment_name %>_DATABASE_PORT', 3306) %>
6
+ database: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_NAME', '<%= @image_name %>') %>
7
+ username: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_USERNAME', 'root') %>
8
+ password: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_PASSWORD', '') %>
9
+ host: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_HOST', 'database') %>
10
+ port: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_PORT', 3306) %>
14
11
  <%- else -%>
15
12
  development: &default
16
13
  adapter: postgresql
17
- database: <%%= ENV.fetch('<%= environment_name %>_DATABASE_NAME', '<%= image_name %>') %>
18
- username: <%%= ENV.fetch('<%= environment_name %>_DATABASE_USERNAME', 'postgres') %>
19
- password: <%%= ENV.fetch('<%= environment_name %>_DATABASE_PASSWORD', 'postgres') %>
20
- host: <%%= ENV.fetch('<%= environment_name %>_DATABASE_HOST', 'database') %>
21
- port: <%%= ENV.fetch('<%= environment_name %>_DATABASE_PORT', 5432) %>
14
+ database: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_NAME', '<%= @image_name %>') %>
15
+ username: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_USERNAME', 'postgres') %>
16
+ password: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_PASSWORD', 'postgres') %>
17
+ host: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_HOST', 'database') %>
18
+ port: <%%= ENV.fetch('<%= @environment_name %>_DATABASE_PORT', 5432) %>
22
19
  <%- end -%>
23
20
 
24
21
  test:
25
22
  <<: *default
26
- database: <%%= ENV.fetch('<%= environment_name %>_TEST_DATABASE_NAME', '<%= image_name %>_test') %>
23
+ database: <%%= ENV.fetch('<%= @environment_name %>_TEST_DATABASE_NAME', '<%= @image_name %>_test') %>
27
24
 
28
25
  staging:
29
26
  <<: *default
@@ -1,10 +1,8 @@
1
1
  version: '3.7'
2
2
 
3
- <%- image_name = Modulorails.data.name.parameterize -%>
4
- <%- environment_name = Modulorails.data.environment_name -%>
5
3
  services:
6
4
  app:
7
- image: modulotechgroup/<%= image_name %>
5
+ image: modulotechgroup/<%= @image_name %>
8
6
  build:
9
7
  context: .
10
8
  dockerfile: Dockerfile.prod
@@ -16,36 +14,35 @@ services:
16
14
  environment:
17
15
  RAILS_ENV: production
18
16
  URL: http://localhost:3000
19
- <%= environment_name %>_DATABASE_HOST: database
20
- <%= environment_name %>_DATABASE_NAME: <%= image_name %>
17
+ <%= @environment_name %>_DATABASE_HOST: database
18
+ <%= @environment_name %>_DATABASE_NAME: <%= @image_name %>
21
19
  RAILS_SERVE_STATIC_FILES: 'true'
22
20
  REDIS_URL: redis://redis:6379/1
23
21
 
24
- <%- adapter = Modulorails.data.adapter -%>
25
- <%- if adapter =~ /mysql/ -%>
22
+ <%- if @adapter =~ /mysql/ -%>
26
23
  database:
27
24
  image: mysql/mysql-server:8.0
28
25
  volumes:
29
26
  - db_data:/var/lib/mysql
30
27
  environment:
31
28
  MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
32
- MYSQL_DATABASE: <%= image_name %>
29
+ MYSQL_DATABASE: <%= @image_name %>
33
30
  MYSQL_ROOT_HOST: '%'
34
31
  <%- else -%>
35
32
  database:
36
- image: postgres:13.5
33
+ image: postgres:15-alpine
37
34
  volumes:
38
35
  - db_data:/var/lib/postgresql/data
39
36
  environment:
40
37
  POSTGRES_USER: postgres
41
38
  POSTGRES_PASSWORD: postgres
42
- POSTGRES_DB: <%= image_name %>
39
+ POSTGRES_DB: <%= @image_name %>
43
40
  LC_COLLATE: 'en_US.UTF-8'
44
41
  LC_CTYPE: 'en_US.UTF-8'
45
42
  <%- end -%>
46
43
 
47
44
  redis:
48
- image: redis:6.2-alpine
45
+ image: redis:7-alpine
49
46
 
50
47
  # Define the volumes references in the services
51
48
  volumes:
@@ -1,10 +1,8 @@
1
1
  version: '3.7'
2
2
 
3
- <%- image_name = Modulorails.data.name.parameterize -%>
4
- <%- environment_name = Modulorails.data.environment_name -%>
5
3
  services:
6
4
  app:
7
- image: modulotechgroup/<%= image_name %>:dev
5
+ image: modulotechgroup/<%= @image_name %>:dev
8
6
  build:
9
7
  context: .
10
8
  dockerfile: Dockerfile
@@ -18,48 +16,46 @@ services:
18
16
  environment:
19
17
  RAILS_ENV: development
20
18
  URL: http://localhost:3000
21
- <%= environment_name %>_DATABASE_HOST: database
22
- <%= environment_name %>_DATABASE_NAME: <%= image_name %>
19
+ <%= @environment_name %>_DATABASE_HOST: database
20
+ <%= @environment_name %>_DATABASE_NAME: <%= @image_name %>
23
21
  REDIS_URL: redis://redis:6379/1
24
22
  entrypoint: ./entrypoints/docker-entrypoint.sh
25
23
  stdin_open: true
26
24
  tty: true
27
25
 
28
- <%- adapter = Modulorails.data.adapter -%>
29
- <%- if adapter =~ /mysql/ -%>
26
+ <%- if @adapter =~ /mysql/ -%>
30
27
  database:
31
28
  image: mysql/mysql-server:8.0
32
29
  volumes:
33
30
  - db_data:/var/lib/mysql
34
31
  environment:
35
32
  MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
36
- MYSQL_DATABASE: <%= image_name %>
33
+ MYSQL_DATABASE: <%= @image_name %>
37
34
  MYSQL_ROOT_HOST: '%'
38
- <%- else-%>
35
+ <%- else -%>
39
36
  database:
40
- image: postgres:13.5
37
+ image: postgres:15-alpine
41
38
  volumes:
42
39
  - db_data:/var/lib/postgresql/data
43
40
  environment:
44
41
  POSTGRES_USER: postgres
45
42
  POSTGRES_PASSWORD: postgres
46
- POSTGRES_DB: <%= image_name %>
43
+ POSTGRES_DB: <%= @image_name %>
47
44
  LC_COLLATE: 'en_US.UTF-8'
48
45
  LC_CTYPE: 'en_US.UTF-8'
49
- <%- end-%>
46
+ <%- end -%>
50
47
 
51
48
  redis:
52
- image: redis:6.2-alpine
49
+ image: redis:7-alpine
53
50
 
54
51
  mailcatcher:
55
52
  image: dockage/mailcatcher
56
53
  ports:
57
54
  - 1080:1080
58
55
 
59
- <%- webpack_container_needed = Modulorails.data.webpacker_version.present? -%>
60
- <%- if webpack_container_needed -%>
56
+ <%- if @webpack_container_needed -%>
61
57
  webpack:
62
- image: modulotechgroup/<%= image_name %>:dev
58
+ image: modulotechgroup/<%= @image_name %>:dev
63
59
  build:
64
60
  context: .
65
61
  dockerfile: Dockerfile
@@ -72,7 +68,7 @@ services:
72
68
  NODE_ENV: development
73
69
  RAILS_ENV: development
74
70
  WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
75
- <%- end-%>
71
+ <%- end -%>
76
72
 
77
73
  volumes:
78
74
  db_data:
@@ -17,4 +17,4 @@ then
17
17
  fi
18
18
 
19
19
  # Launch the application listening from all origins on port 3000
20
- ./bin/bundle exec rails s -b 0.0.0.0 -p 3000
20
+ exec ./bin/bundle exec rails s -b 0.0.0.0 -p 3000
@@ -4,4 +4,4 @@
4
4
  set -e
5
5
 
6
6
  # Launch webpack
7
- ./bin/webpack-dev-server
7
+ exec ./bin/webpack-dev-server
@@ -8,8 +8,19 @@ class Modulorails::GitlabciGenerator < Rails::Generators::Base
8
8
  desc 'This generator creates a template for a .gitlab-ci.yml file at root'
9
9
 
10
10
  def create_config_file
11
+ @data = Modulorails.data
12
+ @image_name = @data.name.parameterize
13
+ @environment_name = @data.environment_name
14
+ @adapter = data.adapter
15
+ @review_base_url = @data.review_base_url
16
+ @staging_url = @data.staging_url
17
+ @production_url = @data.production_url
18
+
11
19
  # Update the gitlab-ci template
12
20
  template '.gitlab-ci.yml'
21
+ template 'config/deploy/production.yaml' if @production_url.present?
22
+ template 'config/deploy/staging.yaml' if @staging_url.present?
23
+ template 'config/deploy/review.yaml' if @review_base_url.present?
13
24
 
14
25
  # Remove the database-ci template if it exists.
15
26
  # It used to be referenced by the gitlab-ci template.
@@ -1,5 +1,3 @@
1
- <%- image_name = Modulorails.data.name.parameterize -%>
2
- <%- environment_name = Modulorails.data.environment_name -%>
3
1
  include:
4
2
  - project: 'modulosource/modulotech/devops/gitlab-ci-templates'
5
3
  file:
@@ -7,26 +5,17 @@ include:
7
5
  - '/templates/integration.gitlab-ci.yml'
8
6
  - '/templates/docker-buildx.gitlab-ci.yml'
9
7
 
10
- services:
11
- <%- adapter = Modulorails.data.adapter -%>
12
- <%- if adapter =~ /mysql/ -%>
13
- - mysql:8.0
14
- <%- else -%>
15
- - postgres:13.5
16
- <%- end -%>
17
- - redis:6.2
18
-
19
8
  variables:
20
- IMAGE_NAME: <%= image_name %>
21
- <%- if adapter =~ /mysql/ -%>
22
- MYSQL_DATABASE: <%= image_name %>_test
9
+ IMAGE_NAME: <%= @image_name %>
10
+ <%- if @adapter =~ /mysql/ -%>
11
+ MYSQL_DATABASE: <%= @image_name %>_test
23
12
  MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
24
- <%= environment_name %>_DATABASE_HOST: mysql
13
+ <%= @environment_name %>_DATABASE_HOST: mysql
25
14
  <%- else -%>
26
- POSTGRES_DB: <%= image_name %>_test
15
+ POSTGRES_DB: <%= @image_name %>_test
27
16
  POSTGRES_USER: postgres
28
17
  POSTGRES_PASSWORD: postgres
29
- <%= environment_name %>_DATABASE_HOST: postgres
18
+ <%= @environment_name %>_DATABASE_HOST: postgres
30
19
  <%- end -%>
31
20
 
32
21
  stages:
@@ -34,35 +23,44 @@ stages:
34
23
  - build
35
24
  - deploy
36
25
 
26
+ build_integration_image:
27
+ extends: .build_integration_image
28
+
37
29
  test:
38
30
  extends: .test
31
+ services:
32
+ <%- if @adapter =~ /mysql/ -%>
33
+ - mysql:8-alpine
34
+ <%- else -%>
35
+ - postgres:15-alpine
36
+ <%- end -%>
37
+ - redis:7-alpine
38
+ variables:
39
+ RAILS_ENV: test
39
40
  script:
40
- - "bundle exec rake db:create RAILS_ENV=test"
41
- - "RAILS_ENV=test bundle exec rake db:migrate:reset"
42
- - RAILS_ENV=test bundle exec rspec --format progress --format RspecJunitFormatter --out rspec.xml
43
-
44
- build_integration_image:
45
- extends: .build_integration_image
41
+ - bundle exec rake db:create
42
+ - bundle exec rake db:migrate:reset
43
+ - bundle exec rspec --format progress --format RspecJunitFormatter --out rspec.xml
46
44
 
47
45
  docker_build:
48
46
  extends: .docker_buildx_push
49
47
  only:
50
48
  - merge_requests
51
49
  - staging
50
+ - master
52
51
 
53
- <%- review_base_url = Modulorails.data.review_base_url -%>
54
- <%- if review_base_url.present? -%>
52
+ <%- if @review_base_url.present? -%>
55
53
  deploy_review:
56
54
  extends: .deploy_helm
57
55
  variables:
58
- NAMESPACE: <%= image_name %>-$CI_ENVIRONMENT_SLUG
59
- NAME: <%= image_name %>
60
- CHART_NAME: <%= image_name %>
61
- CONFIG_FILE: config/deploy/kubernetes/review.yaml
62
- EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set ingress.hosts[0].host=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set ingress.tls[0].hosts[0]=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set env.url=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set database.password=$DB_PASSWORD --set encryption.key=$ENCRYPTION_KEY
56
+ NAMESPACE: <%= @image_name %>-$CI_ENVIRONMENT_SLUG
57
+ NAME: <%= @image_name %>
58
+ CHART_NAME: <%= @image_name %>
59
+ CONFIG_FILE: config/deploy/review.yaml
60
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set ingress.hosts[0].host=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set ingress.tls[0].hosts[0]=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set env.url=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set database.url=$DATABASE_URL --set master_key.key=$MASTER_KEY
63
61
  environment:
64
62
  name: review/$CI_COMMIT_REF_SLUG
65
- url: https://${CI_ENVIRONMENT_SLUG}.<%= review_base_url %>
63
+ url: https://${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %>
66
64
  on_stop: stop_review
67
65
  auto_stop_in: 3 days
68
66
  only:
@@ -71,56 +69,40 @@ deploy_review:
71
69
  stop_review:
72
70
  extends: .stop_review
73
71
  variables:
74
- NAMESPACE: <%= image_name %>-$CI_ENVIRONMENT_SLUG
75
- NAME: <%= image_name %>
72
+ NAMESPACE: <%= @image_name %>-$CI_ENVIRONMENT_SLUG
73
+ NAME: <%= @image_name %>
76
74
  only:
77
75
  - merge_requests
78
76
  <%- end -%>
79
77
 
80
- <%- staging_url = Modulorails.data.staging_url -%>
81
- <%- if staging_url.present? -%>
78
+ <%- if @staging_url.present? -%>
82
79
  deploy_staging:
83
80
  extends: .deploy_helm
84
81
  variables:
85
- NAMESPACE: <%= image_name %>
86
- NAME: <%= image_name %>
87
- CHART_NAME: <%= image_name %>
88
- CONFIG_FILE: config/deploy/kubernetes/staging.yaml
89
- EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.password=$DB_PASSWORD
82
+ NAMESPACE: <%= @image_name %>
83
+ NAME: <%= @image_name %>
84
+ CHART_NAME: <%= @image_name %>
85
+ CONFIG_FILE: config/deploy/staging.yaml
86
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.url=$DATABASE_URL --set master_key.key=$MASTER_KEY
90
87
  environment:
91
88
  name: staging
92
- url: https://<%= staging_url %>
93
- only:
94
- - staging
95
- <%- else -%>
96
- deploy_staging:
97
- extends: .deploy_capistrano
98
- variables:
99
- STAGE: staging
89
+ url: https://<%= @staging_url %>
100
90
  only:
101
91
  - staging
102
92
  <%- end -%>
103
93
 
104
- <%- production_url = Modulorails.data.production_url -%>
105
- <%- if production_url.present? -%>
94
+ <%- if @production_url.present? -%>
106
95
  deploy_production:
107
96
  extends: .deploy_helm
108
97
  variables:
109
- NAMESPACE: <%= image_name %>
110
- NAME: <%= image_name %>
111
- CHART_NAME: <%= image_name %>
112
- CONFIG_FILE: config/deploy/kubernetes/production.yaml
113
- EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.password=$DB_PASSWORD
98
+ NAMESPACE: <%= @image_name %>
99
+ NAME: <%= @image_name %>
100
+ CHART_NAME: <%= @image_name %>
101
+ CONFIG_FILE: config/deploy/production.yaml
102
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA
114
103
  environment:
115
104
  name: production
116
- url: https://<%= production_url %>
117
- only:
118
- - master
119
- <%- else -%>
120
- deploy_production:
121
- extends: .deploy_capistrano
122
- variables:
123
- STAGE: production
105
+ url: https://<%= @production_url %>
124
106
  only:
125
107
  - master
126
108
  <%- end -%>
@@ -0,0 +1,43 @@
1
+ imagePullSecrets:
2
+ - name: regcred
3
+
4
+ ingress:
5
+ enabled: true
6
+ annotations:
7
+ kubernetes.io/ingress.class: nginx
8
+ kubernetes.io/tls-acme: 'true'
9
+ hosts:
10
+ - host: <%= @production_url %>
11
+ paths:
12
+ - path: /
13
+ tls:
14
+ - secretName: <%= @image_name %>
15
+ hosts:
16
+ - <%= @production_url %>
17
+
18
+ resources:
19
+ requests:
20
+ cpu: 100m
21
+ memory: 512Mi
22
+ limits:
23
+ memory: 512Mi
24
+
25
+ autoscaling:
26
+ enabled: true
27
+ minReplicas: 2
28
+ maxReplicas: 10
29
+ targetCPUUtilizationPercentage: 80
30
+
31
+ database:
32
+ existingSecret: 'database-credential'
33
+
34
+ master_key:
35
+ existingSecret: 'masterkey-credential'
36
+
37
+ env:
38
+ RAILS_ENV: production
39
+ URL: https://<%= @production_url %>/
40
+
41
+ redis:
42
+ enabled: false
43
+ existingSecret: 'redis-credential'
@@ -0,0 +1,42 @@
1
+ imagePullSecrets:
2
+ - name: regcred
3
+
4
+ ingress:
5
+ enabled: true
6
+ annotations:
7
+ kubernetes.io/ingress.class: nginx
8
+ kubernetes.io/tls-acme: 'true'
9
+ hosts:
10
+ - host: $REVIEW_URL
11
+ paths:
12
+ - path: /
13
+ tls:
14
+ - secretName: <%= @image_name %>
15
+ hosts:
16
+ - $REVIEW_URL
17
+
18
+ resources:
19
+ requests:
20
+ cpu: 100m
21
+ memory: 512Mi
22
+ limits:
23
+ memory: 512Mi
24
+
25
+ autoscaling:
26
+ enabled: true
27
+ minReplicas: 1
28
+ maxReplicas: 10
29
+ targetCPUUtilizationPercentage: 80
30
+
31
+ database:
32
+ url: $DATABASE_URL
33
+
34
+ master_key:
35
+ key: $MASTER_KEY
36
+
37
+ env:
38
+ RAILS_ENV: staging
39
+ URL: https://$REVIEW_URL/
40
+
41
+ redis:
42
+ enabled: true
@@ -0,0 +1,42 @@
1
+ imagePullSecrets:
2
+ - name: regcred
3
+
4
+ ingress:
5
+ enabled: true
6
+ annotations:
7
+ kubernetes.io/ingress.class: nginx
8
+ kubernetes.io/tls-acme: 'true'
9
+ hosts:
10
+ - host: <%= @staging_url %>
11
+ paths:
12
+ - path: /
13
+ tls:
14
+ - secretName: <%= @image_name %>
15
+ hosts:
16
+ - <%= @staging_url %>
17
+
18
+ resources:
19
+ requests:
20
+ cpu: 100m
21
+ memory: 512Mi
22
+ limits:
23
+ memory: 512Mi
24
+
25
+ autoscaling:
26
+ enabled: true
27
+ minReplicas: 1
28
+ maxReplicas: 10
29
+ targetCPUUtilizationPercentage: 80
30
+
31
+ database:
32
+ url: $DATABASE_URL
33
+
34
+ master_key:
35
+ key: $MASTER_KEY
36
+
37
+ env:
38
+ RAILS_ENV: staging
39
+ URL: https://<%= @staging_url %>/
40
+
41
+ redis:
42
+ enabled: true
@@ -16,6 +16,12 @@ class Modulorails::SidekiqGenerator < Rails::Generators::Base
16
16
  add_to_docker_compose_yml_file(Rails.root.join('docker-compose.prod.yml'))
17
17
  end
18
18
 
19
+ def add_to_deploy_files
20
+ add_to_deploy_file(Rails.root.join('config/deploy/production.yaml'))
21
+ add_to_deploy_file(Rails.root.join('config/deploy/staging.yaml'))
22
+ add_to_deploy_file(Rails.root.join('config/deploy/review.yaml'))
23
+ end
24
+
19
25
  def add_to_gemfile
20
26
  gemfile_path = Rails.root.join('Gemfile')
21
27
 
@@ -143,4 +149,30 @@ class Modulorails::SidekiqGenerator < Rails::Generators::Base
143
149
  end
144
150
  end
145
151
  end
152
+
153
+ def add_to_deploy_file(file_path)
154
+ # Do nothing if file does not exists or Sidekiq is already enabled
155
+ return if !File.exist?(file_path) || File.read(file_path).match?(/^ {2}sidekiq:$/)
156
+
157
+ # Add sidekiq to deploy file
158
+ insert_into_file file_path do
159
+ <<-YAML
160
+
161
+ sidekiq:
162
+ enabled: true
163
+ resources:
164
+ requests:
165
+ cpu: 100m
166
+ memory: 512Mi
167
+ limits:
168
+ cpu: 100m
169
+ memory: 512Mi
170
+ autoscaling:
171
+ enabled: true
172
+ minReplicas: 1
173
+ maxReplicas: 10
174
+ targetCPUUtilizationPercentage: 80
175
+ YAML
176
+ end
177
+ end
146
178
  end
@@ -1,6 +1,6 @@
1
1
  module Modulorails
2
2
 
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '1.3.1'.freeze
4
4
 
5
5
  # Useful to compare the current Ruby version
6
6
  COMPARABLE_RUBY_VERSION = Gem::Version.new(RUBY_VERSION)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulorails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu Ciappara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -211,6 +211,9 @@ files:
211
211
  - lib/generators/modulorails/gitlabci/gitlabci_generator.rb
212
212
  - lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt
213
213
  - lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci
214
+ - lib/generators/modulorails/gitlabci/templates/config/deploy/production.yaml.tt
215
+ - lib/generators/modulorails/gitlabci/templates/config/deploy/review.yaml.tt
216
+ - lib/generators/modulorails/gitlabci/templates/config/deploy/staging.yaml.tt
214
217
  - lib/generators/modulorails/healthcheck/health_check_generator.rb
215
218
  - lib/generators/modulorails/healthcheck/templates/.modulorails-health_check
216
219
  - lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt