Browse Source

boot: add dotenv to load env variables

pull/59/head
Arthur POULET 11 months ago
parent
commit
46d2d3c8d1
Signed by: Sceptique GPG Key ID: C108A668349EE601
  1. 5
      .env.sample
  2. 1
      .gitignore
  3. 2
      Gemfile
  4. 2
      Gemfile.lock
  5. 12
      README.md
  6. 3
      src/app.rb

5
.env.sample

@ -0,0 +1,5 @@
LIFEPEX_DB=sqlite://sqlite.db
LIFEPEX_BIND=127.0.0.1
LIFEPEX_BASE_URL=
LIFEPEX_SECRET=
LIFEPEX_ENV=

1
.gitignore

@ -1,2 +1,3 @@
*.db
coverage
.env.*local

2
Gemfile

@ -32,3 +32,5 @@ group :test do
gem "rack-test", "~> 1.1", require: false
# gem "simplecov", "~> 0.21.2", require: false
end
gem "dotenv", "~> 2.7"

2
Gemfile.lock

@ -12,6 +12,7 @@ GEM
colorize (0.8.1)
concurrent-ruby (1.1.9)
doc_my_routes (0.13.0)
dotenv (2.7.6)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jwt (2.2.3)
@ -65,6 +66,7 @@ DEPENDENCIES
bcrypt (~> 3.1)
colorize (~> 0.8.1)
doc_my_routes
dotenv (~> 2.7)
jwt (~> 2.2)
pg (~> 1.2)
pry (~> 0.14.1)

12
README.md

@ -26,13 +26,13 @@ psql -U postgres postgres -c "CREATE DATABASE life_pex"
## Start
```
export LIFEPEX_SECRET="put something random here" # recommanded
export LIFEPEX_BASE_URL="https://mydomain/base" # recommanded
export LIFEPEX_DB="sqlite://sqlite.db" # REQUIRED
echo LIFEPEX_DB="sqlite://sqlite.db" > .env.local # REQUIRED
echo LIFEPEX_SECRET="put something random here" >> .env.local # recommanded
echo LIFEPEX_BASE_URL="https://mydomain/base" >> .env.local # recommanded
# you may also want to use postgres or something
# export LIFEPEX_DB="postgres://root:toor@localhost/life_pex"
# export LIFEPEX_BIND="0.0.0.0" # you may want to bind against something else than 127.0.01
# export LIFEPEX_ENV="production" # why not hide stacktraces ?
# LIFEPEX_DB="postgres://root:toor@localhost/life_pex"
# LIFEPEX_BIND="0.0.0.0" # you may want to bind against something else than 127.0.01
# LIFEPEX_ENV="production" # why not hide stacktraces ?
./src/app.rb
```

3
src/app.rb

@ -18,6 +18,9 @@ require "active_support"
require "active_support/core_ext"
require "pry" # debug
require "dotenv"
Dotenv.load(".env.local", ".env")
require_relative "./utils/url.rb"
require_relative "./utils/boot_framework"

Loading…
Cancel
Save