Feature: Add Sidekiq docker (#443)

* update db:schema due to migration

* reduce default concurrency for redis connection limit

* Allow auto update packages in the development mode without building image

* add sidekiq support to docker-compose

* Pass sidekiq cofig file

* passed the env file in base image rather than separately in rails, web packer and sidekiq in docker-compose
* removed un-necessary changes in schema
* changed concurrency to finer values
* removed default size set in sidekiq redis config
* Added the sidekiq config option in Procfile.dev

Co-authored-by: Sony Mathew <ynos1234@gmail.com>
This commit is contained in:
Anto Dominic 2020-01-27 05:30:13 +11:00 committed by Sony Mathew
parent 8cf135f2db
commit 6325acd183
5 changed files with 32 additions and 8 deletions

View file

@ -1,3 +1,3 @@
backend: bin/rails s -p 3000 backend: bin/rails s -p 3000
frontend: bin/webpack-dev-server frontend: bin/webpack-dev-server
worker: bundle exec sidekiq worker: bundle exec sidekiq -C config/sidekiq.yml

View file

@ -2,10 +2,11 @@ sidekiq_redis_config = {
url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'), url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'),
password: ENV.fetch('REDIS_PASSWORD', nil) password: ENV.fetch('REDIS_PASSWORD', nil)
} }
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = sidekiq_redis_config config.redis = sidekiq_redis_config.merge(size: 5)
end end
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = sidekiq_redis_config config.redis = sidekiq_redis_config.merge(size: 10)
end end

View file

@ -4,7 +4,7 @@
# pick it up automatically. # pick it up automatically.
--- ---
:verbose: false :verbose: false
:concurrency: 10 :concurrency: 3
:timeout: 25 :timeout: 25
# Sidekiq will run this file through ERB when reading it so you can # Sidekiq will run this file through ERB when reading it so you can
@ -18,6 +18,6 @@
# you can override concurrency based on environment # you can override concurrency based on environment
production: production:
:concurrency: 3 :concurrency: 10
staging: staging:
:concurrency: 15 :concurrency: 5

View file

@ -13,6 +13,7 @@ services:
tty: true tty: true
stdin_open: true stdin_open: true
image: chatwoot:development image: chatwoot:development
env_file: .env
rails: rails:
<<: *base <<: *base
@ -25,14 +26,15 @@ services:
- node_modules:/app/node_modules - node_modules:/app/node_modules
- packs:/app/public/packs - packs:/app/public/packs
- cache:/app/tmp/cache - cache:/app/tmp/cache
- bundle:/usr/local/bundle
depends_on: depends_on:
- postgres - postgres
- redis - redis
- webpack - webpack
- mailhog - mailhog
- sidekiq
ports: ports:
- 3000:3000 - 3000:3000
env_file: .env
environment: environment:
- WEBPACKER_DEV_SERVER_HOST=webpack - WEBPACKER_DEV_SERVER_HOST=webpack
- NODE_ENV=development - NODE_ENV=development
@ -40,6 +42,24 @@ services:
entrypoint: docker/entrypoints/rails.sh entrypoint: docker/entrypoints/rails.sh
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"] command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
sidekiq:
<<: *base
image: chatwoot-rails:development
volumes:
- ./:/app:delegated
- node_modules:/app/node_modules
- packs:/app/public/packs
- cache:/app/tmp/cache
- bundle:/usr/local/bundle
depends_on:
- postgres
- redis
- mailhog
environment:
- NODE_ENV=development
- RAILS_ENV=development
command: ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]
webpack: webpack:
<<: *base <<: *base
build: build:
@ -51,9 +71,9 @@ services:
- node_modules:/app/node_modules # Node modules shared across containers - node_modules:/app/node_modules # Node modules shared across containers
- packs:/app/public/packs - packs:/app/public/packs
- cache:/app/tmp/cache - cache:/app/tmp/cache
- bundle:/usr/local/bundle
ports: ports:
- "3035" # Webpack dev server - "3035" # Webpack dev server
env_file: .env
environment: environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0 - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
- NODE_ENV=development - NODE_ENV=development
@ -95,3 +115,4 @@ volumes:
packs: packs:
node_modules: node_modules:
cache: cache:
bundle:

View file

@ -17,6 +17,8 @@ done
echo "Database ready to accept connections." echo "Database ready to accept connections."
bundle install
BUNDLE="bundle check" BUNDLE="bundle check"
until $BUNDLE until $BUNDLE