rails_template_18f 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -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 +152 -163
- 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 +72 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +72 -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 +46 -3
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +46 -3
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml +2 -2
- 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 +86 -54
- 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 +77 -93
- data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +63 -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 +106 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +10 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +32 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/main.tf +74 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/run.sh +17 -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 +135 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +99 -0
- data/lib/generators/rails_template18f/terraform/terraform_generator.rb +13 -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 +61 -71
- 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
- metadata +30 -29
- 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
@@ -0,0 +1,72 @@
|
|
1
|
+
name: Deploy Production
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ production ]
|
6
|
+
paths-ignore:
|
7
|
+
- 'doc/**'
|
8
|
+
- 'README.md'
|
9
|
+
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
pull-requests: write
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
build-assets:
|
16
|
+
name: Compile and clean assets
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v4
|
20
|
+
- name: Compile assets
|
21
|
+
uses: ./.github/actions/compile-assets
|
22
|
+
with:
|
23
|
+
rails_env: production
|
24
|
+
save_cache: true
|
25
|
+
- name: Upload assets
|
26
|
+
uses: actions/upload-artifact@v4
|
27
|
+
with:
|
28
|
+
name: production-assets
|
29
|
+
path: public/assets
|
30
|
+
|
31
|
+
deploy:
|
32
|
+
name: Deploy to production
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
needs: build-assets
|
35
|
+
environment: production
|
36
|
+
env:
|
37
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
38
|
+
steps:
|
39
|
+
- uses: actions/checkout@v4
|
40
|
+
|
41
|
+
- name: Download assets
|
42
|
+
uses: actions/download-artifact@v4
|
43
|
+
with:
|
44
|
+
name: production-assets
|
45
|
+
path: public/assets
|
46
|
+
|
47
|
+
- name: Terraform apply
|
48
|
+
uses: dflook/terraform-apply@v1
|
49
|
+
env:
|
50
|
+
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
|
51
|
+
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
|
52
|
+
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
|
53
|
+
TERRAFORM_PRE_RUN: |
|
54
|
+
apt-get update
|
55
|
+
apt-get install -y zip
|
56
|
+
with:
|
57
|
+
path: terraform
|
58
|
+
var_file: terraform/production.tfvars
|
59
|
+
backend_config: >
|
60
|
+
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
61
|
+
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
62
|
+
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
|
63
|
+
key=terraform.tfstate.production
|
64
|
+
|
65
|
+
- name: Save app zip for debugging
|
66
|
+
if: failure()
|
67
|
+
uses: actions/upload-artifact@v4
|
68
|
+
with:
|
69
|
+
name: app-src-apply
|
70
|
+
path: terraform/dist/src.zip
|
71
|
+
compression-level: 0
|
72
|
+
retention-days: 1
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
name: Deploy Staging
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
paths-ignore:
|
7
|
+
- 'doc/**'
|
8
|
+
- 'README.md'
|
9
|
+
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
pull-requests: write
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
build-assets:
|
16
|
+
name: Compile and clean assets
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v4
|
20
|
+
- name: Compile assets
|
21
|
+
uses: ./.github/actions/compile-assets
|
22
|
+
with:
|
23
|
+
rails_env: staging
|
24
|
+
save_cache: true
|
25
|
+
- name: Upload assets
|
26
|
+
uses: actions/upload-artifact@v4
|
27
|
+
with:
|
28
|
+
name: staging-assets
|
29
|
+
path: public/assets
|
30
|
+
|
31
|
+
deploy:
|
32
|
+
name: Deploy to staging
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
needs: build-assets
|
35
|
+
environment: staging
|
36
|
+
env:
|
37
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
38
|
+
steps:
|
39
|
+
- uses: actions/checkout@v4
|
40
|
+
|
41
|
+
- name: Download assets
|
42
|
+
uses: actions/download-artifact@v4
|
43
|
+
with:
|
44
|
+
name: staging-assets
|
45
|
+
path: public/assets
|
46
|
+
|
47
|
+
- name: Terraform apply
|
48
|
+
uses: dflook/terraform-apply@v1
|
49
|
+
env:
|
50
|
+
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
|
51
|
+
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
|
52
|
+
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
|
53
|
+
TERRAFORM_PRE_RUN: |
|
54
|
+
apt-get update
|
55
|
+
apt-get install -y zip
|
56
|
+
with:
|
57
|
+
path: terraform
|
58
|
+
var_file: terraform/staging.tfvars
|
59
|
+
backend_config: >
|
60
|
+
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
61
|
+
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
62
|
+
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
|
63
|
+
key=terraform.tfstate.staging
|
64
|
+
|
65
|
+
- name: Save app zip for debugging
|
66
|
+
if: failure()
|
67
|
+
uses: actions/upload-artifact@v4
|
68
|
+
with:
|
69
|
+
name: app-src-apply
|
70
|
+
path: terraform/dist/src.zip
|
71
|
+
compression-level: 0
|
72
|
+
retention-days: 1
|
@@ -31,6 +31,15 @@ jobs:
|
|
31
31
|
steps:
|
32
32
|
- uses: actions/checkout@v4
|
33
33
|
|
34
|
+
- name: Touch staging cache
|
35
|
+
uses: ./.github/actions/compile-assets
|
36
|
+
with:
|
37
|
+
rails_env: staging
|
38
|
+
- name: Touch production cache
|
39
|
+
uses: ./.github/actions/compile-assets
|
40
|
+
with:
|
41
|
+
rails_env: production
|
42
|
+
|
34
43
|
- id: setup
|
35
44
|
uses: ./.github/actions/setup-project
|
36
45
|
|
@@ -39,7 +48,7 @@ jobs:
|
|
39
48
|
database_url: ${{ steps.setup.outputs.database_url }}
|
40
49
|
|
41
50
|
- name: Run OWASP Full Scan
|
42
|
-
uses: zaproxy/action-full-scan@v0.
|
51
|
+
uses: zaproxy/action-full-scan@v0.12.0
|
43
52
|
with:
|
44
53
|
token: ${{ secrets.GITHUB_TOKEN }}
|
45
54
|
docker_name: 'ghcr.io/zaproxy/zaproxy:weekly'
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt
CHANGED
@@ -38,7 +38,7 @@ jobs:
|
|
38
38
|
database_url: ${{ steps.setup.outputs.database_url }}
|
39
39
|
|
40
40
|
- name: Run OWASP Baseline Scan
|
41
|
-
uses: zaproxy/action-baseline@v0.
|
41
|
+
uses: zaproxy/action-baseline@v0.14.0
|
42
42
|
with:
|
43
43
|
docker_name: 'ghcr.io/zaproxy/zaproxy:weekly'
|
44
44
|
target: 'http://localhost:3000/'
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt
CHANGED
@@ -49,7 +49,7 @@ jobs:
|
|
49
49
|
|
50
50
|
- name: Comment on pull request
|
51
51
|
if: failure()
|
52
|
-
uses: actions/github-script@
|
52
|
+
uses: actions/github-script@v7
|
53
53
|
with:
|
54
54
|
script: |
|
55
55
|
const output = `Pa11y Failures detected
|
@@ -61,7 +61,7 @@ jobs:
|
|
61
61
|
\`\`\`
|
62
62
|
</details>`;
|
63
63
|
|
64
|
-
github.issues.createComment({
|
64
|
+
github.rest.issues.createComment({
|
65
65
|
issue_number: context.issue.number,
|
66
66
|
owner: context.repo.owner,
|
67
67
|
repo: context.repo.repo,
|
@@ -9,9 +9,28 @@ permissions:
|
|
9
9
|
pull-requests: write
|
10
10
|
|
11
11
|
jobs:
|
12
|
+
build-assets:
|
13
|
+
name: Compile and clean assets
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
- name: Compile assets
|
18
|
+
uses: ./.github/actions/compile-assets
|
19
|
+
with:
|
20
|
+
rails_env: production
|
21
|
+
# you may want to enable the next line to surface issues with missing assets,
|
22
|
+
# but not until after you've deployed once and the cache has been created
|
23
|
+
# fail_on_missing_cache: true
|
24
|
+
- name: Upload assets
|
25
|
+
uses: actions/upload-artifact@v4
|
26
|
+
with:
|
27
|
+
name: production-assets
|
28
|
+
path: public/assets
|
29
|
+
|
12
30
|
terraform:
|
13
31
|
name: Terraform plan
|
14
32
|
runs-on: ubuntu-latest
|
33
|
+
needs: build-assets
|
15
34
|
environment: production
|
16
35
|
env:
|
17
36
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -22,20 +41,44 @@ jobs:
|
|
22
41
|
- name: terraform validate
|
23
42
|
uses: dflook/terraform-validate@v1
|
24
43
|
with:
|
25
|
-
path: terraform
|
44
|
+
path: terraform
|
26
45
|
|
27
46
|
- name: terraform fmt
|
28
47
|
uses: dflook/terraform-fmt-check@v1
|
29
48
|
with:
|
30
|
-
path: terraform
|
49
|
+
path: terraform
|
50
|
+
|
51
|
+
- name: Download assets
|
52
|
+
uses: actions/download-artifact@v4
|
53
|
+
with:
|
54
|
+
name: production-assets
|
55
|
+
path: public/assets
|
31
56
|
|
32
57
|
- name: terraform plan
|
33
58
|
uses: dflook/terraform-plan@v1
|
34
59
|
env:
|
35
60
|
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
|
36
61
|
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
|
62
|
+
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
|
63
|
+
TERRAFORM_PRE_RUN: |
|
64
|
+
apt-get update
|
65
|
+
apt-get install -y zip
|
37
66
|
with:
|
38
|
-
path: terraform
|
67
|
+
path: terraform
|
68
|
+
var_file: terraform/production.tfvars
|
69
|
+
add_github_comment: changes-only
|
39
70
|
backend_config: >
|
40
71
|
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
41
72
|
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
73
|
+
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
|
74
|
+
key=terraform.tfstate.production
|
75
|
+
|
76
|
+
# Uncomment this step if you need to debug issues
|
77
|
+
# with mismatched app checksum between plan and apply
|
78
|
+
# - name: Save app zip for debugging
|
79
|
+
# uses: actions/upload-artifact@v4
|
80
|
+
# with:
|
81
|
+
# name: app-src-plan
|
82
|
+
# path: terraform/dist/src.zip
|
83
|
+
# compression-level: 0
|
84
|
+
# retention-days: 1
|
@@ -9,9 +9,28 @@ permissions:
|
|
9
9
|
pull-requests: write
|
10
10
|
|
11
11
|
jobs:
|
12
|
+
build-assets:
|
13
|
+
name: Compile and clean assets
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
- name: Compile assets
|
18
|
+
uses: ./.github/actions/compile-assets
|
19
|
+
with:
|
20
|
+
rails_env: staging
|
21
|
+
# you may want to enable the next line to surface issues with missing assets,
|
22
|
+
# but not until after you've deployed once and the cache has been created
|
23
|
+
# fail_on_missing_cache: true
|
24
|
+
- name: Upload assets
|
25
|
+
uses: actions/upload-artifact@v4
|
26
|
+
with:
|
27
|
+
name: staging-assets
|
28
|
+
path: public/assets
|
29
|
+
|
12
30
|
terraform:
|
13
31
|
name: Terraform plan
|
14
32
|
runs-on: ubuntu-latest
|
33
|
+
needs: build-assets
|
15
34
|
environment: staging
|
16
35
|
env:
|
17
36
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -22,20 +41,44 @@ jobs:
|
|
22
41
|
- name: terraform validate
|
23
42
|
uses: dflook/terraform-validate@v1
|
24
43
|
with:
|
25
|
-
path: terraform
|
44
|
+
path: terraform
|
26
45
|
|
27
46
|
- name: terraform fmt
|
28
47
|
uses: dflook/terraform-fmt-check@v1
|
29
48
|
with:
|
30
|
-
path: terraform
|
49
|
+
path: terraform
|
50
|
+
|
51
|
+
- name: Download assets
|
52
|
+
uses: actions/download-artifact@v4
|
53
|
+
with:
|
54
|
+
name: staging-assets
|
55
|
+
path: public/assets
|
31
56
|
|
32
57
|
- name: terraform plan
|
33
58
|
uses: dflook/terraform-plan@v1
|
34
59
|
env:
|
35
60
|
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
|
36
61
|
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
|
62
|
+
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
|
63
|
+
TERRAFORM_PRE_RUN: |
|
64
|
+
apt-get update
|
65
|
+
apt-get install -y zip
|
37
66
|
with:
|
38
|
-
path: terraform
|
67
|
+
path: terraform
|
68
|
+
var_file: terraform/staging.tfvars
|
69
|
+
add_github_comment: changes-only
|
39
70
|
backend_config: >
|
40
71
|
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
41
72
|
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
73
|
+
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
|
74
|
+
key=terraform.tfstate.staging
|
75
|
+
|
76
|
+
# Uncomment this step if you need to debug issues
|
77
|
+
# with mismatched app checksum between plan and apply
|
78
|
+
# - name: Save app zip for debugging
|
79
|
+
# uses: actions/upload-artifact@v4
|
80
|
+
# with:
|
81
|
+
# name: app-src-plan
|
82
|
+
# path: terraform/dist/src.zip
|
83
|
+
# compression-level: 0
|
84
|
+
# retention-days: 1
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml
CHANGED
@@ -31,14 +31,14 @@ jobs:
|
|
31
31
|
|
32
32
|
- name: Comment on pull request
|
33
33
|
if: failure()
|
34
|
-
uses: actions/github-script@
|
34
|
+
uses: actions/github-script@v7
|
35
35
|
with:
|
36
36
|
script: |
|
37
37
|
const output = `SSP assembly detected changes that aren't checked in.
|
38
38
|
|
39
39
|
Run \`bin/trestle assemble-ssp-json\` to ensure markdown changes are reflected in your SSP`;
|
40
40
|
|
41
|
-
github.issues.createComment({
|
41
|
+
github.rest.issues.createComment({
|
42
42
|
issue_number: context.issue.number,
|
43
43
|
owner: context.repo.owner,
|
44
44
|
repo: context.repo.repo,
|
@@ -34,7 +34,7 @@ module RailsTemplate18f
|
|
34
34
|
def configure_asset_pipeline
|
35
35
|
copy_file "lib/tasks/i18n.rake"
|
36
36
|
copy_file "config/initializers/i18n_js.rb"
|
37
|
-
copy_file "app/javascript/i18n.js"
|
37
|
+
copy_file "app/javascript/i18n/index.js"
|
38
38
|
end
|
39
39
|
|
40
40
|
def ignore_generated_file
|
@@ -42,7 +42,7 @@ module RailsTemplate18f
|
|
42
42
|
append_to_file ".gitignore", <<~EOM
|
43
43
|
|
44
44
|
# Generated by i18n-js
|
45
|
-
/app/javascript/
|
45
|
+
/app/javascript/i18n/translations.json
|
46
46
|
EOM
|
47
47
|
end
|
48
48
|
end
|
@@ -24,7 +24,7 @@ module RailsTemplate18f
|
|
24
24
|
|
25
25
|
def install_gem
|
26
26
|
return if gem_installed?("newrelic_rpm")
|
27
|
-
gem "newrelic_rpm", "~> 9.
|
27
|
+
gem "newrelic_rpm", "~> 9.16"
|
28
28
|
bundle_install
|
29
29
|
end
|
30
30
|
|
@@ -33,7 +33,9 @@ module RailsTemplate18f
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def update_cloud_gov_manifest
|
36
|
-
insert_into_file "
|
36
|
+
insert_into_file file_path("terraform/app.tf"), <<EOT, after: "environment = {\n"
|
37
|
+
NEW_RELIC_LOG = "stdout"
|
38
|
+
EOT
|
37
39
|
end
|
38
40
|
|
39
41
|
def update_readme
|
@@ -22,44 +22,56 @@ module RailsTemplate18f
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def use_terraform_module
|
25
|
-
append_to_file file_path("terraform/
|
26
|
-
append_to_file file_path("terraform/
|
25
|
+
append_to_file file_path("terraform/main.tf"), terraform_module
|
26
|
+
append_to_file file_path("terraform/variables.tf"), <<~EOT
|
27
|
+
variable "egress_allowlist" {
|
28
|
+
type = set(string)
|
29
|
+
default = []
|
30
|
+
description = "The set of hostnames that the application is allowed to connect to"
|
31
|
+
}
|
32
|
+
EOT
|
33
|
+
insert_into_file file_path("terraform/app.tf"), <<EOT, after: "environment = {\n"
|
34
|
+
no_proxy = "apps.internal,s3-fips.us-gov-west-1.amazonaws.com"
|
35
|
+
EOT
|
36
|
+
insert_into_file file_path("terraform/app.tf"), <<EOT, after: "service_bindings = [\n"
|
37
|
+
{ service_instance = "egress-proxy-${var.env}-credentials" },
|
38
|
+
EOT
|
39
|
+
insert_into_file file_path("terraform/app.tf"), <<EOT, after: "depends_on = [\n"
|
40
|
+
cloudfoundry_service_instance.egress_proxy_credentials,
|
41
|
+
EOT
|
27
42
|
end
|
28
43
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
cf_org: #{cloud_gov_organization}
|
38
|
-
cf_space: #{cloud_gov_staging_space}-egress
|
39
|
-
cf_command: bind-security-group public_networks_egress $INPUT_CF_ORG --space $INPUT_CF_SPACE
|
40
|
-
EOD
|
41
|
-
end
|
42
|
-
if file_exists?(".github/workflows/deploy-production.yml")
|
43
|
-
insert_into_file ".github/workflows/deploy-production.yml", <<EOD, before: " - name: Deploy app"
|
44
|
-
- name: Set public egress
|
45
|
-
uses: cloud-gov/cg-cli-tools@main
|
46
|
-
with:
|
47
|
-
cf_username: ${{ secrets.CF_USERNAME }}
|
48
|
-
cf_password: ${{ secrets.CF_PASSWORD }}
|
49
|
-
cf_org: #{cloud_gov_organization}
|
50
|
-
cf_space: #{cloud_gov_production_space}-egress
|
51
|
-
cf_command: bind-security-group public_networks_egress $INPUT_CF_ORG --space $INPUT_CF_SPACE
|
52
|
-
EOD
|
53
|
-
end
|
54
|
-
if file_exists?(".circleci/config.yml")
|
55
|
-
insert_into_file ".circleci/config.yml", <<EOD, before: " name: Push application with deployment vars"
|
56
|
-
name: Set public egress
|
57
|
-
command: |
|
58
|
-
cf bind-security-group public_networks_egress << parameters.cloudgov_org >> \
|
59
|
-
--space << parameters.cloudgov_space >>-egress
|
60
|
-
- run:
|
61
|
-
EOD
|
44
|
+
def setup_terraform_provider
|
45
|
+
insert_into_file file_path("terraform/providers.tf"), after: "required_providers {\n" do
|
46
|
+
<<-EOT
|
47
|
+
cloudfoundry-community = {
|
48
|
+
source = "cloudfoundry-community/cloudfoundry"
|
49
|
+
version = "0.53.1"
|
50
|
+
}
|
51
|
+
EOT
|
62
52
|
end
|
53
|
+
append_to_file file_path("terraform/providers.tf"), <<~EOT
|
54
|
+
provider "cloudfoundry-community" {
|
55
|
+
api_url = "https://api.fr.cloud.gov"
|
56
|
+
user = var.cf_user
|
57
|
+
password = var.cf_password
|
58
|
+
}
|
59
|
+
EOT
|
60
|
+
end
|
61
|
+
|
62
|
+
def setup_proxy_vars
|
63
|
+
create_file ".profile", <<~EOP unless file_exists?(".profile")
|
64
|
+
##
|
65
|
+
# Cloud Foundry app initialization script
|
66
|
+
# https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile
|
67
|
+
##
|
68
|
+
|
69
|
+
EOP
|
70
|
+
insert_into_file ".profile", <<~EOP
|
71
|
+
proxy_creds=$(echo "$VCAP_SERVICES" | jq --arg service_name "egress-proxy-$RAILS_ENV-credentials" '.[][] | select(.name == $service_name) | .credentials')
|
72
|
+
export http_proxy=$(echo "$proxy_creds" | jq --raw-output ".http_uri")
|
73
|
+
export https_proxy=$(echo "$proxy_creds" | jq --raw-output ".https_uri")
|
74
|
+
EOP
|
63
75
|
end
|
64
76
|
|
65
77
|
def update_readme
|
@@ -94,9 +106,10 @@ EOB
|
|
94
106
|
### Public Egress Proxy
|
95
107
|
|
96
108
|
Traffic to be delivered to the public internet must be proxied through the [cg-egress-proxy](https://github.com/GSA-TTS/cg-egress-proxy) app. Hostnames that the app should be able to
|
97
|
-
reach should be added to the `
|
109
|
+
reach should be added to the `egress_allowlist` terraform variable in `terraform/production.tfvars` and `terraform/staging.tfvars`
|
98
110
|
|
99
111
|
See the [ruby troubleshooting doc](https://github.com/GSA-TTS/cg-egress-proxy/blob/main/docs/ruby.md) first if you have any problems making outbound connections through the proxy.
|
112
|
+
|
100
113
|
README
|
101
114
|
end
|
102
115
|
|
@@ -104,30 +117,49 @@ EOB
|
|
104
117
|
<<~EOT
|
105
118
|
|
106
119
|
module "egress_space" {
|
107
|
-
source = "github.com/gsa-tts/terraform-cloudgov//cg_space?ref=
|
108
|
-
|
109
|
-
cf_org_name
|
110
|
-
cf_space_name
|
111
|
-
|
112
|
-
deployers
|
113
|
-
|
114
|
-
]
|
120
|
+
source = "github.com/gsa-tts/terraform-cloudgov//cg_space?ref=v2.1.0"
|
121
|
+
|
122
|
+
cf_org_name = local.cf_org_name
|
123
|
+
cf_space_name = "${var.cf_space_name}-egress"
|
124
|
+
allow_ssh = var.allow_space_ssh
|
125
|
+
deployers = local.space_deployers
|
126
|
+
developers = var.space_developers
|
127
|
+
security_group_names = ["public_networks_egress"]
|
115
128
|
}
|
116
129
|
|
117
130
|
module "egress_proxy" {
|
118
|
-
source = "github.com/gsa-tts/terraform-cloudgov//egress_proxy?ref=
|
119
|
-
|
120
|
-
cf_org_name
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
# comment out allowlist if this module is being deployed before the app has ever been deployed
|
125
|
-
allowlist = {
|
126
|
-
"${local.app_name}-${local.env}" = []
|
127
|
-
}
|
131
|
+
source = "github.com/gsa-tts/terraform-cloudgov//egress_proxy?ref=v2.1.0"
|
132
|
+
|
133
|
+
cf_org_name = local.cf_org_name
|
134
|
+
cf_egress_space = module.egress_space.space
|
135
|
+
name = "egress-proxy-${var.env}"
|
136
|
+
allowlist = var.egress_allowlist
|
128
137
|
# depends_on line is needed only for initial creation and destruction. It should be commented out for updates to prevent unwanted cascading effects
|
129
138
|
depends_on = [module.app_space, module.egress_space]
|
130
139
|
}
|
140
|
+
|
141
|
+
resource "cloudfoundry_network_policy" "egress_routing" {
|
142
|
+
provider = cloudfoundry-community
|
143
|
+
policy {
|
144
|
+
source_app = cloudfoundry_app.app.id
|
145
|
+
destination_app = module.egress_proxy.app_id
|
146
|
+
port = "61443"
|
147
|
+
}
|
148
|
+
policy {
|
149
|
+
source_app = cloudfoundry_app.app.id
|
150
|
+
destination_app = module.egress_proxy.app_id
|
151
|
+
port = "8080"
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
resource "cloudfoundry_service_instance" "egress_proxy_credentials" {
|
156
|
+
name = "egress-proxy-${var.env}-credentials"
|
157
|
+
space = module.app_space.space_id
|
158
|
+
type = "user-provided"
|
159
|
+
credentials = module.egress_proxy.json_credentials
|
160
|
+
# depends_on line is needed only for initial creation and destruction. It should be commented out for updates to prevent unwanted cascading effects
|
161
|
+
depends_on = [module.app_space]
|
162
|
+
}
|
131
163
|
EOT
|
132
164
|
end
|
133
165
|
end
|
@@ -29,23 +29,14 @@ module RailsTemplate18f
|
|
29
29
|
|
30
30
|
def configure_server_runner
|
31
31
|
append_to_file "Procfile.dev", "worker: bundle exec sidekiq\n"
|
32
|
-
insert_into_file "
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
append_to_file "staging.yml", <<~EOYAML
|
41
|
-
worker_instances: 1
|
42
|
-
worker_memory: 256M
|
43
|
-
EOYAML
|
44
|
-
append_to_file "production.yml", <<~EOYAML
|
45
|
-
worker_instances: 1
|
46
|
-
worker_memory: 512M
|
47
|
-
EOYAML
|
48
|
-
end
|
32
|
+
insert_into_file file_path("terraform/app.tf"), <<EOT, after: "processes = [\n"
|
33
|
+
{
|
34
|
+
type = "worker"
|
35
|
+
instances = var.worker_instances
|
36
|
+
memory = var.worker_memory
|
37
|
+
command = "bundle exec sidekiq"
|
38
|
+
},
|
39
|
+
EOT
|
49
40
|
end
|
50
41
|
|
51
42
|
def configure_active_job
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file takes care of importing bootstrap
|
2
|
+
# resources onto a new developer's machine if needed
|
3
|
+
# import happens automatically on a normal ./apply.sh run
|
4
|
+
|
5
|
+
%{ for resource_name, id in import_map ~}
|
6
|
+
import {
|
7
|
+
to = ${resource_name}
|
8
|
+
id = "${id}"
|
9
|
+
}
|
10
|
+
%{ endfor ~}
|
11
|
+
|
12
|
+
locals {
|
13
|
+
developer_import_map = "${replace(jsonencode(developer_map), "\"", "\\\"")}"
|
14
|
+
manager_import_map = "${replace(jsonencode(manager_map), "\"", "\\\"")}"
|
15
|
+
}
|
16
|
+
import {
|
17
|
+
for_each = jsondecode(local.developer_import_map)
|
18
|
+
to = module.mgmt_space.cloudfoundry_space_role.developers[each.key]
|
19
|
+
id = each.value
|
20
|
+
}
|
21
|
+
import {
|
22
|
+
for_each = jsondecode(local.manager_import_map)
|
23
|
+
to = module.mgmt_space.cloudfoundry_space_role.managers[each.key]
|
24
|
+
id = each.value
|
25
|
+
}
|