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

Update sidekiq, add redis-namespace, add REDIS_NAMESPACE ENV #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /sidekiq
COPY Gemfile* ./
COPY config.ru .

RUN bundle update sidekiq
RUN bundle install

CMD rackup config.ru -o 0.0.0.0 -p 3030 -q
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 5.1'
gem 'sinatra', '~> 2.0'
gem 'sidekiq', '~> 6.4.0'
gem 'sinatra', '~> 2.0'
gem 'redis-namespace', '~> 1.8.1', :require => 'redis/namespace'
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ services:
SIDEKIQ_PASSWORD: password123
ports:
- 3030:3030
```
```

## Build a new container if you make changes

```
docker build -t aschzero/sidekiq-web .
```
6 changes: 5 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
require 'sidekiq'
require 'sidekiq/web'
require 'securerandom'; File.open(".session.key", "w") {|f| f.write(SecureRandom.hex(32)) }

sidekiq_user = ENV.fetch('SIDEKIQ_USER') { 'admin' }
sidekiq_password = ENV.fetch('SIDEKIQ_PASSWORD') { 'admin' }

Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_URL'] }
config.redis = { url: ENV['REDIS_URL'], namespace: ENV['REDIS_NAMESPACE'] }
end

Sidekiq::Web.use(Rack::Auth::Basic) do |user, password|
[user, password] == [sidekiq_user, sidekiq_password]
end

# now use the secret with a session cookie middleware
use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400

run Sidekiq::Web