{"id":15151501,"url":"https://github.com/d3diva/rails6-docker-stimulus-reflex","last_synced_at":"2026-01-21T17:32:02.162Z","repository":{"id":184250001,"uuid":"454811962","full_name":"d3diva/Rails6-Docker-Stimulus-reflex","owner":"d3diva","description":"Docker Docker-composer Sidekiq Redis Stimulus-reflix","archived":false,"fork":false,"pushed_at":"2022-02-02T16:25:21.000Z","size":155,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T09:43:45.859Z","etag":null,"topics":["docker","docker-compose","mysql","rails6","redis","ruby","sidekiq","stimulus-js","webpacker"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d3diva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-02T14:41:33.000Z","updated_at":"2022-02-03T06:51:46.000Z","dependencies_parsed_at":"2023-07-27T17:09:58.344Z","dependency_job_id":null,"html_url":"https://github.com/d3diva/Rails6-Docker-Stimulus-reflex","commit_stats":null,"previous_names":["d3diva/rails6-docker-stimulus-reflex"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3diva%2FRails6-Docker-Stimulus-reflex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3diva%2FRails6-Docker-Stimulus-reflex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3diva%2FRails6-Docker-Stimulus-reflex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3diva%2FRails6-Docker-Stimulus-reflex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d3diva","download_url":"https://codeload.github.com/d3diva/Rails6-Docker-Stimulus-reflex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247631273,"owners_count":20970038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","mysql","rails6","redis","ruby","sidekiq","stimulus-js","webpacker"],"created_at":"2024-09-26T15:03:49.757Z","updated_at":"2026-01-21T17:32:02.133Z","avatar_url":"https://github.com/d3diva.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\nTo run a Stimulus Reflex in Docker with Sidekiq and Redis \n\n1. Create a Dockerfile\n\n```\nFROM ruby:2.7.3\n\nRUN curl https://deb.nodesource.com/setup_12.x | bash\nRUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -\nRUN echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list\n\nRUN apt-get update \u0026\u0026 apt-get install -y nodejs yarn postgresql-client\n\nWORKDIR /myapp\nCOPY Gemfile /myapp/Gemfile\nCOPY Gemfile.lock /myapp/Gemfile.lock\nRUN bundle install\n\n# Add a script to be executed every time the container starts.\nCOPY entrypoint.sh /usr/bin/\nRUN chmod +x /usr/bin/entrypoint.sh\nENTRYPOINT [\"entrypoint.sh\"]\nEXPOSE 3000\n\n# Configure the main process to run when running the image\nCMD [\"rails\", \"server\", \"-b\", \"0.0.0.0\"]\n```\n\n2. Create a Gemfile\n\n```\nsource 'https://rubygems.org'\ngit_source(:github) { |repo| \"https://github.com/#{repo}.git\" }\n\nruby '2.7.3'\n```\n\n3. Create a Gemfile.lock\n\n`touch Gemfile.lock`\n\n4. Create a docker-compose.yml file\n\n```\nversion: \"3.9\"\nservices:\n  db:\n    image: postgres\n    volumes:\n      - ./tmp/db:/var/lib/postgresql/data\n    environment:\n      POSTGRES_PASSWORD: password\n  web:\n    build: .\n    command: bash -c \"rm -f tmp/pids/server.pid \u0026\u0026 bundle exec rails s -p 3000 -b '0.0.0.0'\"\n    volumes:\n      - .:/myapp\n    environment:\n      RAILS_ENV: \"development\"\n      REDIS_URL: \"redis://redis:6379/12\"\n    ports:\n      - \"3000:3000\"\n    depends_on:\n      - db\n  \n```\n\n5. Generate the project\n\n`docker-compose run web rails new . --force --database=postgresql`\n\n6. Build the containers\n\n`docker-compose build`\n\n7. User permission\n\n`sudo chown -R $USER:$USER .`\n\n8. Update the database config/database.yml\n\n```\ndefault: \u0026default\n  adapter: postgresql\n  encoding: unicode\n  host: db\n  username: postgres\n  password:\n  pool: 5\n\ndevelopment:\n  \u003c\u003c: *default\n  database: myapp_development\n\n\ntest:\n  \u003c\u003c: *default\n  database: myapp_test\n```\n\n9. Create the database\n\n`docker-compose run web rake db:create`\n\n10. Add sidekiq and gem\n\n`gem 'sidekiq'`\n`gem 'stimulus_reflex'`\n\n11. Update Gemfile.lock\n\n`docker-compose run web bundle install`\n\n12. Add redis and sidekiq container\n\n```\nredis:\n    image: redis\n    volumes:\n      - ./tmp/db:/var/lib/redis/data\nsidekiq:\n  build: .\n  command: 'bundle exec sidekiq'\n  volumes:\n    - .:/myapp\n  environment:\n    RAILS_ENV: \"development\"\n    REDIS_URL: \"redis://redis:6379/12\"\n  depends_on:\n    - redis\n```\n\n13. Add active job queue config\n\n```\nconfig.active_job.queue_adapter = :sidekiq\n```\n\n14. Add sidekiq config\n\n```\nSidekiq.configure_server do |config|\n  config.redis = { url: 'redis://redis.example.com:7372/12' }\nend\n\nSidekiq.configure_client do |config|\n  config.redis = { url: 'redis://redis.example.com:7372/12' }\nend\n```\n\n15. Install Stimulus\n\n`docker-compose run web rails stimulus_reflex:install`\n\n16. Install Stimulus Reflex\n\n`docker-compose run web rails webpacker:install:stimulus`\n\n17. Genrate Page Controller\n\n`docker-compose run web rails g controller Pages index`\n\n18. Edit app/views/pages/index.html.erb\n\n```\n\u003ca href=\"#\"\n  data-reflex=\"click-\u003eCounter#increment\"\n  data-step=\"1\" \n  data-count=\"\u003c%= @count.to_i %\u003e\"\n\u003e Increment \u003c%= @count.to_i %\u003e\u003c/a\u003e\n```\n\n19. Add counter_reflex.rb in app/reflex folder and edit and add\n\n```\nclass CounterReflex \u003c ApplicationReflex\n  def increment\n    @count = element.dataset[:count].to_i + element.dataset[:step].to_i\n  end\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3diva%2Frails6-docker-stimulus-reflex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3diva%2Frails6-docker-stimulus-reflex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3diva%2Frails6-docker-stimulus-reflex/lists"}