My opinionated ruby on rails template
1# frozen_string_literal: true
2
3say 'Setting up credentials...', :green
4
5# Initialize credentials for each environment (after bundle)
6after_bundle do
7 say ' Creating environment credentials...', :cyan
8 %w[development staging production].each do |env|
9 say " #{env}...", :cyan
10 run "EDITOR='echo' bin/rails credentials:edit --environment #{env}", abort_on_failure: false
11 end
12end
13
14# Create credentials example file
15file 'config/credentials.yml.example', <<~YAML
16 # Credentials structure for all environments
17 # Edit with: EDITOR=nano rails credentials:edit --environment <env>
18 #
19 # Generate keys in rails console:
20 # Lockbox.generate_key
21 # BlindIndex.generate_key
22 # SecureRandom.hex(32)
23
24 secret_key_base: # auto-generated
25
26 lockbox:
27 master_key: # Lockbox.generate_key
28
29 blind_index:
30 master_key: # BlindIndex.generate_key
31
32 hashid:
33 salt: # SecureRandom.hex(32)
34YAML
35
36say 'Credentials configured!', :green