From d3e5682cb83d44f262c361dd0c0ed7647be98d84 Mon Sep 17 00:00:00 2001 From: Graham Schmidt Date: Tue, 26 Apr 2022 19:46:03 +0000 Subject: [PATCH 1/3] Updates --- Dockerfile | 1 + Gemfile | 4 ++-- config.ru | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d68bb7..42b984f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Gemfile b/Gemfile index f9d7660..20d1c83 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -gem 'sidekiq', '~> 5.1' -gem 'sinatra', '~> 2.0' \ No newline at end of file +gem 'sidekiq', '~> 6.4.0' +gem 'sinatra', '~> 2.0' diff --git a/config.ru b/config.ru index 3ecb88f..bb82836 100644 --- a/config.ru +++ b/config.ru @@ -5,7 +5,7 @@ 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| From 54e1ecbf6cd3bc2a185be807914d0c3c11d19826 Mon Sep 17 00:00:00 2001 From: Graham Schmidt Date: Tue, 26 Apr 2022 19:56:04 +0000 Subject: [PATCH 2/3] Add session handling --- Gemfile | 2 ++ config.ru | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index 20d1c83..1b9f766 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,5 @@ source 'https://rubygems.org' gem 'sidekiq', '~> 6.4.0' gem 'sinatra', '~> 2.0' +# gem 'redis', '~> 4.5.1' +gem 'redis-namespace', '~> 1.8.1', :require => 'redis/namespace' diff --git a/config.ru b/config.ru index bb82836..7915f1b 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,6 @@ 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' } @@ -12,4 +13,7 @@ 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 From 4554f55715a64c9e7a058b3682386fa6f26bba2d Mon Sep 17 00:00:00 2001 From: Graham Schmidt Date: Tue, 26 Apr 2022 20:24:55 +0000 Subject: [PATCH 3/3] Update docs --- Gemfile | 1 - README.md | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 1b9f766..5271c96 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,4 @@ source 'https://rubygems.org' gem 'sidekiq', '~> 6.4.0' gem 'sinatra', '~> 2.0' -# gem 'redis', '~> 4.5.1' gem 'redis-namespace', '~> 1.8.1', :require => 'redis/namespace' diff --git a/README.md b/README.md index b6e8d68..3c0ef97 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,10 @@ services: SIDEKIQ_PASSWORD: password123 ports: - 3030:3030 -``` \ No newline at end of file +``` + +## Build a new container if you make changes + +``` +docker build -t aschzero/sidekiq-web . +```