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:
@@ -0,0 +1,26 @@
|
|||||||
|
# numolus settings -- copy to .env (same directory) and fill in.
|
||||||
|
# .env is read at startup (gem dotenv) and never committed. Variables that
|
||||||
|
# are already set in the real environment take precedence over this file.
|
||||||
|
# Environment-specific files are read too: .env.production, .env.development
|
||||||
|
# (and *.local variants).
|
||||||
|
|
||||||
|
# ---- Database (PostgreSQL) --------------------------------------------------
|
||||||
|
# Unset host/user/password = local socket as the current OS user (development).
|
||||||
|
NUMOLUS_DATABASE_NAME=numolus
|
||||||
|
NUMOLUS_DATABASE_HOST=localhost
|
||||||
|
NUMOLUS_DATABASE_PORT=5432
|
||||||
|
NUMOLUS_DATABASE_USER=numolus
|
||||||
|
NUMOLUS_DATABASE_PASSWORD=
|
||||||
|
|
||||||
|
# ---- Server -------------------------------------------------------------------
|
||||||
|
# Host name used in links in mails (sign-in, invitations)
|
||||||
|
NUMOLUS_HOST=numolus.wicom.li
|
||||||
|
# Rails secret (production): generate with bin/rails secret
|
||||||
|
SECRET_KEY_BASE=
|
||||||
|
|
||||||
|
# ---- Mail (production; development shows mails at /letter_opener) ------------
|
||||||
|
NUMOLUS_MAIL_FROM="numolus <noreply@wicom.li>"
|
||||||
|
SMTP_ADDRESS=smtp.example.com
|
||||||
|
SMTP_PORT=587
|
||||||
|
SMTP_USER_NAME=
|
||||||
|
SMTP_PASSWORD=
|
||||||
@@ -26,4 +26,5 @@ node_modules
|
|||||||
!/storage/.keep
|
!/storage/.keep
|
||||||
/config/master.key
|
/config/master.key
|
||||||
/.env*
|
/.env*
|
||||||
|
!/.env.example
|
||||||
/vendor/gems
|
/vendor/gems
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ group :development do
|
|||||||
gem "web-console"
|
gem "web-console"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Settings and secrets (database, SMTP, host) from a .env file in the project
|
||||||
|
# directory; real environment variables win -- see .env.example
|
||||||
|
gem "dotenv"
|
||||||
|
|
||||||
# Vite as the frontend build, integrated into Rails [https://vite-ruby.netlify.app]
|
# Vite as the frontend build, integrated into Rails [https://vite-ruby.netlify.app]
|
||||||
gem "vite_rails"
|
gem "vite_rails"
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ GEM
|
|||||||
debug (1.11.1)
|
debug (1.11.1)
|
||||||
irb (~> 1.10)
|
irb (~> 1.10)
|
||||||
reline (>= 0.3.8)
|
reline (>= 0.3.8)
|
||||||
|
dotenv (3.2.0)
|
||||||
drb (2.2.3)
|
drb (2.2.3)
|
||||||
dry-cli (1.4.1)
|
dry-cli (1.4.1)
|
||||||
erb (6.0.7)
|
erb (6.0.7)
|
||||||
@@ -300,6 +301,7 @@ DEPENDENCIES
|
|||||||
brakeman
|
brakeman
|
||||||
bundler-audit
|
bundler-audit
|
||||||
debug
|
debug
|
||||||
|
dotenv
|
||||||
letter_opener_web
|
letter_opener_web
|
||||||
pg (~> 1.1)
|
pg (~> 1.1)
|
||||||
puma (>= 5.0)
|
puma (>= 5.0)
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ kommen über ActionCable sofort bei den anderen an (Yjs, siehe
|
|||||||
[`app/frontend/collab/`](app/frontend/collab/)), jede Person hat ihr eigenes
|
[`app/frontend/collab/`](app/frontend/collab/)), jede Person hat ihr eigenes
|
||||||
Undo, und die Auswahl der anderen ist als farbiger Rahmen zu sehen. Details: [`docs/konzept-teilen-und-zusammenarbeit.md`](docs/konzept-teilen-und-zusammenarbeit.md).
|
Undo, und die Auswahl der anderen ist als farbiger Rahmen zu sehen. Details: [`docs/konzept-teilen-und-zusammenarbeit.md`](docs/konzept-teilen-und-zusammenarbeit.md).
|
||||||
|
|
||||||
Mails landen in der Entwicklung nicht im Postfach, sondern unter
|
**Konfiguration:** Datenbank-Zugang, Server-Name, SMTP und `SECRET_KEY_BASE`
|
||||||
<http://localhost:3000/letter_opener>. Produktion braucht `SMTP_ADDRESS`,
|
stehen in einer `.env` im Projektverzeichnis – Vorlage kopieren und ausfüllen:
|
||||||
`SMTP_USER_NAME`, `SMTP_PASSWORD`, `NUMOLUS_MAIL_FROM`, `NUMOLUS_HOST` und
|
`cp .env.example .env`. Die Datei wird nie committet; echte
|
||||||
`NUMOLUS_DATABASE_PASSWORD`; Solid Queue, Cache und Cable liegen in derselben
|
Umgebungsvariablen haben Vorrang. Solid Queue, Cache und Cable liegen in
|
||||||
Datenbank wie die Daten.
|
derselben Datenbank wie die Daten. Mails landen in der Entwicklung nicht im
|
||||||
|
Postfach, sondern unter <http://localhost:3000/letter_opener>.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+10
-8
@@ -15,14 +15,17 @@
|
|||||||
default: &default
|
default: &default
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
encoding: unicode
|
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 } %>
|
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:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: numolus_development
|
database: <%= ENV.fetch("NUMOLUS_DATABASE_NAME", "numolus") %>
|
||||||
|
|
||||||
# The specified database role being used to connect to PostgreSQL.
|
# The specified database role being used to connect to PostgreSQL.
|
||||||
# To create additional roles in PostgreSQL see `$ createuser --help`.
|
# To create additional roles in PostgreSQL see `$ createuser --help`.
|
||||||
@@ -59,9 +62,8 @@ test:
|
|||||||
database: numolus_test
|
database: numolus_test
|
||||||
|
|
||||||
# Production: one database for everything -- app data, Solid Queue, Solid
|
# 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:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: numolus_production
|
database: <%= ENV.fetch("NUMOLUS_DATABASE_NAME", "numolus") %>
|
||||||
username: numolus
|
username: <%= ENV.fetch("NUMOLUS_DATABASE_USER", "numolus") %>
|
||||||
password: <%= ENV["NUMOLUS_DATABASE_PASSWORD"] %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user