Skip to content

Commit

Permalink
Merge branch 'hotfix/1.0.3' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	config/cable.yml
#	docs/development/environment-setup/docker.md
  • Loading branch information
sony-mathew committed Jan 26, 2020
2 parents 1fd4127 + 2168f82 commit 8cf135f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
REDIS_URL=redis://redis:6379
SECRET_KEY_BASE=

#redis config
REDIS_URL=redis://redis:6379
# If you are using docker-compose, set this variable's value to be any string,
# which will be the password for the redis service running inside the docker-compose
# to make it secure
REDIS_PASSWORD=

# Postgres Database config variables
POSTGRES_HOST=postgres
POSTGRES_USERNAME=postgres
Expand Down
3 changes: 3 additions & 0 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
development:
adapter: redis
url: <%= ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379') %>
password: <%= ENV.fetch('REDIS_PASSWORD', nil) %>

test:
adapter: test

staging:
adapter: redis
url: <%= ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379') %>
password: <%= ENV.fetch('REDIS_PASSWORD', nil) %>

production:
adapter: redis
url: <%= ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379') %>
password: <%= ENV.fetch('REDIS_PASSWORD', nil) %>
7 changes: 5 additions & 2 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uri = URI.parse(ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'))
redis = Rails.env.test? ? MockRedis.new : Redis.new(url: uri)
app_redis_config = {
url: URI.parse(ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379')),
password: ENV.fetch('REDIS_PASSWORD', nil)
}
redis = Rails.env.test? ? MockRedis.new : Redis.new(app_redis_config)
Nightfury.redis = Redis::Namespace.new('reports', redis: redis)

# Alfred - Used currently for round robin and conversation emails.
Expand Down
11 changes: 11 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sidekiq_redis_config = {
url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'),
password: ENV.fetch('REDIS_PASSWORD', nil)
}
Sidekiq.configure_client do |config|
config.redis = sidekiq_redis_config
end

Sidekiq.configure_server do |config|
config.redis = sidekiq_redis_config
end
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:
- cache:/app/tmp/cache
ports:
- "3035" # Webpack dev server
env_file: .env.example
env_file: .env
environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
- NODE_ENV=development
Expand All @@ -76,6 +76,8 @@ services:
redis:
image: redis:alpine
restart: always
command: ["sh", "-c", "redis-server --requirepass \"$REDIS_PASSWORD\""]
env_file: .env
volumes:
- redis:/data/redis
ports:
Expand Down
3 changes: 2 additions & 1 deletion docs/development/environment-setup/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ After cloning the repo and installing docker on your machine, run the following
cp .env.example .env
```

Make changes to the `.env` file as required. [Optional]
Make changes to the `.env` file as required [Optional]. If you want to set the password for redis when you run
docker-compose, set any string value to the environment variable `REDIS_PASSWORD` in the `.env` file. which will secure the redis running inside docker-compose with this password. This will be automatically picked up by app server and sidekiq, to authenticate while making connections to redis server.

```bash
docker-compose build
Expand Down
9 changes: 8 additions & 1 deletion docs/development/project-setup/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ But you can change it to use any of the cloud providers like amazon s3, microsof
ACTIVE_STORAGE_SERVICE='local'
```
### Configure Redis URL
### Configure Redis
For development, you can use the following url to connect to redis.
```bash
REDIS_URL='redis:://127.0.0.1:6379'
```
To authenticate redis connections made by app server and sidekiq, if it's protected by a password, use the following
environment variable to set the password.
```bash
REDIS_PASSWORD=
```
### Configure Postgres host
You can set the following environment variable to set the host for postgres.
Expand Down

0 comments on commit 8cf135f

Please sign in to comment.