{"id":13416327,"url":"https://github.com/ledermann/docker-rails","last_synced_at":"2025-10-23T06:30:17.798Z","repository":{"id":12577645,"uuid":"72115697","full_name":"ledermann/docker-rails","owner":"ledermann","description":"Dockerize Rails 7 with ActionCable, Webpacker, Stimulus, Elasticsearch, Sidekiq","archived":true,"fork":false,"pushed_at":"2024-10-29T04:23:56.000Z","size":14128,"stargazers_count":1121,"open_issues_count":1,"forks_count":175,"subscribers_count":23,"default_branch":"develop","last_synced_at":"2025-02-07T11:49:39.391Z","etag":null,"topics":["actioncable","deployment","docker","file-upload","opensearch","rails","reference-implementation","ruby","sidekiq","stimulusjs"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ledermann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-27T14:21:49.000Z","updated_at":"2024-11-28T16:13:10.000Z","dependencies_parsed_at":"2024-04-28T06:33:36.156Z","dependency_job_id":"9287ffe8-e982-4670-a69a-faf2a68b0e77","html_url":"https://github.com/ledermann/docker-rails","commit_stats":{"total_commits":6181,"total_committers":10,"mean_commits":618.1,"dds":0.5194952273094968,"last_synced_commit":"f365e751331d373823571cf8837201ba54801875"},"previous_names":[],"tags_count":34,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledermann%2Fdocker-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledermann%2Fdocker-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledermann%2Fdocker-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledermann%2Fdocker-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ledermann","download_url":"https://codeload.github.com/ledermann/docker-rails/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237784841,"owners_count":19365940,"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":["actioncable","deployment","docker","file-upload","opensearch","rails","reference-implementation","ruby","sidekiq","stimulusjs"],"created_at":"2024-07-30T21:00:57.132Z","updated_at":"2025-10-23T06:30:17.319Z","avatar_url":"https://github.com/ledermann.png","language":"Ruby","readme":"# Docker-Rails\n\nSimple Rails 7.0 application to demonstrate using Docker for production deployment. The application is a very simple kind of CMS (content management system) allowing to manage posts. Beside the boring [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) functionality it has some non-default features.\n\nThis project aims to build a lean Docker image for use in production. Therefore it's based on the official Alpine Ruby image, uses multi-stage building and some [optimizations that I described in my blog](https://ledermann.dev/blog/2018/04/19/dockerize-rails-the-lean-way/). This results in an image size of ~80MB.\n\n\n## Features\n\n- Auto refresh via [ActionCable](https://github.com/rails/rails/tree/master/actioncable): If a displayed post gets changed by another user/instance, it refreshes automatically using the publish/subscribe pattern\n- Full text search via [OpenSearch](https://opensearch.org/) and the [Searchkick](https://github.com/ankane/searchkick) gem to find post content (with suggestions)\n- Autocompletion with [autocompleter](https://github.com/kraaden/autocomplete)\n- Editing HTML content with the WYSIWYG JavaScript editor [Trix](https://github.com/basecamp/trix)\n- Uploading images directly to S3 with the [Shrine](https://github.com/janko-m/shrine) gem and [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload)\n- Background jobs with [ActiveJob](https://github.com/rails/rails/tree/master/activejob) and the [Sidekiq](http://sidekiq.org/) gem (to handle full text indexing, image processing and ActionCable broadcasting)\n- Cron scheduling with [Sidekiq-Cron](https://github.com/ondrejbartas/sidekiq-cron) to handle daily data updates from Wikipedia\n- Permalinks using the [FriendlyId](https://github.com/norman/friendly_id) gem\n- Infinitive scrolling (using the [Kaminari](https://github.com/kaminari/kaminari) gem and some JavaScript)\n- User authentication with the [Clearance](https://github.com/thoughtbot/clearance/) gem\n- Sending HTML e-mails with [Premailer](https://github.com/fphilipe/premailer-rails) and the [Really Simple Responsive HTML Email Template](https://github.com/leemunroe/responsive-html-email-template)\n- Admin dashboards with [Blazer](https://github.com/ankane/blazer) gem\n- JavaScript with [Stimulus](https://stimulusjs.org/)\n- Bundle JavaScript libraries with [Yarn](https://yarnpkg.com)\n\n\n## Why?\n\nThis project demonstrates my way of building Rails applications. The techniques used to build the app should not be considered as \"best practice\", maybe there are better ways to build. Any [feedback](https://github.com/ledermann/docker-rails/issues/new) would be appreciated.\n\n\n## Multi container architecture\n\nThere is an example **docker-compose.production.yml**. The whole stack is divided into multiple different containers:\n\n- **app:** Main part. It contains the Rails code to handle web requests (by using the [Puma](https://github.com/puma/puma) gem). See the [Dockerfile](/Dockerfile) for details. The image is based on the Alpine variant of the official [Ruby image](https://hub.docker.com/_/ruby/) and uses multi-stage building.\n- **worker:** Background processing. It contains the same Rails code, but only runs Sidekiq\n- **db:** PostgreSQL database\n- **opensearch:** Full text search engine\n- **redis:** In-memory key/value store (used by Sidekiq, ActionCable and for caching)\n- **backup:** Regularly backups the database as a dump via CRON to an Amazon S3 bucket\n\n## Check it out!\n\nTo start up the application in your local Docker environment:\n\n```bash\ngit clone https://github.com/ledermann/docker-rails.git\ncd docker-rails\ndocker-compose build\ndocker-compose up\n```\n\nWait some minutes while the database will be prepared by fetching articles from Wikipedia. Then,\nnavigate your browser to `http://[DOCKER_HOST]:[DOCKER_PORT]`.\n\nSign in to the admin account:\n\n* Username: `admin@example.org`\n* Password: `secret`\n\nEnjoy!\n\n\n## Tests / CI\n\nOn every push, the test suite (including [RuboCop](https://github.com/bbatsov/rubocop) checks) is performed via [GitHub Actions](https://github.com/ledermann/docker-rails/actions). If successful, a production image is built and pushed to GitHub Container Registry.\n\n\n## Production deployment\n\nThe Docker image build includes precompiled assets only (no node_modules and no sources). The [spec folder](/spec) is removed and the Alpine packages for Node and Yarn are not installed.\n\nThe stack is ready to host with [traefik](https://traefik.io/) or [nginx proxy](https://github.com/jwilder/nginx-proxy) and [letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion).\n\n\n## Demo\n\nA demo installation is set up on [https://docker-rails.ledermann.dev](https://docker-rails.ledermann.dev).\n","funding_links":[],"categories":["Ruby","Starters/Boilerplates"],"sub_categories":["Articles"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledermann%2Fdocker-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fledermann%2Fdocker-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledermann%2Fdocker-rails/lists"}