Skip to content
48 changes: 48 additions & 0 deletions .env.mysql2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# DMPRoadmap dotenv file

# Rails log level
RAILS_LOG_LEVEL=debug
# Whether or not Rails should log to STDOUT. If false it will log to `./logs/[env].log`
RAILS_LOG_TO_STDOUT=true
# Whether or not Rails will be serving your static assets
RAILS_SERVE_STATIC_FILES=false
# Maximum number of Puma threads
RAILS_MAX_THREADS=5
# Maximum number of Puma workers
WEB_CONCURRENCY=2
# The port puma will use to host the Rails app
PORT=3000

# Rails 6.1+ has a white-list of valid domains. You must set this for your production env!
DMPROADMAP_HOST=localhost

# The location of the wkhtmltopdf app. Once bundler has installed it, you can find it with
# `which wkhtmltopdf` on linux/osx systems.
WICKED_PDF_PATH=/usr/local/bin/wkhtmltopdf

# Database settings.
DB_ADAPTER=mysql2
DB_HOST=localhost
DB_PORT=3306
DB_POOL_SIZE=16
DB_NAME=roadmap

# Whether or not the Dragonfly gem should use AWS S3 to store logos. If 'false' the logos will
# be stored on the local disk. If true, you must provide the `AWS_` prefixed values.
DRAGONFLY_AWS=false
AWS_REGION=
AWS_BUCKET_NAME=

# If you have a Rollbar account and want to redcord errors there, add your token here
ROLLBAR_ACCESS_TOKEN=
ROLLBAR_ENV=

# Translation IO variables. The Domain can be either `app` or `client` and is typically defined
# when running `bin/rails translations:sync DOMAIN=app`. `client` will use any of your
# customized content in ./app/views/branded and `app` is for the core roadmap translations.
# Include your Translation.io API key for the appropriate domains:
# app => TRANSLATION_API_ROADMAP
# client => TRANSLATION_API_CLIENT
# DOMAIN=app
# TRANSLATION_API_ROADMAP=
# TRANSLATION_API_CLIENT=
48 changes: 48 additions & 0 deletions .env.postgresql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# DMPRoadmap dotenv file

# Rails log level
RAILS_LOG_LEVEL=debug
# Whether or not Rails should log to STDOUT. If false it will log to `./logs/[env].log`
RAILS_LOG_TO_STDOUT=true
# Whether or not Rails will be serving your static assets
RAILS_SERVE_STATIC_FILES=false
# Maximum number of Puma threads
RAILS_MAX_THREADS=5
# Maximum number of Puma workers
WEB_CONCURRENCY=2
# The port puma will use to host the Rails app
PORT=3000

# Rails 6.1+ has a white-list of valid domains. You must set this for your production env!
DMPROADMAP_HOST=localhost

# The location of the wkhtmltopdf app. Once bundler has installed it, you can find it with
# `which wkhtmltopdf` on linux/osx systems.
WICKED_PDF_PATH=/usr/local/bin/wkhtmltopdf

# Database settings.
DB_ADAPTER=postgresql
DB_HOST=localhost
DB_PORT=5432
DB_POOL_SIZE=16
DB_NAME=roadmap

# Whether or not the Dragonfly gem should use AWS S3 to store logos. If 'false' the logos will
# be stored on the local disk. If true, you must provide the `AWS_` prefixed values.
DRAGONFLY_AWS=false
AWS_REGION=
AWS_BUCKET_NAME=

# If you have a Rollbar account and want to redcord errors there, add your token here
ROLLBAR_ACCESS_TOKEN=
ROLLBAR_ENV=

# Translation IO variables. The Domain can be either `app` or `client` and is typically defined
# when running `bin/rails translations:sync DOMAIN=app`. `client` will use any of your
# customized content in ./app/views/branded and `app` is for the core roadmap translations.
# Include your Translation.io API key for the appropriate domains:
# app => TRANSLATION_API_ROADMAP
# client => TRANSLATION_API_CLIENT
DOMAIN=app
TRANSLATION_API_ROADMAP=
TRANSLATION_API_CLIENT=
5 changes: 3 additions & 2 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ jobs:
cache: 'yarn'

