Sinatra

Encrypt a .env file in Sinatra with the Dotenvx gem, commit it safely, and load its secrets at runtime.

Install

Get the Dotenvx Ruby gem.

$ gem install dotenvx

And the CLI to encrypt files.

$ curl -sfS https://dotenvx.sh | sh

Encrypt

Encrypt your .env file.

$ dotenvx encrypt

Inject

Then inject your encrypted secrets at runtime.

require "dotenvx"
require "sinatra"

Dotenvx.load

get "/" do
  "HELLO: #{ENV['HELLO']}"
end
Open page ↗

Side path