Skip to content

Commit

Permalink
Merge pull request #1419 from hennevogel/bugfix/staging-production
Browse files Browse the repository at this point in the history
Introduces dotenv-rails
  • Loading branch information
hennevogel authored Nov 9, 2023
2 parents 3d4cb13 + 68124bb commit e681aad
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 22 deletions.
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ diff.diff
# Bundler config
/.bundle

# docker-compose override file
docker-compose.override.yml

# dotenv files
.env
.env.production
.env.development
.env.test

# Static files in public
public/111
public/112
Expand All @@ -37,9 +46,3 @@ public/package
locale/*/software.edit.po
locale/*/software.po.time_stamp

# Local databases
/db/*.sqlite3
/db/*.db

.byebug_history
docker-compose.override.yml
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ gem 'sentry-ruby'
# for versioning
gem 'paper_trail'

# for setting environment variables
gem 'dotenv-rails'

gem 'dalli'
gem 'hashie'
gem 'mini_magick'
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ GEM
delayed_job_active_record (4.1.8)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
Expand Down Expand Up @@ -376,6 +380,7 @@ DEPENDENCIES
clockwork
dalli
delayed_job_active_record (~> 4.1)
dotenv-rails
faker
faraday
faraday-decode_xml
Expand Down
15 changes: 8 additions & 7 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default: &default
defaults: &defaults
adapter: postgresql
encoding: utf8
pool: 5
Expand All @@ -10,15 +10,16 @@ default: &default
database: <%= ENV.fetch('SOFTWARE_DB_NAME', 'postgres') %>

development:
<<: *default
<<: *defaults
database: software_development

test:
<<: *default
<<: *defaults
database: software_test

production:
adapter: postgresql
encoding: utf8
pool: 5
timeout: 5000
<<: *defaults
# no defaults for host/port as we might want to connect through a socket
host: <%= ENV.fetch('SOFTWARE_DB_HOST', nil) %>
port: <%= ENV.fetch('SOFTWARE_DB_PORT', nil) %>
database: software_production
9 changes: 3 additions & 6 deletions config/options.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defaults: &defaults
api_host: https://api.opensuse.org
web_host: https://build.opensuse.org
api_username: <%= ENV['API_USERNAME'] %>
api_password: <%= ENV['API_PASSWORD'] %>
api_username: <%= ENV['SOFTWARE_OBS_API_USERNAME'] %>
api_password: <%= ENV['SOFTWARE_OBS_API_PASSWORD'] %>
relative_url_root:
development:
<<: *defaults
Expand All @@ -12,7 +12,4 @@ test:
production:
<<: *defaults
relative_url_root:
api_username: <%= ENV['API_USERNAME'] %>
api_password: <%= ENV['API_PASSWORD'] %>
use_static: software.o.o
opensuse_cookie: <%= ENV['OPENSUSE_COOKIE'] %>
opensuse_cookie: <%= ENV['SOFTWARE_OPENSUSE_COOKIE'] %>
3 changes: 0 additions & 3 deletions docker-compose.override.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ services:
build:
args:
CONTAINER_USERID: 1000
environment:
- API_USERNAME=yourusername
- API_PASSWORD=password123
17 changes: 17 additions & 0 deletions dotenv.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Rails Secret Key Base
# https://guides.rubyonrails.org/security.html#session-storage
# generate one with rails secret
SECRET_KEY_BASE=12345

# OBS API Secrets
# https://api.opensuse.org/apidocs/
SOFTWARE_API_USERNAME=myusername
SOFTWARE_API_PASSWORD=mypassword
SOFTWARE_OPENSUSE_COOKIE=12345

# Postgres Database configuration
SOFTWARE_DB_USER=postgres
SOFTWARE_DB_PASSWORD=postgres
SOFTWARE_DB_NAME=postgres
SOFTWARE_DB_HOST=database
SOFTWARE_DB_PORT=5432
Binary file added vendor/cache/dotenv-2.8.1.gem
Binary file not shown.
Binary file added vendor/cache/dotenv-rails-2.8.1.gem
Binary file not shown.

0 comments on commit e681aad

Please sign in to comment.