Chore: Sidekiq ActionCable fix for Development (#405)
- action cable works from sidekiq in development environments - documentation updates for docker
This commit is contained in:
parent
f178429df2
commit
91ace96acd
6 changed files with 40 additions and 14 deletions
|
@ -36,6 +36,10 @@ AWS_REGION=
|
|||
#sentry
|
||||
SENTRY_DSN=
|
||||
|
||||
# Credentials to access sidekiq dashboard in production
|
||||
SIDEKIQ_AUTH_USERNAME=
|
||||
SIDEKIQ_AUTH_PASSWORD=
|
||||
|
||||
#### This environment variables are only required in hosted version which has billing
|
||||
ENABLE_BILLING=
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
development:
|
||||
adapter: async
|
||||
adapter: redis
|
||||
url: <%= ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379') %>
|
||||
|
||||
test:
|
||||
adapter: test
|
||||
|
|
|
@ -90,12 +90,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
# Sidekiq Web UI
|
||||
require 'sidekiq/web'
|
||||
authenticate :user, ->(u) { u.administrator? } do
|
||||
mount Sidekiq::Web => '/sidekiq'
|
||||
end
|
||||
|
||||
# Used in mailer templates
|
||||
resource :app, only: [:index] do
|
||||
resources :conversations, only: [:show]
|
||||
|
@ -106,4 +100,25 @@ Rails.application.routes.draw do
|
|||
|
||||
# Routes for testing
|
||||
resources :widget_tests, only: [:index] unless Rails.env.production?
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Internal Monitoring Routes
|
||||
require 'sidekiq/web'
|
||||
|
||||
scope :monitoring do
|
||||
# Sidekiq should use basic auth in production environment
|
||||
if Rails.env.production?
|
||||
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
|
||||
ENV['SIDEKIQ_AUTH_USERNAME'] &&
|
||||
ENV['SIDEKIQ_AUTH_PASSWORD'] &&
|
||||
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username),
|
||||
::Digest::SHA256.hexdigest(ENV['SIDEKIQ_AUTH_USERNAME'])) &&
|
||||
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password),
|
||||
::Digest::SHA256.hexdigest(ENV['SIDEKIQ_AUTH_PASSWORD']))
|
||||
end
|
||||
end
|
||||
|
||||
mount Sidekiq::Web, at: '/sidekiq'
|
||||
end
|
||||
# ----------------------------------------------------------------------
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ services:
|
|||
- redis
|
||||
ports:
|
||||
- 3000:3000
|
||||
env_file: .env.example ## Change this file for customised env variables
|
||||
env_file: .env ## Change this file for customized env variables
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- RAILS_ENV=production
|
||||
|
|
|
@ -32,7 +32,7 @@ services:
|
|||
- mailhog
|
||||
ports:
|
||||
- 3000:3000
|
||||
env_file: .env.example
|
||||
env_file: .env
|
||||
environment:
|
||||
- WEBPACKER_DEV_SERVER_HOST=webpack
|
||||
- NODE_ENV=development
|
||||
|
|
|
@ -7,6 +7,12 @@ title: "Docker Setup and Debugging Guide"
|
|||
|
||||
After cloning the repo and installing docker on your machine, run the following command from the root directory of the project.
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Make changes to the `.env` file as required. [Optional]
|
||||
|
||||
```bash
|
||||
docker-compose build
|
||||
```
|
||||
|
@ -14,19 +20,19 @@ docker-compose build
|
|||
After building the image or after destroying the stack you would have to reset the database using following command
|
||||
|
||||
```bash
|
||||
docker-compose run rails bundle exec rails db:reset
|
||||
docker-compose run --rm rails bundle exec rails db:reset
|
||||
```
|
||||
|
||||
### Running the app
|
||||
|
||||
```bash
|
||||
docker-compose run --service-port rails
|
||||
docker-compose run --rm --service-port rails
|
||||
```
|
||||
|
||||
open another terminal and also run below command to run sidekiq in a separate service
|
||||
|
||||
```
|
||||
docker-compose run rails bundle exec sidekiq
|
||||
docker-compose run --rm rails bundle exec sidekiq
|
||||
```
|
||||
|
||||
* Access the rails app frontend by visiting `http://0.0.0.0:3000/`
|
||||
|
@ -50,13 +56,13 @@ docker-compose down
|
|||
For running the complete rspec tests
|
||||
|
||||
```bash
|
||||
docker-compose run rails bundle exec rspec
|
||||
docker-compose run --rm rails bundle exec rspec
|
||||
```
|
||||
|
||||
For running specific test:
|
||||
|
||||
```bash
|
||||
docker-compose run rails bundle exec rspec spec/<path-to-file>:<line-number>
|
||||
docker-compose run --rm rails bundle exec rspec spec/<path-to-file>:<line-number>
|
||||
```
|
||||
|
||||
## production environment
|
||||
|
|
Loading…
Reference in a new issue