16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/kuby/plugins/rails_app/generators/kuby.rb', line 16
def create_config_file
app_class = Rails.application.class
app_name = if app_class.respond_to?(:module_parent_name)
app_class.module_parent_name
else
app_class.parent_name
end
create_file(
'kuby.rb',
" require 'active_support/core_ext'\n require 'active_support/encrypted_configuration'\n\n # Define a production Kuby deploy environment\n Kuby.define('\#{app_name}') do\n environment(:production) do\n # Because the Rails environment isn't always loaded when\n # your Kuby config is loaded, provide access to Rails\n # credentials manually.\n app_creds = ActiveSupport::EncryptedConfiguration.new(\n config_path: File.join('config', 'credentials.yml.enc'),\n key_path: File.join('config', 'master.key'),\n env_key: 'RAILS_MASTER_KEY',\n raise_if_missing_key: true\n )\n\n docker do\n # Configure your Docker registry credentials here. Add them to your\n # Rails credentials file by running `bundle exec rake credentials:edit`.\n credentials do\n username app_creds[:KUBY_DOCKER_USERNAME]\n password app_creds[:KUBY_DOCKER_PASSWORD]\n email app_creds[:KUBY_DOCKER_EMAIL]\n end\n\n # Configure the URL to your Docker image here, eg:\n # image_url 'foo.bar.com/me/myproject'\n #\n # If you're using Gitlab's Docker registry, try something like this:\n # image_url 'registry.gitlab.com/<username>/<repo>'\n end\n\n kubernetes do\n # Add a plugin that facilitates deploying a Rails app.\n add_plugin :rails_app do\n # configure database credentials\n database do\n user app_creds[:KUBY_DB_USER]\n password app_creds[:KUBY_DB_PASSWORD]\n end\n end\n\n # Use Docker Desktop as the provider.\n # See: https://www.docker.com/products/docker-desktop\n #\n # Note: you will likely want to use a different provider when deploying\n # your application into a production environment. To configure a different\n # provider, add the corresponding gem to your gemfile and update the\n # following line according to the provider gem's README.\n provider :docker_desktop\n end\n end\n end\n END\n )\nend\n"
|