Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added MAILER_PROTOCOL env var (sets default mailer protocol) #1446

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ These instructions are for setting up a development instance of QPixel. QPixel i
built with Ruby on Rails.

In that guide it is assumed that you already have a Unix environment available
with Ruby and Bundler installed. WSL works as well. Windows (core) has not been tested.
with Ruby and Bundler installed. WSL works as well. Windows (core) has not been tested.

For an installation with **Docker** see the README.md in the [docker](docker) folder
for further instructions.
Expand Down Expand Up @@ -45,6 +45,29 @@ bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"

QPixel is tested with Ruby 3 (and works with Ruby 2.7 as of December 2022).

## Environment

The following lists environment variables provided for QPixel customization
(this section is best-effort, please check for `ENV['<variable name>']`) in source code for the full list of available variables (for Docker-specific variables, see [Docker README](/docker/README.md)):

| Name | Value | Required? | Default | Description |
| --------------------------------- | ------------------------------------------------------ | --------- | -------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `BACKTRACE` | `<1>` | no | - | Enables backtrace for libraries (see [backtrace_silencers.rb](/config/initializers/backtrace_silencers.rb)) |
| `BUNDLE_GEMFILE` | | no | | |
| `CONFIRMABLE_ALLOWED_ACCESS_DAYS` | `<number>` | no | `0` | Sets for how long (in days) an unconfirmed account can access the instance |
| `DRIVER` | `<headless_chrome\|chrome\|headless_firefox\|firefox>` | no | `headless_firefox` | Sets browser to use when running system tests |
| `MAILER_PROTOCOL` | `http\|https` | no | `https` | Sets default URL protocol to use with mailes (f.e., confirmation emails) |
| `PIDFILE` | `<string>` | no | `tmp/pids/server.pid` | Sets pidfile (a file where the id of a process is written to) for Puma |
| `PORT` | `<number>` | no | `3000` | Sets the port on which the server will listen for incoming requests |
| `RAILS_ENV` | `<development\|production\|test>` | no | `development` | Sets the environment to use (see [config/environments](/config/environments/)) |
| `RAILS_MAX_THREADS` | `<number>` | no | `5` | Sets the maximum number of threads from the internal thread pool to use for requests |
| `RAILS_MIN_THREADS` | `<number>` | no | `5` | Sets the minimum number of threads from the internal pool to use for requests |
| `RAILS_SERVE_STATIC_FILES` | `<boolean>` | no | - | |
| `REDIS_URL` | `<string>` | no | `redis://localhost:6379/1` | |
| `SECRET_KEY_BASE` | `<string>` | yes | - | Sets the secret key for signed cookie verification (can be generated with `rake secret`, used in `production`) |
| `SEEDS` | `<seeds source name>` | no | - | Runs only a specified set of seeds from [db/seeds](/db/seeds/) |
| `UPDATE_POSTS` | `<boolean>` | no | - | If set to `true`, updates seeded posts when running post seeds |
| `WEB_CONCURRENCY` | `<number>` | no | `2` | |

### Install JS runtime

Expand Down Expand Up @@ -142,7 +165,7 @@ Community.create(name: 'Dev Community', host: 'localhost:3000')
Rails.cache.clear
```

After that you can run `rails db:seed` to fill the database with necessary seed data, such as settings, help posts and default templates. (If you are preparing a production deployment, you might choose to edit some of the help seeds first. See "Help Topics" at the end of this guide.)
After that you can run `rails db:seed` to fill the database with necessary seed data, such as settings, help posts and default templates. (If you are preparing a production deployment, you might choose to edit some of the help seeds first. See "Help Topics" at the end of this guide.)

$ rails db:seed
Category: Created 2, skipped 0
Expand Down Expand Up @@ -182,8 +205,8 @@ Go to `http://localhost:3000/categories/`

![img/categories.png](img/categories.png)

