All Projects → mdsol → dice_bag

mdsol / dice_bag

Licence: MIT license
DiceBag is a library of rake tasks for configuring web apps in the style of The Twelve-Factor App.

Programming Languages

Gherkin
971 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to dice bag

comprehend
No description or website provided.
Stars: ✭ 13 (-31.58%)
Mutual labels:  platform, patient-mgmt
Api.gouv.fr
Liste les API disponibles au sein de l'administration française
Stars: ✭ 243 (+1178.95%)
Mutual labels:  platform
Ofc Bootstrap
Bootstrap OpenFaaS Cloud for your team
Stars: ✭ 178 (+836.84%)
Mutual labels:  platform
Blazorrepl
Write, compile, execute and share Blazor components entirely in the browser
Stars: ✭ 196 (+931.58%)
Mutual labels:  platform
Baldphone
A new accessible interface for your smartphone, suitable for seniors
Stars: ✭ 181 (+852.63%)
Mutual labels:  platform
Qards
Qards is a blogging platform focused on performance and on closing the gap between content publishers and developers: https://qards.io
Stars: ✭ 226 (+1089.47%)
Mutual labels:  platform
Elf
An End-To-End, Lightweight and Flexible Platform for Game Research
Stars: ✭ 2,057 (+10726.32%)
Mutual labels:  platform
nuber
Virtualization management software
Stars: ✭ 33 (+73.68%)
Mutual labels:  platform
Canvas
A Laravel publishing platform
Stars: ✭ 2,838 (+14836.84%)
Mutual labels:  platform
Klepto
Klepto is a tool for copying and anonymising data
Stars: ✭ 193 (+915.79%)
Mutual labels:  platform
Platypush
A versatile and extensible platform for home and life automation with hundreds of supported integrations
Stars: ✭ 192 (+910.53%)
Mutual labels:  platform
Sharetribe
Sharetribe Go is a source available marketplace software, also available as a hosted, no-code SaaS product. For a headless, API-first marketplace solution, check out Sharetribe Flex: https://www.sharetribe.com/flex.
Stars: ✭ 2,184 (+11394.74%)
Mutual labels:  platform
Microservices Platform
基于SpringBoot2.x、SpringCloud和SpringCloudAlibaba并采用前后端分离的企业级微服务多租户系统架构。并引入组件化的思想实现高内聚低耦合,项目代码简洁注释丰富上手容易,适合学习和企业中使用。真正实现了基于RBAC、jwt和oauth2的无状态统一权限认证的解决方案,面向互联网设计同时适合B端和C端用户,支持CI/CD多环境部署,并提供应用管理方便第三方系统接入;同时还集合各种微服务治理功能和监控功能。模块包括:企业级的认证系统、开发平台、应用监控、慢sql监控、统一日志、单点登录、Redis分布式高速缓存、配置中心、分布式任务调度、接口文档、代码生成等等。
Stars: ✭ 3,274 (+17131.58%)
Mutual labels:  platform
Platform
A @laravel based RAD platform for back-office applications, admin/user panels, and dashboards.
Stars: ✭ 2,623 (+13705.26%)
Mutual labels:  platform
Modbus.net
A high extensible hardware communication platform using C#
Stars: ✭ 244 (+1184.21%)
Mutual labels:  platform
Zazu
🚀 A fully extensible and open source launcher for hackers, creators and dabblers.
Stars: ✭ 2,060 (+10742.11%)
Mutual labels:  platform
Janus
An API Gateway written in Go
Stars: ✭ 2,249 (+11736.84%)
Mutual labels:  platform
Grpc Web Devtools
Chrome & Firefox Browser extension to aid gRPC-Web development
Stars: ✭ 223 (+1073.68%)
Mutual labels:  platform
o2o
No description or website provided.
Stars: ✭ 21 (+10.53%)
Mutual labels:  platform
Foundation lib
Cross-platform public domain foundation library in C providing basic support data types and functions to write applications and games in a platform-independent fashion.
Stars: ✭ 249 (+1210.53%)
Mutual labels:  platform