# Copy all of the example configs over
- name: 'Setup Default Configuration'
- name: 'Setup the application'
run: |
cp config/database.yml.sample config/database.yml
cp config/initializers/contact_us.rb.example config/initializers/contact_us.rb
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb
cp .env.mysql2 .env

# Stub out the Rails credentials file so that we can start the Rails app
- name: 'Setup Credentials'
run: EDITOR='echo "$(cat config/credentials.yml.example)" >' bundle exec rails credentials:edit
run: EDITOR='echo "$(cat config/credentials.yml.mysql2)" >' bundle exec rails credentials:edit

# Set the path to the wkhtmltopdf executable
- name: 'Determine wkhtmltopdf location'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ jobs:
cp config/database.yml.sample config/database.yml
cp config/initializers/contact_us.rb.example config/initializers/contact_us.rb
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb
cp .env.postgresql .env

# Stub out the Rails credentials file so that we can start the Rails app
- name: 'Setup Credentials'
run: |
# generate a default credential file and key
EDITOR='echo "$(cat config/credentials.yml.example)" >' bundle exec rails credentials:edit
EDITOR='echo "$(cat config/credentials.yml.postgresql)" >' bundle exec rails credentials:edit

# Set the path to the wkhtmltopdf executable
- name: 'Determine wkhtmltopdf location'
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ GEM
mysql2 (0.5.4)
nenv (0.3.0)
nio4r (2.5.8)
nokogiri (1.13.9-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
Expand Down Expand Up @@ -498,6 +500,7 @@ GEM
zeitwerk (2.6.1)

PLATFORMS
arm64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -580,4 +583,4 @@ RUBY VERSION
ruby 2.7.6p219

BUNDLED WITH
2.3.15
2.3.24
83 changes: 58 additions & 25 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,65 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "\n== Copying sample files =="
%w[
config/database.yml.sample
config/initializers/wicked_pdf.rb.example
].each do |file|
new_file = file.gsub('.sample', '').gsub('.example', '')
cp file, new_file unless File.exist?(new_file)
end
valid_db = ARGV.length > 0 && %w[mysql postgres].include?(ARGV[0].to_s.downcase.strip)

puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
if valid_db
db_adapter = ARGV[0].to_s.downcase.strip == 'mysql' ? 'mysql2' : 'postgresql'

puts "\n== Fetching mime types and adding to database =="
system! 'bin/rails mime_types:load'
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
system! 'yarn install'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
puts "\n== Copying sample files =="
cp 'config/database.yml.sample', 'config/database.yml'
cp 'config/initializers/contact_us.rb.example', 'config/initializers/contact_us.rb'
cp 'config/initializers/wicked_pdf.rb.example', 'config/initializers/wicked_pdf.rb'
cp ".env.#{db_adapter}", '.env'

puts "\n== Preparing credentials file =="
system! "EDITOR='echo \"$(cat config/credentials.yml.#{db_adapter})\" >' bin/rails credentials:edit"

# Set the editor based on the platform
ENV['EDITOR'] = Gem.win_platform? ? 'code --wait' : 'vim'

puts "\n== Opening .env in editor ... please update as needed =="
puts " In particular make sure your DB settings are correct."
sleep(3)
system! '$EDITOR .env'

puts "\n== Opening credentials editor ... please update as needed =="
puts " In particular make sure your DB settings are correct."
sleep(3)
system! 'bin/rails credentials:edit'

puts "\n== Preparing database =="
system! 'bin/rails db:setup'

puts "\n== Populating License table =="
system! 'bin/rails external_api:load_spdx_licenses'

puts "\n== Populating Metadata Standards table =="
system! 'bin/rails external_api:load_rdamsc_standards'

puts "\n== Populating Research Domains table =="
system! 'bin/rails external_api:add_field_of_science_to_research_domains'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'

puts "\n== !!We highly recommend that you populate the Repositories table, but this can take"
puts "in excess of 10 minutes so we do not run it as part of this setup!!"
puts " To run it on your own: `bin/rails external_api:load_re3data_repos`"
end
else
puts "\n== You MUST specify the type of DB you would like to use. Either mysql or postgres =="
puts "== For example: `ruby bin/setup postgres` =="
end
42 changes: 2 additions & 40 deletions config/brakeman.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,14 @@
],
"note": ""
},
{
"warning_type": "Unmaintained Dependency",
"warning_code": 121,
"fingerprint": "9a3951031616a07c8e02c86652f537e92c08685da97f5ec2b12d5d3602b55bb8",
"check_name": "EOLRuby",
"message": "Support for Ruby 2.6.3 ended on 2022-03-31",
"file": "Gemfile.lock",
"line": 325,
"link": "https://brakemanscanner.org/docs/warning_types/unmaintained_dependency/",
"code": null,
"render_path": null,
"location": null,
"user_input": null,
"confidence": "High",
"cwe_id": [
1104
],
"note": ""
},
{
"warning_type": "Redirect",
"warning_code": 18,
"fingerprint": "c94d0d02516558699b49eb76787d02665041a45b490686266e4f42d5c19088d6",
"check_name": "Redirect",
"message": "Possible unprotected redirect",
"file": "app/controllers/plans_controller.rb",
"line": 393,
"line": 392,
"link": "https://brakemanscanner.org/docs/warning_types/redirect/",
"code": "redirect_to(Plan.deep_copy(Plan.find(params[:id])), :notice => success_message(Plan.deep_copy(Plan.find(params[:id])), _(\"copied\")))",
"render_path": null,
Expand All @@ -65,25 +46,6 @@
],
"note": ""
},
{
"warning_type": "Unmaintained Dependency",
"warning_code": 120,
"fingerprint": "d84924377155b41e094acae7404ec2e521629d86f97b0ff628e3d1b263f8101c",
"check_name": "EOLRails",
"message": "Support for Rails 5.2.8.1 ended on 2022-06-01",
"file": "Gemfile.lock",
"line": 325,
"link": "https://brakemanscanner.org/docs/warning_types/unmaintained_dependency/",
"code": null,
"render_path": null,
"location": null,
"user_input": null,
"confidence": "High",
"cwe_id": [
1104
],
"note": ""
},
{
"warning_type": "Redirect",
"warning_code": 18,
Expand All @@ -108,6 +70,6 @@
"note": ""
}
],
"updated": "2022-08-10 07:47:14 -0700",
"updated": "2022-10-28 11:43:26 -0700",
"brakeman_version": "5.3.1"
}
23 changes: 0 additions & 23 deletions config/credentials.yml.example

