diff --git a/.gitignore b/.gitignore index 30a29907..a7867ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -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 diff --git a/Gemfile b/Gemfile index cc1e1b33..b90e0883 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index c1ec2ed2..288da30c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -376,6 +380,7 @@ DEPENDENCIES clockwork dalli delayed_job_active_record (~> 4.1) + dotenv-rails faker faraday faraday-decode_xml diff --git a/config/database.yml b/config/database.yml index e44f0dba..4cf7ec5b 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,4 +1,4 @@ -default: &default +defaults: &defaults adapter: postgresql encoding: utf8 pool: 5 @@ -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 diff --git a/config/options.yml b/config/options.yml index be621470..0eb704b5 100644 --- a/config/options.yml +++ b/config/options.yml @@ -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 @@ -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'] %> diff --git a/docker-compose.override.yml.example b/docker-compose.override.yml.example index b1a88489..7942c2e2 100644 --- a/docker-compose.override.yml.example +++ b/docker-compose.override.yml.example @@ -4,6 +4,3 @@ services: build: args: CONTAINER_USERID: 1000 - environment: - - API_USERNAME=yourusername - - API_PASSWORD=password123 diff --git a/dotenv.example b/dotenv.example new file mode 100644 index 00000000..b9bf3be3 --- /dev/null +++ b/dotenv.example @@ -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 diff --git a/vendor/cache/dotenv-2.8.1.gem b/vendor/cache/dotenv-2.8.1.gem new file mode 100644 index 00000000..1e952071 Binary files /dev/null and b/vendor/cache/dotenv-2.8.1.gem differ diff --git a/vendor/cache/dotenv-rails-2.8.1.gem b/vendor/cache/dotenv-rails-2.8.1.gem new file mode 100644 index 00000000..1aab6b48 Binary files /dev/null and b/vendor/cache/dotenv-rails-2.8.1.gem differ