Skip to content

Commit

Permalink
Merge pull request #85 from DFE-Digital/xxx-more-redis-config
Browse files Browse the repository at this point in the history
[xxx] More Redis / Sidekiq config
  • Loading branch information
AbigailMcP authored Aug 10, 2023
2 parents 215ffe1 + f800f63 commit 5454992
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ RUN yarn install --frozen-lockfile --check-files
COPY . .

# Precompile assets
RUN RAILS_ENV=production SECRET_KEY_BASE=required-to-run-but-not-used \
RUN RAILS_ENV=production \
SECRET_KEY_BASE=required-to-run-but-not-used \
REDIS_URL=redis://required-to-run-but-not-used \
bundle exec rails assets:precompile

# Cleanup to save space in the production image
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ the Children’s Barred List.

## Setup

### Prerequisites
### Dependencies

This project depends on:

Expand All @@ -14,6 +14,7 @@ This project depends on:
- [NodeJS](https://nodejs.org/)
- [Yarn](https://yarnpkg.com/)
- [Postgres](https://www.postgresql.org/)
- [Redis](https://redis.io/)

Install dependencies using your preferred method, using `asdf` or `rbenv` or
`nvm`. Example with `asdf`:
Expand All @@ -30,7 +31,24 @@ asdf plugin add postgres
asdf install
```

Setup the project:
#### Redis

You’ll need to install Redis. The way to do this is different on each operating system, but on macOS you can try the following:

```bash
brew install redis
brew services start redis
```

If installing Redis manually, you'll need to start it in a separate terminal:

```bash
redis-server
```

### Application

Setup the project (re-run after `Gemfile` or `package.json` updates, automatically restarts any running Rails server):

```bash
bin/setup
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
config.active_job.queue_adapter = :sidekiq
# config.active_job.queue_name_prefix = "check_the_childrens_barred_list_production"

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
Expand Down
10 changes: 4 additions & 6 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

Sidekiq.configure_server do |config|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
end
url = ENV.fetch("REDIS_URL", "redis://localhost:6379/1")

Sidekiq.configure_client do |config|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
end
Sidekiq.configure_server { |config| config.redis = { url: } }

Sidekiq.configure_client { |config| config.redis = { url: } }
3 changes: 2 additions & 1 deletion terraform/aks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ locals {
app_secrets = merge(
local.kv_app_secrets,
{
DATABASE_URL = module.postgres.url
DATABASE_URL = module.postgres.url,
REDIS_URL = module.redis.url,
}
)
}

0 comments on commit 5454992

Please sign in to comment.