This file was deleted.

26 changes: 26 additions & 0 deletions config/credentials.yml.mysql2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# DMPRoadmap Rails credentials file
# To generate secrets and peppers, run the following in another tab/window `bin/rails secret`

# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: my_secret_key

# Database credentials
db_username: root
db_password:

# Devise credentials (used for user password encryption)
secret_key: my_secret_key
devise_pepper: my_pepper

# Used by the Dragonfly gem for creating random hashes for org logos
dragonfly_secret: my_secret_key

# AWS credentials used by the config/initializers/dragonfly.rb to access your S3 bucket (if applicable)
# aws:
# access_key_id: 12345
# secret_access_key: 34567

# Recaptcha credentials
recaptcha:
site_key: 11111
secret_key: 22222
26 changes: 26 additions & 0 deletions config/credentials.yml.postgresql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# DMPRoadmap Rails credentials file
# To generate secrets and peppers, run the following in another tab/window `bin/rails secret`

# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: my_secret_key

# Database credentials
db_username: postgres
db_password:

# Devise credentials (used for user password encryption)
secret_key: my_secret_key
devise_pepper: my_pepper

# Used by the Dragonfly gem for creating random hashes for org logos
dragonfly_secret: my_secret_key

# AWS credentials used by the config/initializers/dragonfly.rb to access your S3 bucket (if applicable)
# aws:
# access_key_id: 12345
# secret_access_key: 34567

# Recaptcha credentials
recaptcha:
site_key: 11111
secret_key: 22222
Loading