Click "edit" for each category and scroll down to see the "Tag Set" field. This
will be empty on first setup.
Click "edit" for each category and scroll down to see the "Tag Set" field. This
will be empty on first setup.

![img/tagset.png](img/tagset.png)

Expand All @@ -208,20 +231,18 @@ And then click to "Save Post in Q&A"

## Optional: Help Topics

If you are running a development server, you might not care a lot about what's in the help. If you are planning to deploy a server for actual use, however, note that the seeds have some placeholder text you'll want to edit. We have provided starting points (to be edited) for the following topics:
If you are running a development server, you might not care a lot about what's in the help. If you are planning to deploy a server for actual use, however, note that the seeds have some placeholder text you'll want to edit. We have provided starting points (to be edited) for the following topics:

- Terms of service (TOS)
- Code of conduct (COC)
- Privacy policy
- Spam policy
- Terms of service (TOS)
- Code of conduct (COC)
- Privacy policy
- Spam policy
- Global (network) FAQ

The corresponding posts in db/seeds/posts have some places marked with "$EDIT" where you will probably want to insert URLs, email addresses, and the like. We recommend reviewing all of the content in these topics. There are two ways to edit these topics: in the source files before adding to your database, or through the UI in your running instance.
The corresponding posts in db/seeds/posts have some places marked with "$EDIT" where you will probably want to insert URLs, email addresses, and the like. We recommend reviewing all of the content in these topics. There are two ways to edit these topics: in the source files before adding to your database, or through the UI in your running instance.

If you edit the seed files, use the following command to add them to your database:

`UPDATE_POSTS=true rails db:seed`

You can also edit the topics in the UI. As an administrator, you'll see an edit button on help topics when you view them, and the editor provides an option to deploy changes across your network of communities. Administrators can update help topics in this way at any time.


You can also edit the topics in the UI. As an administrator, you'll see an edit button on help topics when you view them, and the editor provides an option to deploy changes across your network of communities. Administrators can update help topics in this way at any time.
5 changes: 4 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@
config.i18n.raise_on_missing_translations = true

config.action_mailer.delivery_method = :letter_opener_web
config.action_mailer.default_url_options = { host: 'meta.codidact.com', protocol: 'https' }

config.action_mailer.default_url_options = {
host: 'meta.codidact.com', protocol: ENV['MAILER_PROTOCOL'] || 'https'
}

# Ensure docker ip added to allowed, given that we are in container
if File.file?('/.dockerenv') == true
Expand Down
5 changes: 4 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

config.action_mailer.delivery_method = :ses
config.action_mailer.default_url_options = { host: 'meta.codidact.com', protocol: 'https' }
config.action_mailer.default_url_options = {
host: 'meta.codidact.com',
protocol: ENV['MAILER_PROTOCOL'] || 'https'
}
config.action_mailer.asset_host = 'https://meta.codidact.com'

# Do not dump schema after migrations.
Expand Down
5 changes: 4 additions & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

config.action_mailer.default_url_options = { host: 'test.host' }
config.action_mailer.default_url_options = {
host: 'test.host',
protocol: ENV['MAILER_PROTOCOL'] || 'https'
}

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
environment:
- COMMUNITY_NAME=${COMMUNITY_NAME}
- RAILS_ENV=${RAILS_ENV}
- MAILER_PROTOCOL=${MAILER_PROTOCOL}
- CONFIRMABLE_ALLOWED_ACCESS_DAYS=${CONFIRMABLE_ALLOWED_ACCESS_DAYS}
- LOCAL_DEV_PORT=${LOCAL_DEV_PORT}
env_file:
Expand Down
1 change: 1 addition & 0 deletions docker/compose-env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LOCAL_DEV_PORT=3000
COMMUNITY_NAME=Dev Community
MAILER_PROTOCOL=https
RAILS_ENV=development
CONFIRMABLE_ALLOWED_ACCESS_DAYS=2
ENV_FILE_LOCATION=./docker/env
Loading