DiceBag

Build Status Code Climate

DiceBag is a library of rake tasks for configuring web apps in the style of The Twelve-Factor App. Configuration values are picked up from the environment and used to populate configuration files from templates. Pre-packaged templates for common configuration files are provided.

Although Rails already supports ERB syntax for its YML configuration files, DiceBag will generate a final static file that will work without keeping your deployment environment variables in sync with your production environment variables. For security reasons, these environments may sometimes differ.

Also DiceBag will work with any kind of text files, not only YML files. It can be very useful for ruby initializer files for instance.

Installation

Add the following to your Gemfile:

gem 'dice_bag'

If you are using these tasks outside of a Rails project, add the following to your Rakefile or wherever your local rake tasks are defined:

require 'dice_bag/tasks'

Run the following command to see the new tasks:

[bundle exec] rake -T | grep "rake config"

Create configuration files from templates

When the rake "config" task is run, configuration files are populated for all ERB template files in the project that have a ".dice" extension. Configuration values from the environment are made available to the templates through the configured object.

For example, take a "database.yml.dice" file containing this template:

development:
  database: development
  username: <%= configured.database_username || 'root' %>
  password: <%= configured.database_password %>

Then running the following command:

DATABASE_USERNAME=alice DATABASE_PASSWORD=xyzzy [bundle exec] rake config

will generate a "database.yml" file with the following contents:

development:
  database: development
  username: alice
  password: xyzzy

See the feature documentation for further examples and functionality.

As discussed in The Twelve-Factor App section on configuration, do not commit your generated configuration files to source control. Instead, commit the templates to source control and then regenerate the configuration files at deployment time by running the rake config:deploy task.

Ensuring variables are set in production

It is a common pattern to use default information for development but to not allow defaults in production, instead we want to always set up the environment variables in production.

It is very easy to discover what variables have not been set in production using a bang after the variable name, for instance:

secret_key: <%= configured.secret_key_base! || 'any text is ok' %>

Will raise an explanatory error if we are using Rails, we are in production and the variable SECRET_KEY_BASE is not set. In other environments will not care about it not being set and will use the default.

Generating the templates of given gems only

config:generate_all will generate all the templates it can find. Since sometimes this behavior is not desirable you can use the config:generate_from_gems task to specify gem names:

[bundle exec] rake config:generate_from_gems gem1 gem2 gemN

will generate only the templates provided by gem1, gem2 and gemN.

To force-generate set the DICEBAG_FORCE environment variable to any value when running the task.

Generating the pre-packaged templates

If the corresponding gems are installed, the following pre-packaged templates are provided:

  • mysql2 or pg: database.yml.dice for Rails
  • aws-sdk: aws.yml.dice
  • dalli: dalli.yml.dice

Run the following command to generate them:

[bundle exec] rake config:generate_all

This command provides options to compare changes between source and local templates, so new additions to the source templates can be safely added while preserving any project specific customization to local templates.

Alternatively, to force generate templates (replacing existing local templates with the source), run the following:

[bundle exec] rake config:generate_all:force

As with your own templates, you should commit these pre-packaged templates to source control.

You can customize these pre-packaged template to your needs but if the change is a generic fix or extension, please consider contributing it back to this project so that everyone benefits.

Defining your own pre-packaged templates

If you want DiceBag to generate your own pre-packaged templates when you run the rake "config:generate_all" task, you can create a plug-in. Read the templates.md file to learn how to do this.

Troubleshooting

rake config fails in Rails project with file not found

Due to rake running config/application.rb before kicking off a task, if config/application.rb loads any configuration files that dice_bag must generate a 'file not found' error may occur. Makes sense that a file rake config:generate_all needs to create, does not exist before it has ran.

Solution: Move any config loading that depends on files generated by dice_bag out of application.rb and into config/initializers/*. Since the commands rails server or rails console etc. always run the initializers, moving the logic here should be a safe bet.

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].