{"id":14955449,"url":"https://github.com/dodonki1223/template_sample_rails_6","last_synced_at":"2025-09-30T13:30:56.213Z","repository":{"id":39210369,"uuid":"243648738","full_name":"dodonki1223/template_sample_rails_6","owner":"dodonki1223","description":"Rails6環境ですぐに開発を始められるようにするためのテンプレート（Docker、CircleCI、自動デプロイ機能導入済み）","archived":false,"fork":false,"pushed_at":"2023-03-08T20:34:33.000Z","size":1459,"stargazers_count":7,"open_issues_count":17,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T11:20:30.159Z","etag":null,"topics":["circleci","circleci-heroku","docker","docker-compose","dockerfile","heroku","postgresql","rails","rails6"],"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/dodonki1223.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-28T00:55:30.000Z","updated_at":"2022-08-08T09:52:57.000Z","dependencies_parsed_at":"2024-09-21T23:00:35.954Z","dependency_job_id":"a87b0855-1c62-4f0d-abc8-7b75d48b05c2","html_url":"https://github.com/dodonki1223/template_sample_rails_6","commit_stats":{"total_commits":137,"total_committers":2,"mean_commits":68.5,"dds":"0.18248175182481752","last_synced_commit":"ebe9ff41af480f1797de9fa8868d0b2de01a23ac"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodonki1223%2Ftemplate_sample_rails_6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodonki1223%2Ftemplate_sample_rails_6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodonki1223%2Ftemplate_sample_rails_6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodonki1223%2Ftemplate_sample_rails_6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dodonki1223","download_url":"https://codeload.github.com/dodonki1223/template_sample_rails_6/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234737856,"owners_count":18879180,"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":["circleci","circleci-heroku","docker","docker-compose","dockerfile","heroku","postgresql","rails","rails6"],"created_at":"2024-09-24T13:11:10.436Z","updated_at":"2025-09-30T13:30:50.816Z","avatar_url":"https://github.com/dodonki1223.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tempalte_sample_rails_6\n\n[![CircleCI](https://circleci.com/gh/dodonki1223/template_sample_rails_6/tree/master.svg?style=svg)](https://circleci.com/gh/dodonki1223/template_sample_rails_6/tree/master)\n\n![00_template_sample_rails_6](https://raw.githubusercontent.com/dodonki1223/image_garage/master/template_sample_rails6/readme/00_template_sample_rails_6.png)\n\n## 概要\n\nRails6アプリケーションの開発をすぐに始められるように素のRails6アプリケーションを元に自分流にカスタマイズしたものになります  \nまたソースコードに不必要なコメントを大量に書いているので使用する場合は適宜、削除することをオススメします\n\n## tempalte_sample_rails_6を動かす\n\n下記コマンドを実行します\n\n```shell\n# ソースコードをcloneする\n$ git clone https://github.com/dodonki1223/template_sample_rails_6.git\n\n# cloneしてきたtempalte_sample_rails_6ディレクトリに移動\n$ cd template_sample_rails_6/\n\n# tempalte_sample_rails_6を動かす\n$ docker-compose up rails\n```\n\nこちらのURL:[http://localhost:3000/](http://localhost:3000/) にアクセスすることで動作確認できます\n**Dockerがインストールされていないと動かすことはできません**\n\n## 環境について\n\n### バージョン情報\n\n| ソフトウェアスタック | バージョン    |\n|:---------------------|:-------------:|\n| Rails                | 6.0.2.1以上   |\n| Ruby                 | 2.6.6         |\n| PostgreSQL           | 12            |\n| Node.js              | 12.16.3       |\n| Yarn                 | 1.22.10       |\n| Bundler              | 2.1.2         |\n| Redis                | 5.0           |\n\n### ローカルでの開発について\n\n基本的にDockerを使用して開発を行えるようになっているのでPCにDockerがインストールされていれば問題ないです\n\n#### PostgreSQLへの接続情報\n\n| DB情報       | 値            |\n|:-------------|:-------------:|\n| Host         | 127.0.0.1     |\n| User         | root          |\n| Password     |               |\n| Port         | 5432          |\n| DatabaseName | dev_sample_db |\n\n### CI（継続的インテグレーション）/CD（継続的デリバリー）環境 - Lint/Test/Deploy\n\n自動テスト、静的コード解析、WebアプリケーションのデプロイはCircleCIで実装されていてデプロイ先には**Heroku**を使用しているのでCircleCIとHerokuの設定も必要になります  \nまたCircleCIの通知用（デプロイの実行、完了通知）としてSlackも使用しているので自分用のWorkspaceを作成することをオススメします\n\n## 改修箇所\n\n自分が使いやすいようにいくつか改修しました\n\n### Docker化\n\nコマンド１つで開発ができるようにDocker化しました  \nDocker内ではよく使う [Redis](https://github.com/redis/redis-rb/)、[Sidekiq](https://github.com/mperham/sidekiq)が既に導入済みです  \nデータベースは [PostgreSQL](https://www.postgresql.jp/document/12/html/) を使用します\n\n### RSpec\n\nデフォルトでは [Minitest](https://github.com/seattlerb/minitest) ですが [RSpec](https://github.com/rspec/rspec-rails) のほうが使い慣れているので [RSpec](https://github.com/rspec/rspec-rails) を導入しています  \nテストデータ作成ツールの [factory_bot](https://github.com/thoughtbot/factory_bot)、コードカバレッジを計測するツールの [SimpleCov](https://github.com/colszowka/simplecov) も導入済みです\n\n### ER図自動生成\n\n[Rails ERD](https://github.com/voormedia/rails-erd) を導入しているのでマイグレーションを実行した時、自動でER図が作成されるようになっています\n\n### デバッグツール\n\nシステムを開発するためには効率よくデバッグできることで開発スピードは格段に上がるためRails開発ではおなじみの `binding.pry` を使用できる状態になっています\n\n### 静的コード解析ツール\n\nコードを一定の品質に保つために静的コード解析ツールを以下の４つが導入済みになっています\n\n- [Rubocop](https://github.com/rubocop-hq/rubocop)(Rubyの静的コードアナライザー及びコードフォーマッター)\n- [Rails Best Practices](https://github.com/flyerhzm/rails_best_practices)(Railsのベストプラクティスを教えてくれる)\n- [Brakeman](https://github.com/presidentbeef/brakeman)(セキュリティの脆弱性チェック)\n- [hadolint](https://github.com/hadolint/hadolint)(Dockerfileの静的コード解析)\n\n### CI（継続的インテグレーション）/CD（継続的デリバリー）環境 - Lint/Test/Deploy\n\nCircleCIにて自動テスト、静的コード解析、自動デプロイ（Heroku）を行うように設定ずみ\n\n### コードの状態\n\n- Railsガイドで紹介されている [rails generate scaffold HighScore game:string score:integer](https://railsguides.jp/command_line.html#rails-generate) を叩いた状態\n\n## 開発\n\n開発環境にはRails以外にもRedisやSidekiq、Webpackerが導入されています  \n起動方法やコマンドの実行方法を解説します\n\n### Railsを起動する\n\n```shell\n$ docker-compose up rails\n```\n\n※`PostgreSQL` 、 `Redis` も一緒に起動します\n\n### Webpackerを起動する\n\n```shell\n$ docker-compose up webpacker\n```\n\n### Sidekiqを起動する\n\n```shell\n$ docker-compose up sidekiq\n```\n\n### Runnerを起動する\n\nRunnerはコマンドを実行するためのサービスになります  \nrakeコマンドやRSpecを実行するために使用します\n\n```shell\n$ docker-compose run --rm runner\n```\n\n以下の説明は `docker-compose run runner` 実行後の説明になります\n\n#### RSpecを実行する\n\n起動後のRunnerはデフォルトだと `RAILS_ENV=development` になっているためコマンドで明示的に `RAILS_ENV=test` を指定して実行します\n\n```shell\n# bundle exec ありバージョン\n$ RAILS_ENV=test bundle exec rspec --format progress\n\n# bundle exec なしバージョン\n$ RAILS_ENV=test rspec --format progress\n```\n\n#### RuboCopを実行する\n\n```shell\n# bundle exec ありバージョン\n$ bundle exec rubocop --require rubocop-rspec -D -P\n\n# bundle exec なしバージョン\n$ rubocop --require rubocop-rspec -D -P\n```\n\n#### Rails Best Practicesを実行する\n\n```shell\n# bundle exec ありバージョン\n$ bundle exec rails_best_practices .\n\n# bundle exec なしバージョン\n$ rails_best_practices .\n```\n\n#### Brakemanを実行する\n\n```shell\n# bundle exec ありバージョン\n$ bundle exec brakeman\n\n# bundle exec なしバージョン\n$ brakeman\n```\n\n#### rakeコマンドを実行する\n\n```shell\n# bin/ ありバージョン\n$ bin/rake about\n\n# bin/ なしバージョン\n$ rake about\n```\n\n#### railsコマンドを実行する\n\n```shell\n# bin/ ありバージョン\n$ bin/rails g --help\n\n# bin/ なしバージョン\n$ rails g --help\n```\n\n#### DBに接続する\n\n```shell\n# bin/ ありバージョン\n$ bin/rails dbconsole\n\n# bin/ なしバージョン\n$ rails dbconsole\n```\n\n### その他\n\n開発時のTipsを紹介します  \nやってもやらなくても良いです\n\n#### GitHooksのpre-pushを使用する\n\n[pre-push](https://githooks.com/)を使用してmaster、developmentブランチにpushする前に静的コード解析を実行してCIで落ちないようにします  \nCIの静的コード解析で落ちて修正するのは時間がかかるのでpush前に検知できた方が良いと思います  \nローカルのgitを使用しているのでDockerで開発しているのにローカルの環境も整える必要があり２重管理になってしまうところが悩みどころです……\n\npre-pushファイルを動作させるためにテンプレートファイルをコピーする\n\n```shell\n$ cp .github/hooks/pre-push .git/hooks/pre-push\n```\n\npre-pushのファイルに実行権限ないとhookされないので実行権限を与えてやる\n\n```shell\n$ chmod 755 .git/hooks/pre-push\n```\n\n## 環境構築\n\nCI（継続的インテグレーション）/CD（継続的デリバリー）環境を実現するために Heroku、CircleCI、Slackの環境構築が必要です  \n下記ドキュメントを参照してください\n\n- [環境構築手順書](https://github.com/dodonki1223/template_sample_rails_6/blob/master/documents/ENVIRONMENTAL_CONSTRUCTION.md)\n\n## 解説\n\n細かい内容について解説しています  \n詳しくは下記を参照してください\n\n- [template_sample_rails_6の解説](https://github.com/dodonki1223/template_sample_rails_6/blob/master/documents/EXPLANATION.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodonki1223%2Ftemplate_sample_rails_6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdodonki1223%2Ftemplate_sample_rails_6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodonki1223%2Ftemplate_sample_rails_6/lists"}