From 3b67ffee409fabb04ffd94a6cff5511dcdf3930b Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Fri, 26 Oct 2018 11:59:49 -0400 Subject: [PATCH] Generalized logs and mailer (#312) --- config/application.rb | 13 +++++-------- config/environments/development.rb | 4 ++-- config/environments/production.rb | 4 ++-- docker-compose.yml | 7 ++++++- sample.env | 28 ++++++++++++++++++---------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/config/application.rb b/config/application.rb index 3118ee79..c3de455b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -55,19 +55,16 @@ module Greenlight config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" # Use standalone BigBlueButton server. - config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] - config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] - - # Fallback to testing credentails. - if config.bigbluebutton_endpoint.blank? - config.bigbluebutton_endpoint = config.bigbluebutton_endpoint_default - config.bigbluebutton_secret = config.bigbluebutton_secret_default - end + config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] || config.bigbluebutton_endpoint_default + config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] || config.bigbluebutton_secret_default # Fix endpoint format if required. config.bigbluebutton_endpoint += "api/" unless config.bigbluebutton_endpoint.ends_with?('api/') end + # Specify the email address that all mail is sent from + config.email_sender = ENV['EMAIL_SENDER'].present? ? ENV['EMAIL_SENDER'] : "notifications@example.com" + # Determine if GreenLight should enable email verification config.enable_email_verification = (ENV['ALLOW_MAIL_NOTIFICATIONS'] == "true") diff --git a/config/environments/development.rb b/config/environments/development.rb index b3178310..cdd5c078 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -28,8 +28,8 @@ Rails.application.configure do config.cache_store = :null_store end - # Tell Action Mailer to use smtp server - config.action_mailer.delivery_method = :smtp + # Tell Action Mailer to use smtp server, if configured + config.action_mailer.delivery_method = ENV['SMTP_SERVER'].present? ? :smtp : :sendmail ActionMailer::Base.smtp_settings = { address: ENV['SMTP_SERVER'], diff --git a/config/environments/production.rb b/config/environments/production.rb index 90a1de00..fd1d8ae5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -54,8 +54,8 @@ Rails.application.configure do # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Tell Action Mailer to use smtp server - config.action_mailer.delivery_method = :smtp + # Tell Action Mailer to use smtp server, if configured + config.action_mailer.delivery_method = ENV['SMTP_SERVER'].present? ? :smtp : :sendmail ActionMailer::Base.smtp_settings = { address: ENV['SMTP_SERVER'], diff --git a/docker-compose.yml b/docker-compose.yml index 7b50ff0c..4c76ee10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,15 @@ services: entrypoint: [bin/start] image: bigbluebutton/greenlight:v2 container_name: greenlight-v2 - env_file: env + env_file: .env restart: unless-stopped ports: - 5000:80 volumes: - ./db/production:/usr/src/app/db/production - ./log:/usr/src/app/log +# logging: +# driver: $LOG_DRIVER +# options: +# syslog-address: $LOG_ADDRESS +# tag: $LOG_TAG diff --git a/sample.env b/sample.env index 309866eb..8125d3c1 100644 --- a/sample.env +++ b/sample.env @@ -73,9 +73,11 @@ ALLOW_GREENLIGHT_ACCOUNTS=true # Set this to true if you want GreenLight to send verification emails upon # the creation of a new account # -# SMTP variables can be configured by following the template: -# # ALLOW_MAIL_NOTIFICATIONS=true +# +# The notifications are sent using sendmail, unless the SMTP_SERVER variable is set. +# In that case, make sure the rest of the variables are properly set. +# # SMTP_SERVER=smtp.gmail.com # SMTP_PORT=587 # SMTP_DOMAIN=gmail.com @@ -84,7 +86,6 @@ ALLOW_GREENLIGHT_ACCOUNTS=true # SMTP_AUTH=plain # SMTP_STARTTLS_AUTO=true # -ALLOW_MAIL_NOTIFICATIONS= SMTP_SERVER= SMTP_PORT= SMTP_DOMAIN= @@ -110,17 +111,24 @@ BRANDING_IMAGE= # # RAILS_LOG_TO_STDOUT=true # -# When using docker-compose the logs can be sent to an external service like PaperTrail +# When using docker-compose the logs can be sent to an centralized repository like PaperTrail # just by using the built in driver. Make sure to add to docker-compose.yml the next lines: # # logging: -# driver: syslog +# driver: $LOG_DRIVER # options: -# syslog-address: "tcp+tls://logs4.papertrailapp.com:[99999]" -# tag: greenlight.mydomain.com:v2 +# syslog-address: $LOG_ADDRESS +# tag: $LOG_TAG # - -# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. -# It is disabled by default. +# And set this variables up: +# +# LOG_DRIVER=syslog +# LOG_ADDRESS=udp://logs4.papertrailapp.com:[99999] +# LOG_TAG=greenlight.example.com:v2 +# +# Check docker-compose and papertrail documentation for encrypting and +# protecting access to the log repository. +# https://docs.docker.com/config/containers/logging/syslog/#options +# https://help.papertrailapp.com/kb/configuration/encrypting-remote-syslog-with-tls-ssl/ # # ENABLE_SSL=true