Read database, host and SMTP settings from a .env file

- gem dotenv loads .env (and .env.<environment>[.local]) at startup; real
  environment variables take precedence.
- database.yml takes host, port, user, password and name from
  NUMOLUS_DATABASE_*; the database is called numolus by default.
- .env.example documents every setting; .env itself stays ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
wkh
2026-09-28 20:57:43 +02:00
co-authored by Claude Opus 5.5
parent ed099cfbda
commit f22963a666
6 changed files with 49 additions and 13 deletions
+10 -8
View File
@@ -15,14 +15,17 @@
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
# Connection details come from the environment, usually a .env file in
# the project directory (see .env.example). Unset = local socket, own user.
host: <%= ENV["NUMOLUS_DATABASE_HOST"] %>
port: <%= ENV["NUMOLUS_DATABASE_PORT"] %>
username: <%= ENV["NUMOLUS_DATABASE_USER"] %>
password: <%= ENV["NUMOLUS_DATABASE_PASSWORD"] %>
development:
<<: *default
database: numolus_development
database: <%= ENV.fetch("NUMOLUS_DATABASE_NAME", "numolus") %>
# The specified database role being used to connect to PostgreSQL.
# To create additional roles in PostgreSQL see `$ createuser --help`.
@@ -59,9 +62,8 @@ test:
database: numolus_test
# Production: one database for everything -- app data, Solid Queue, Solid
# Cache and Solid Cable. The password comes from NUMOLUS_DATABASE_PASSWORD.
# Cache and Solid Cable. Credentials via NUMOLUS_DATABASE_* (see .env.example).
production:
<<: *default
database: numolus_production
username: numolus
password: <%= ENV["NUMOLUS_DATABASE_PASSWORD"] %>
database: <%= ENV.fetch("NUMOLUS_DATABASE_NAME", "numolus") %>
username: <%= ENV.fetch("NUMOLUS_DATABASE_USER", "numolus") %>