From 1b7f23db9e6a5a42a5a136ffd711a49aa5efabe8 Mon Sep 17 00:00:00 2001 From: Gabe Mendoza Date: Tue, 29 Oct 2024 23:40:19 -0500 Subject: [PATCH] Fix render (#534) * fix render * save * redis * undo job changes * docker compose port --- backend/Gemfile | 4 +++- backend/Gemfile.lock | 26 +++++++++++++++++++--- backend/app/jobs/save_chat_message_job.rb | 1 - backend/config/application.rb | 4 ++-- docker-compose.yml | 27 ++++++++++++++++++++++- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/backend/Gemfile b/backend/Gemfile index 952a75aec..af0856faa 100644 --- a/backend/Gemfile +++ b/backend/Gemfile @@ -39,6 +39,7 @@ gem "rack-cors", "~> 2" # Utilities gem "awesome_print" +gem "dotenv-rails" gem "ostruct", "~> 0" gem "parallel", "~> 1.26" gem "retries" @@ -47,6 +48,8 @@ gem "uri", "~> 0.13.1" # Redis gem "redis", "~> 5" +gem "redis-namespace" +gem "redis-rails" # Development Tools gem "rb-readline" @@ -82,7 +85,6 @@ end group :development, :test do gem "debug", "~> 1" - gem "dotenv-rails" gem "faker", "~> 3" gem "listen", "~> 3.3" gem "parallel_tests", "~> 4" diff --git a/backend/Gemfile.lock b/backend/Gemfile.lock index 1774a9376..266463f67 100644 --- a/backend/Gemfile.lock +++ b/backend/Gemfile.lock @@ -201,7 +201,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) nokogiri (1.16.7-arm-linux) @@ -294,8 +294,26 @@ GEM psych (>= 4.0.0) redis (5.3.0) redis-client (>= 0.22.0) + redis-actionpack (5.4.0) + actionpack (>= 5, < 8) + redis-rack (>= 2.1.0, < 4) + redis-store (>= 1.1.0, < 2) + redis-activesupport (5.3.0) + activesupport (>= 3, < 8) + redis-store (>= 1.3, < 2) redis-client (0.22.2) connection_pool + redis-namespace (1.11.0) + redis (>= 4) + redis-rack (3.0.0) + rack-session (>= 0.2.0) + redis-store (>= 1.2, < 2) + redis-rails (5.0.2) + redis-actionpack (>= 5.0, < 6) + redis-activesupport (>= 5.0, < 6) + redis-store (>= 1.2, < 2) + redis-store (1.11.0) + redis (>= 4, < 6) regexp_parser (2.9.2) reline (0.5.10) io-console (~> 0.5) @@ -342,7 +360,7 @@ GEM rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + rubocop-ast (1.33.0) parser (>= 3.3.1.0) rubocop-checkstyle_formatter (0.6.0) rubocop (>= 1.14.0) @@ -442,7 +460,7 @@ GEM simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) smart_properties (1.17.0) - sorbet-runtime (0.5.11618) + sorbet-runtime (0.5.11620) spring (4.2.1) sprockets (4.2.1) concurrent-ruby (~> 1.0) @@ -542,6 +560,8 @@ DEPENDENCIES rails-erd rb-readline redis (~> 5) + redis-namespace + redis-rails retries rspec-json_expectations rspec-rails diff --git a/backend/app/jobs/save_chat_message_job.rb b/backend/app/jobs/save_chat_message_job.rb index ee9c626a3..a82e595fd 100644 --- a/backend/app/jobs/save_chat_message_job.rb +++ b/backend/app/jobs/save_chat_message_job.rb @@ -2,7 +2,6 @@ class SaveChatMessageJob < ApplicationJob queue_as :default def perform(match_id:, profile_id:, content:, account_id:, sent_at:, message_type:) - ChatMessage.create!( match_id:, account_id:, diff --git a/backend/config/application.rb b/backend/config/application.rb index 0a966c8f6..4dd815371 100644 --- a/backend/config/application.rb +++ b/backend/config/application.rb @@ -32,10 +32,10 @@ class Application < Rails::Application hostname = Socket.gethostname ENV["POSTGRES_HOST"] = hostname == "rails-api-container" ? "postgres" : "localhost" + redis_host = hostname == "rails-api-container" ? "redis" : "localhost" + ENV["REDIS_URL"] ||= "redis://#{redis_host}:6379/1" ENV["DATABASE_URL"] = nil - ENV["REDIS_URL"] ||= "redis://redis:6379/1" - errors = [] errors << "Missing CLERK_SECRET_KEY environment variable" if ENV.fetch("CLERK_SECRET_KEY", nil).nil? diff --git a/docker-compose.yml b/docker-compose.yml index 8e6895d6f..844f9d999 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,31 @@ services: ports: - 6379:6379 + sidekiq: + image: thatguyinabeanie/battle-stadium:dev-latest + command: zsh -c "(bundle check || bundle install) && bundle exec sidekiq" + environment: + RAILS_ENV: development + ADMIN_BYPASS: "true" + REDIS_URL: redis://redis:6379/1 + ports: + - 10001:3000 + build: + context: backend + dockerfile: Dockerfile.dev + target: development + tags: + - thatguyinabeanie/battle-stadium:dev-latest + cache_from: + - thatguyinabeanie/battle-stadium:dev-latest + depends_on: + - postgres + - redis + volumes: + - .:/battle-stadium + - ./backend/.zshrc:/root/.zshenv + - ./backend/.zshrc:/root/.zshrc + # RAILS API - DEVELOPMENT CONTAINER backend: hostname: rails-api-container @@ -43,7 +68,7 @@ services: - postgres - redis healthcheck: - test: ["CMD", "curl", "-f", "http://backend/up"] + test: ["CMD", "curl", "-f", "http://backend:10000/up"] interval: 60s timeout: 10s retries: 3