rails_template_18f 1.3.0 → 2.1.0
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +64 -61
- data/README.md +11 -16
- data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +7 -6
- data/lib/generators/rails_template18f/circleci/circleci_generator.rb +28 -27
- data/lib/generators/rails_template18f/circleci/templates/Dockerfile.ci.tt +0 -1
- data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +162 -163
- data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +9 -1
- data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +31 -30
- data/lib/generators/rails_template18f/github_actions/templates/github/actions/compile-assets/action.yml +50 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt +4 -8
- data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +2 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +74 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +74 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-daily-scan.yml.tt +10 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt +1 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt +2 -2
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +49 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +49 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml +2 -2
- data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +147 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt +11 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +75 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml +7 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +28 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +212 -0
- data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +2 -2
- data/lib/generators/rails_template18f/i18n_js/templates/app/javascript/{i18n.js → i18n/index.js} +1 -1
- data/lib/generators/rails_template18f/i18n_js/templates/config/i18n-js.yml +1 -1
- data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +4 -2
- data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +71 -55
- data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +8 -17
- data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/imports.tf.tftpl +25 -0
- data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/main.tf.tt +159 -0
- data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/imports.tf.tftpl +10 -0
- data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/main.tf.tt +117 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +69 -95
- data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +57 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/apply.sh +15 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +8 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/bot_secrets.tftpl +5 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/users.auto.tfvars +5 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +117 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +13 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +18 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +8 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +95 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +98 -0
- data/lib/generators/rails_template18f/terraform/terraform_generator.rb +12 -4
- data/lib/rails_template18f/generators/cloud_gov_options.rb +9 -6
- data/lib/rails_template18f/generators/cloud_gov_parsing.rb +7 -7
- data/lib/rails_template18f/generators.rb +0 -1
- data/lib/rails_template18f/version.rb +1 -1
- data/rails-template-18f.gemspec +4 -4
- data/railsrc +4 -2
- data/railsrc-hotwire +4 -2
- data/template.rb +80 -82
- data/templates/README.md.tt +21 -8
- data/templates/app/assets/stylesheets/uswds-settings.scss +3 -2
- data/templates/app/views/application/_header.html.erb +1 -1
- data/templates/app/views/application/_usa_banner.html.erb +3 -3
- data/templates/bin/ops/create_service_account.sh.tt +20 -11
- data/templates/bin/ops/destroy_service_account.sh.tt +3 -3
- data/templates/browserslistrc +1 -2
- data/templates/doc/compliance/TODO.md +1 -4
- data/templates/{pa11yci.js → pa11yci.js.tt} +5 -0
- metadata +36 -35
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +0 -50
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +0 -50
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/import.sh +0 -13
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt +0 -22
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/providers.tf +0 -16
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt +0 -40
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +0 -5
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/variables.tf +0 -2
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +0 -90
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf +0 -23
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/variables.tf +0 -2
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +0 -70
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf +0 -23
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/variables.tf +0 -2
- data/lib/rails_template18f/generators/pipeline_options.rb +0 -18
- data/templates/app/assets/images/uswds.js +0 -6
- data/templates/config/deployment/production.yml +0 -3
- data/templates/config/deployment/staging.yml +0 -3
- data/templates/manifest.yml.tt +0 -17
data/template.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "colorize"
|
2
|
+
require "bundler/version"
|
2
3
|
|
3
4
|
## Supporting methods
|
4
5
|
# tell our template to grab all files from the templates directory
|
@@ -14,8 +15,8 @@ def skip_active_job?
|
|
14
15
|
!!options[:skip_active_job]
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
options[:javascript] == "
|
18
|
+
def esbuild?
|
19
|
+
options[:javascript] == "esbuild"
|
19
20
|
end
|
20
21
|
|
21
22
|
def hotwire?
|
@@ -26,9 +27,17 @@ def cloud_gov_org_tktk?
|
|
26
27
|
@cloud_gov_organization =~ /TKTK/
|
27
28
|
end
|
28
29
|
|
30
|
+
def gem_ruby_entry
|
31
|
+
if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2.4.20") # add file: option to #ruby
|
32
|
+
'ruby file: ".ruby-version"'
|
33
|
+
else
|
34
|
+
"ruby \"#{@ruby_version}\""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
@announcements = Hash.new { |h, k| h[k] = [] }
|
30
39
|
def register_announcement(section_name, instructions)
|
31
|
-
@announcements[section_name.to_sym] << instructions
|
40
|
+
@announcements[section_name.to_sym] << instructions.strip
|
32
41
|
end
|
33
42
|
|
34
43
|
def print_announcements
|
@@ -39,16 +48,18 @@ def print_announcements
|
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
42
|
-
unless Gem::Dependency.new("rails", "~>
|
43
|
-
warn "This template requires Rails
|
51
|
+
unless Gem::Dependency.new("rails", "~> 8.0.1").match?("rails", Rails.gem_version)
|
52
|
+
warn "This template requires Rails 8.0.x"
|
44
53
|
if Gem::Dependency.new("rails", "~> 6.1.0").match?("rails", Rails.gem_version)
|
45
54
|
warn "See the rails-6 branch https://github.com/gsa-tts/rails-template/tree/rails-6"
|
46
55
|
elsif Gem::Dependency.new("rails", "~> 7.0.0").match?("rails", Rails.gem_version)
|
47
56
|
warn "See the rails-7.0 branch https://github.com/gsa-tts/rails-template/tree/rails-7.0"
|
48
57
|
elsif Gem::Dependency.new("rails", "~> 7.1.0").match?("rails", Rails.gem_version)
|
49
58
|
warn "See the rails-7.1 branch https://github.com/gsa-tts/rails-template/tree/rails-7.1"
|
50
|
-
elsif Gem::Dependency.new("rails", "
|
51
|
-
warn "
|
59
|
+
elsif Gem::Dependency.new("rails", "~> 7.2.0").match?("rails", Rails.gem_version)
|
60
|
+
warn "See the rails-7.2 branch https://github.com/gsa-tts/rails-template/tree/rails-7.2"
|
61
|
+
elsif Gem::Dependency.new("rails", ">= 8.1.0").match?("rails", Rails.gem_version)
|
62
|
+
warn "We haven't updated the template for Rails >= 8.1 yet! Please file an issue so we can get the template updated"
|
52
63
|
else
|
53
64
|
warn "We didn't recognize the version of Rails you are using: #{Rails.version}"
|
54
65
|
end
|
@@ -77,16 +88,18 @@ if auditree
|
|
77
88
|
auditree_evidence_repo = ask("What is the https address of your auditree evidence repo? (Leave blank to fill in later)")
|
78
89
|
end
|
79
90
|
|
80
|
-
terraform = yes?("Create terraform files for cloud.gov services? (y/n)")
|
81
91
|
@cloud_gov_organization = ask("What is your cloud.gov organization name? (Leave blank to fill in later)")
|
82
92
|
default_staging_space = "staging"
|
83
93
|
cloud_gov_staging_space = ask("What is your cloud.gov staging space name? (Default: #{default_staging_space})")
|
84
|
-
default_prod_space = "
|
85
|
-
|
94
|
+
default_prod_space = "production"
|
95
|
+
if @cloud_gov_organization != "sandbox-gsa"
|
96
|
+
cloud_gov_production_space = ask("What is your cloud.gov production space name? (Default: #{default_prod_space})")
|
97
|
+
end
|
86
98
|
@cloud_gov_organization = "TKTK-cloud.gov-org-name" if @cloud_gov_organization.blank?
|
87
99
|
cloud_gov_staging_space = default_staging_space if cloud_gov_staging_space.blank?
|
88
100
|
cloud_gov_production_space = default_prod_space if cloud_gov_production_space.blank?
|
89
101
|
|
102
|
+
@gitlab_ci = yes?("Create GitLab CI config? (y/n)")
|
90
103
|
@github_actions = yes?("Create GitHub Actions? (y/n)")
|
91
104
|
@circleci_pipeline = yes?("Create CircleCI config? (y/n)")
|
92
105
|
newrelic = yes?("Create FEDRAMP New Relic config files? (y/n)")
|
@@ -106,6 +119,8 @@ running_node_version = `node --version`.gsub(/^v/, "").strip
|
|
106
119
|
run_db_setup = yes?("Run db setup steps? (y/n)")
|
107
120
|
|
108
121
|
## Start of app customizations
|
122
|
+
insert_into_file "Gemfile", "\n#{gem_ruby_entry}\n", after: /^source "https.*\n/
|
123
|
+
|
109
124
|
template "README.md", force: true
|
110
125
|
register_announcement("Documentation", <<~EOM)
|
111
126
|
* Complete the project README by adding a quick summary of the project in the top section.
|
@@ -118,6 +133,8 @@ if compliance_trestle
|
|
118
133
|
generator_arguments = []
|
119
134
|
generator_arguments << "--oscal_repo=#{compliance_trestle_repo}" if compliance_trestle_submodule
|
120
135
|
generator_arguments << "--ci=github" if @github_actions
|
136
|
+
generator_arguments << "--ci=gitlab" if @gitlab_ci
|
137
|
+
generator_arguments << "--ci=circleci" if @circleci_pipeline
|
121
138
|
generate "rails_template18f:oscal", *generator_arguments
|
122
139
|
end
|
123
140
|
register_announcement("OSCAL Documentation", <<~EOM)
|
@@ -179,7 +196,7 @@ chmod "bin/ops/create_service_account.sh", 0o755
|
|
179
196
|
chmod "bin/ops/destroy_service_account.sh", 0o755
|
180
197
|
chmod "bin/ops/set_space_egress.sh", 0o755
|
181
198
|
copy_file "pa11y.js"
|
182
|
-
|
199
|
+
template "pa11yci.js"
|
183
200
|
copy_file "editorconfig", ".editorconfig"
|
184
201
|
copy_file "zap.conf"
|
185
202
|
after_bundle do
|
@@ -187,7 +204,7 @@ after_bundle do
|
|
187
204
|
end
|
188
205
|
|
189
206
|
# updates for OWASP scan to pass
|
190
|
-
gem "secure_headers", "~>
|
207
|
+
gem "secure_headers", "~> 7.1"
|
191
208
|
initializer "secure_headers.rb", <<~EOM
|
192
209
|
SecureHeaders::Configuration.default do |config|
|
193
210
|
# CSP settings are handled by Rails
|
@@ -226,22 +243,16 @@ uncomment_lines csp_initializer, "content_security_policy_nonce"
|
|
226
243
|
|
227
244
|
# install development & testing gems
|
228
245
|
gem_group :development, :test do
|
229
|
-
gem "rspec-rails", "~>
|
246
|
+
gem "rspec-rails", "~> 7.1"
|
230
247
|
gem "dotenv-rails", "~> 3.1"
|
231
248
|
gem "bundler-audit", "~> 0.9"
|
232
|
-
gem "standard", "~> 1.
|
249
|
+
gem "standard", "~> 1.43"
|
233
250
|
end
|
234
251
|
if ENV["RT_DEV"] == "true"
|
235
252
|
gem "rails_template_18f", group: :development, path: ENV["PWD"]
|
236
253
|
else
|
237
254
|
gem "rails_template_18f", group: :development
|
238
255
|
end
|
239
|
-
after_bundle do
|
240
|
-
gsub_file "bin/dev", /foreman start -f (.*)$/, <<~'EOM'
|
241
|
-
# pass /dev/null for the environment file to prevent weird interactions between foreman and dotenv
|
242
|
-
foreman start -e /dev/null -f \1
|
243
|
-
EOM
|
244
|
-
end
|
245
256
|
|
246
257
|
copy_file "lib/tasks/scanning.rake"
|
247
258
|
copy_file "env", ".env"
|
@@ -269,27 +280,19 @@ unless skip_git?
|
|
269
280
|
end
|
270
281
|
|
271
282
|
# setup USWDS and asset pipeline
|
272
|
-
copy_file "browserslistrc", ".browserslistrc"
|
283
|
+
copy_file "browserslistrc", ".browserslistrc"
|
273
284
|
after_bundle do
|
274
|
-
run 'npm pkg set scripts.build:css="postcss ./app/assets/stylesheets/application.postcss.scss -o ./app/assets/builds/application.css"'
|
275
|
-
# include verbose flag for dev postcss output
|
276
|
-
gsub_file "Procfile.dev", "yarn build:css --watch", "yarn build:css --verbose --watch"
|
277
|
-
# Replace postcss-nesting with sass since USWDS uses sass
|
278
|
-
run "yarn remove postcss-nesting"
|
279
|
-
run "yarn add @csstools/postcss-sass postcss-scss postcss-minify"
|
280
|
-
insert_into_file "postcss.config.js", " syntax: 'postcss-scss',\n", before: /^\s+plugins/
|
281
|
-
insert_into_file "package.json", <<-EOJSON, before: /^\s+\}$/
|
282
|
-
},
|
283
|
-
"resolutions": {
|
284
|
-
"@csstools/postcss-sass/@csstools/sass-import-resolve": "https://github.com/rahearn/sass-import-resolve"
|
285
|
-
EOJSON
|
286
|
-
gsub_file "postcss.config.js", "postcss-nesting'),", <<~EOJS.strip
|
287
|
-
@csstools/postcss-sass')({
|
288
|
-
includePaths: ['./node_modules/@uswds/uswds/packages'],
|
289
|
-
}),
|
290
|
-
EOJS
|
291
|
-
insert_into_file "postcss.config.js", " process.env.NODE_ENV === 'production' ? require('postcss-minify') : null,\n", before: /^\s+\],/
|
292
285
|
run "yarn add @uswds/uswds"
|
286
|
+
if esbuild?
|
287
|
+
run "yarn add --dev browserslist browserslist-to-esbuild"
|
288
|
+
run 'npm pkg set scripts.build:js="esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets --target=\$(cat config/esbuild-targets.txt) --pure:console.log"'
|
289
|
+
run 'npm pkg set scripts.build="yarn build:js --minify"'
|
290
|
+
run 'npm pkg set scripts.update-browserslist="update-browserslist-db && browserslist-to-esbuild | sed \'s/ /,/g\' > config/esbuild-targets.txt"'
|
291
|
+
run "yarn update-browserslist"
|
292
|
+
gsub_file "Procfile.dev", "js: yarn build --watch", "js: yarn build:js --watch"
|
293
|
+
end
|
294
|
+
gsub_file "package.json", "--load-path=node_modules", "--load-path=node_modules/@uswds/uswds/packages --style=compressed"
|
295
|
+
gsub_file "Procfile.dev", "css: yarn build:css --watch", "css: yarn build:css --style=expanded --watch"
|
293
296
|
appjs_file = "app/javascript/application.js"
|
294
297
|
append_to_file appjs_file, "\nimport \"@uswds/uswds\"\n"
|
295
298
|
if hotwire?
|
@@ -313,15 +316,12 @@ after_bundle do
|
|
313
316
|
EOJS
|
314
317
|
end
|
315
318
|
directory "app/assets"
|
316
|
-
append_to_file "app/assets/stylesheets/application.
|
319
|
+
append_to_file "app/assets/stylesheets/application.sass.scss", <<~EOCSS
|
317
320
|
@forward "uswds-settings";
|
318
321
|
@forward "uswds-components";
|
319
322
|
|
320
323
|
@forward "uswds-overrides";
|
321
324
|
EOCSS
|
322
|
-
inside "app/assets/stylesheets" do
|
323
|
-
File.rename("application.postcss.css", "application.postcss.scss")
|
324
|
-
end
|
325
325
|
gsub_file "app/views/layouts/application.html.erb", "<html>", '<html lang="<%= I18n.locale %>">'
|
326
326
|
gsub_file "app/views/layouts/application.html.erb", /^\s+<%= yield %>/, <<-EOHTML
|
327
327
|
<%= render "application/usa_banner" %>
|
@@ -332,7 +332,13 @@ after_bundle do
|
|
332
332
|
</div>
|
333
333
|
</main>
|
334
334
|
EOHTML
|
335
|
-
append_to_file "config/initializers/assets.rb",
|
335
|
+
append_to_file "config/initializers/assets.rb", <<~EOC
|
336
|
+
Rails.application.configure do
|
337
|
+
config.assets.paths << Rails.root.join("node_modules/@uswds/uswds/dist/img")
|
338
|
+
config.assets.paths << Rails.root.join("node_modules/@uswds/uswds/dist/fonts")
|
339
|
+
config.assets.excluded_paths << Rails.root.join("app/assets/stylesheets")
|
340
|
+
end
|
341
|
+
EOC
|
336
342
|
end
|
337
343
|
directory "app/views/application"
|
338
344
|
|
@@ -387,29 +393,25 @@ if dap
|
|
387
393
|
end
|
388
394
|
|
389
395
|
# infrastructure & deploy
|
390
|
-
template "manifest.yml"
|
391
396
|
copy_file "lib/tasks/cf.rake"
|
392
|
-
directory "config/deployment"
|
393
397
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
EOM
|
410
|
-
end
|
411
|
-
register_announcement("Terraform", "Run the bootstrap script and update the appropriate CI/CD environment variables defined in the Deployment section of the README")
|
398
|
+
after_bundle do
|
399
|
+
generator_arguments = [
|
400
|
+
"--cg-org=#{@cloud_gov_organization}",
|
401
|
+
"--cg-staging=#{cloud_gov_staging_space}",
|
402
|
+
"--cg-prod=#{cloud_gov_production_space}"
|
403
|
+
]
|
404
|
+
generate "rails_template18f:terraform", *generator_arguments
|
405
|
+
end
|
406
|
+
if cloud_gov_org_tktk?
|
407
|
+
register_announcement("Terraform", <<~EOM)
|
408
|
+
Fill in the cloud.gov organization and space information in:
|
409
|
+
* terraform/bootstrap/main.tf
|
410
|
+
* terraform/main.tf
|
411
|
+
* terraform/*.tfvars
|
412
|
+
EOM
|
412
413
|
end
|
414
|
+
register_announcement("Terraform", "Run the bootstrap script and update the appropriate CI/CD environment variables defined in the Deployment section of the README")
|
413
415
|
|
414
416
|
if !skip_active_job?
|
415
417
|
after_bundle do
|
@@ -426,18 +428,12 @@ end
|
|
426
428
|
if @github_actions
|
427
429
|
after_bundle do
|
428
430
|
generator_arguments = [
|
429
|
-
(terraform ? "--terraform" : "--no-terraform"),
|
430
431
|
"--cg-org=#{@cloud_gov_organization}",
|
431
432
|
"--cg-staging=#{cloud_gov_staging_space}",
|
432
433
|
"--cg-prod=#{cloud_gov_production_space}"
|
433
434
|
]
|
434
435
|
generate "rails_template18f:github_actions", *generator_arguments
|
435
436
|
end
|
436
|
-
if cloud_gov_org_tktk?
|
437
|
-
register_announcement("GitHub Actions", <<~EOM)
|
438
|
-
* Fill in the cloud.gov organization information in .github/workflows/deploy-staging.yml
|
439
|
-
EOM
|
440
|
-
end
|
441
437
|
register_announcement("GitHub Actions", <<~EOM)
|
442
438
|
* Create environment variable secrets for deploy users as defined in the Deployment section of the README
|
443
439
|
EOM
|
@@ -446,23 +442,31 @@ end
|
|
446
442
|
if @circleci_pipeline
|
447
443
|
after_bundle do
|
448
444
|
generator_arguments = [
|
449
|
-
(terraform ? "--terraform" : "--no-terraform"),
|
450
445
|
"--cg-org=#{@cloud_gov_organization}",
|
451
446
|
"--cg-staging=#{cloud_gov_staging_space}",
|
452
447
|
"--cg-prod=#{cloud_gov_production_space}"
|
453
448
|
]
|
454
449
|
generate "rails_template18f:circleci", *generator_arguments
|
455
450
|
end
|
456
|
-
if cloud_gov_org_tktk?
|
457
|
-
register_announcement("CircleCI", <<~EOM)
|
458
|
-
* Fill in the cloud.gov organization information in .circleci/config.yml
|
459
|
-
EOM
|
460
|
-
end
|
461
451
|
register_announcement("CircleCI", <<~EOM)
|
462
452
|
* Create project environment variables for deploy users as defined in the Deployment section of the README
|
463
453
|
EOM
|
464
454
|
end
|
465
455
|
|
456
|
+
if @gitlab_ci
|
457
|
+
after_bundle do
|
458
|
+
generator_arguments = [
|
459
|
+
"--cg-org=#{@cloud_gov_organization}",
|
460
|
+
"--cg-staging=#{cloud_gov_staging_space}",
|
461
|
+
"--cg-prod=#{cloud_gov_production_space}"
|
462
|
+
]
|
463
|
+
generate "rails_template18f:gitlab_ci", *generator_arguments
|
464
|
+
end
|
465
|
+
register_announcement("GitLab CI", <<~EOM)
|
466
|
+
* Create project environment variables for deploy users as defined in the Deployment section of the README
|
467
|
+
EOM
|
468
|
+
end
|
469
|
+
|
466
470
|
if auditree
|
467
471
|
after_bundle do
|
468
472
|
generate "rails_template18f:auditree", "--evidence_locker=#{auditree_evidence_repo}"
|
@@ -513,12 +517,6 @@ after_bundle do
|
|
513
517
|
run "bundle exec standardrb --fix"
|
514
518
|
|
515
519
|
unless skip_git?
|
516
|
-
run "cp .gitignore .cfignore"
|
517
|
-
append_to_file ".cfignore", <<~EOM
|
518
|
-
|
519
|
-
# compliance documentation
|
520
|
-
/doc/compliance/
|
521
|
-
EOM
|
522
520
|
if compliance_trestle_submodule
|
523
521
|
inside "doc/compliance/oscal" do
|
524
522
|
run "git add -A"
|
data/templates/README.md.tt
CHANGED
@@ -110,34 +110,47 @@ To enable automatic ruby linting on every `git commit` follow the instructions a
|
|
110
110
|
Each environment has dependencies on a PostgreSQL RDS instance managed by cloud.gov.
|
111
111
|
See [cloud.gov docs](https://cloud.gov/docs/services/relational-database/) for information on RDS.
|
112
112
|
|
113
|
+
Terraform is used to deploy the application and supporting services. See [terraform/README.md](./terraform/README.md)
|
114
|
+
for more information on how to set up your terraform backend and deploy the app.
|
115
|
+
|
113
116
|
#### Staging
|
114
117
|
<% if !@github_actions && !@circleci_pipeline %>
|
115
|
-
|
118
|
+
First, follow the `terraform/README.md` instructions to set up your backend, then:
|
116
119
|
|
117
|
-
|
120
|
+
```bash
|
121
|
+
$ cd terraform
|
122
|
+
$ ./terraform.sh -e staging -c apply
|
123
|
+
```
|
118
124
|
<% end %>
|
119
125
|
|
120
126
|
#### Production
|
121
127
|
<% if !@github_actions && !@circleci_pipeline %>
|
122
|
-
|
128
|
+
First, follow the `terraform/README.md` instructions to set up your backend, then:
|
123
129
|
|
124
|
-
|
130
|
+
```bash
|
131
|
+
$ cd terraform
|
132
|
+
$ ./terraform.sh -e production -k $(cat ../config/credentials/production.key) -c apply
|
133
|
+
```
|
125
134
|
<% end %>
|
126
135
|
|
127
136
|
### Configuring ENV variables in cloud.gov
|
128
137
|
|
129
138
|
All configuration that needs to be added to the deployed application's ENV should be added to
|
130
|
-
the `
|
139
|
+
the `environment = {}` block in `terraform/app.tf`
|
140
|
+
|
141
|
+
Items that are both **public** and **consistent** across environments can be set directly there.
|
131
142
|
|
132
|
-
|
143
|
+
Otherwise:
|
133
144
|
|
134
|
-
|
145
|
+
1. add a new `variable "variable_name" {}` block to `terraform/variables.tf`
|
146
|
+
2. add a new entry in the `environment = {}` block to reference that variable
|
147
|
+
3. set that variable depending on sensitivity:
|
135
148
|
|
136
149
|
#### Credentials and other Secrets
|
137
150
|
|
138
151
|
#### Non-secrets
|
139
152
|
|
140
|
-
Configuration that changes
|
153
|
+
Configuration that changes by environment, but is public, should be added to the `tfvars` files, such as `terraform/production.tfvars` and `terraform/staging.tfvars`
|
141
154
|
|
142
155
|
## Documentation
|
143
156
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
@use "uswds-core" with (
|
2
2
|
// Point the asset pipline to the correct locations
|
3
|
-
|
4
|
-
$theme-
|
3
|
+
// empty strings are on purpose to override the defaults
|
4
|
+
$theme-font-path: "",
|
5
|
+
$theme-image-path: "",
|
5
6
|
|
6
7
|
$theme-show-notifications: false,
|
7
8
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
</div>
|
15
15
|
<nav aria-label="<%= t('shared.header.primary') %>" class="usa-nav">
|
16
16
|
<button class="usa-nav__close">
|
17
|
-
<%= image_tag "
|
17
|
+
<%= image_tag "usa-icons/close.svg", role: "img", alt: t('shared.header.close') %>
|
18
18
|
</button>
|
19
19
|
<ul class="usa-nav__primary usa-accordion">
|
20
20
|
<li class="usa-nav__primary-item">
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<div class="usa-banner__inner">
|
7
7
|
<div class="banner__text-container grid-row">
|
8
8
|
<div class="grid-col-auto">
|
9
|
-
<%= image_tag "
|
9
|
+
<%= image_tag "us_flag_small.png", alt: t('shared.banner.us_flag'), class: "usa-banner__header-flag" %>
|
10
10
|
</div>
|
11
11
|
<div class="grid-col-fill tablet:grid-col-auto">
|
12
12
|
<p class="usa-banner__header-text">
|
@@ -35,14 +35,14 @@
|
|
35
35
|
<% end %>
|
36
36
|
<div class="grid-row grid-gap-lg">
|
37
37
|
<div class="usa-banner__guidance tablet:grid-col-6">
|
38
|
-
<%= image_tag "
|
38
|
+
<%= image_tag "icon-dot-gov.svg", role: "img", "aria-hidden": true, class: "usa-banner__icon usa-media-block__img" %>
|
39
39
|
<div class="usa-media-block__body">
|
40
40
|
<strong><%= t('shared.banner.gov_heading') %></strong>
|
41
41
|
<br> <%= t('shared.banner.gov_description_html') %>
|
42
42
|
</div>
|
43
43
|
</div>
|
44
44
|
<div class="usa-banner__guidance tablet:grid-col-6">
|
45
|
-
<%= image_tag "
|
45
|
+
<%= image_tag "icon-https.svg", role: "img", "aria-hidden": true, class: "usa-banner__icon usa-media-block__img" %>
|
46
46
|
<div class="usa-media-block__body">
|
47
47
|
<p>
|
48
48
|
<strong><%= t('shared.banner.secure_heading') %></strong>
|
@@ -7,7 +7,7 @@ $0: Create a Service User Account for a given space
|
|
7
7
|
|
8
8
|
Usage:
|
9
9
|
$0 -h
|
10
|
-
$0 -s <SPACE NAME> -u <USER NAME> [-r <ROLE NAME>] [-o <ORG NAME>] [-m]
|
10
|
+
$0 -s <SPACE NAME> -u <USER NAME> [-r <ROLE NAME>] [-o <ORG NAME>] [-m] [-n]
|
11
11
|
|
12
12
|
Options:
|
13
13
|
-h: show help and exit
|
@@ -15,10 +15,12 @@ Options:
|
|
15
15
|
-u <USER NAME>: set the service user name. Required
|
16
16
|
-r <ROLE NAME>: set the service user's role to either space-deployer or space-auditor. Default: space-deployer
|
17
17
|
-m: If provided, make the service user an OrgManager
|
18
|
+
-n: If provided, make the service user a SpaceManager
|
18
19
|
-o <ORG NAME>: configure the organization to act on. Default: $org
|
19
20
|
|
20
21
|
Notes:
|
21
|
-
* OrgManager is required for terraform to create
|
22
|
+
* OrgManager is required for terraform to create spaces
|
23
|
+
* OrgManager or SpaceManager is required for terraform to set egress rules
|
22
24
|
"
|
23
25
|
|
24
26
|
set -e
|
@@ -28,8 +30,9 @@ space=""
|
|
28
30
|
service=""
|
29
31
|
role="space-deployer"
|
30
32
|
org_manager="false"
|
33
|
+
space_manager="false"
|
31
34
|
|
32
|
-
while getopts ":
|
35
|
+
while getopts ":hmns:u:r:o:" opt; do
|
33
36
|
case "$opt" in
|
34
37
|
s)
|
35
38
|
space=${OPTARG}
|
@@ -46,6 +49,9 @@ while getopts ":hms:u:r:o:" opt; do
|
|
46
49
|
m)
|
47
50
|
org_manager="true"
|
48
51
|
;;
|
52
|
+
n)
|
53
|
+
space_manager="true"
|
54
|
+
;;
|
49
55
|
h)
|
50
56
|
echo "$usage"
|
51
57
|
exit 0
|
@@ -59,26 +65,29 @@ then
|
|
59
65
|
exit 1
|
60
66
|
fi
|
61
67
|
|
62
|
-
if [[ $space
|
68
|
+
if [[ -z "$space" || -z "$service" ]]; then
|
63
69
|
echo "$usage"
|
64
70
|
exit 1
|
65
71
|
fi
|
66
72
|
|
67
|
-
cf target -o $org -s $space 1>&2
|
73
|
+
cf target -o "$org" -s "$space" 1>&2
|
68
74
|
|
69
75
|
# create user account service
|
70
|
-
cf create-service cloud-gov-service-account $role $service 1>&2
|
76
|
+
cf create-service cloud-gov-service-account "$role" "$service" 1>&2
|
71
77
|
|
72
78
|
# create service key
|
73
|
-
cf create-service-key $service service-account-key 1>&2
|
79
|
+
cf create-service-key "$service" service-account-key 1>&2
|
74
80
|
|
75
81
|
# output service key to stdout in secrets.auto.tfvars format
|
76
|
-
creds=`cf service-key $service service-account-key | tail -n +2 | jq '.credentials'`
|
77
|
-
username=`echo $creds | jq -r '.username'`
|
78
|
-
password=`echo $creds | jq -r '.password'`
|
82
|
+
creds=`cf service-key "$service" service-account-key | tail -n +2 | jq '.credentials'`
|
83
|
+
username=`echo "$creds" | jq -r '.username'`
|
84
|
+
password=`echo "$creds" | jq -r '.password'`
|
79
85
|
|
80
86
|
if [[ "$org_manager" = "true" ]]; then
|
81
|
-
cf set-org-role $username $org OrgManager 1>&2
|
87
|
+
cf set-org-role "$username" "$org" OrgManager 1>&2
|
88
|
+
fi
|
89
|
+
if [[ "$space_manager" = "true" ]]; then
|
90
|
+
cf set-space-role "$username" "$org" "$space" SpaceManager 1>&2
|
82
91
|
fi
|
83
92
|
|
84
93
|
cat << EOF
|
@@ -39,12 +39,12 @@ while getopts ":hs:u:o:" opt; do
|
|
39
39
|
esac
|
40
40
|
done
|
41
41
|
|
42
|
-
if [[ $space
|
42
|
+
if [[ -z "$space" || -z "$service" ]]; then
|
43
43
|
echo "$usage"
|
44
44
|
exit 1
|
45
45
|
fi
|
46
46
|
|
47
|
-
cf target -o $org -s $space
|
47
|
+
cf target -o "$org" -s "$space"
|
48
48
|
|
49
49
|
# destroy service
|
50
|
-
cf delete-service $service
|
50
|
+
cf delete-service -f "$service"
|
data/templates/browserslistrc
CHANGED
@@ -10,10 +10,7 @@ Egress Spaces
|
|
10
10
|
|
11
11
|
If your application requires outbound communication to services outside of cloud.gov:
|
12
12
|
|
13
|
-
1.
|
14
|
-
1. Set that space to public egress with `bin/ops/set_space_egress.sh -s <env>-egress -p`
|
15
|
-
1. Run [cg-egress-proxy](https://github.com/GSA/cg-egress-proxy#deploying-proxies-for-a-bunch-of-apps-automatically) in that space
|
16
|
-
1. Send all outbound traffic from your app through the proxy
|
13
|
+
1. `bin/rails g rails_template18f:public_egress`
|
17
14
|
1. Document this use under the SC-7 security control
|
18
15
|
|
19
16
|
Log Drains
|
@@ -2,7 +2,12 @@ let defaults = require("./pa11y.js");
|
|
2
2
|
|
3
3
|
// set chrome path for github actions
|
4
4
|
defaults.defaults.chromeLaunchConfig = {
|
5
|
+
<% if @gitlab_ci %>
|
6
|
+
"executablePath": "/usr/bin/chromium",
|
7
|
+
"args": ["--no-sandbox"]
|
8
|
+
<% else %>
|
5
9
|
"executablePath": "/usr/bin/google-chrome"
|
10
|
+
<% end %>
|
6
11
|
};
|
7
12
|
|
8
13
|
module.exports = defaults;
|