{"id":15821459,"url":"https://github.com/daaain/rails-kata","last_synced_at":"2025-04-01T06:38:31.490Z","repository":{"id":66686491,"uuid":"406517979","full_name":"daaain/rails-kata","owner":"daaain","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-05T22:16:35.000Z","size":449,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T07:51:22.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/daaain.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":"2021-09-14T20:53:10.000Z","updated_at":"2021-10-19T07:30:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"04dd5908-cac0-4cac-8a7b-0778be4cf1b1","html_url":"https://github.com/daaain/rails-kata","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daaain%2Frails-kata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daaain%2Frails-kata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daaain%2Frails-kata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daaain%2Frails-kata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daaain","download_url":"https://codeload.github.com/daaain/rails-kata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246598153,"owners_count":20802973,"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":[],"created_at":"2024-10-05T07:22:25.151Z","updated_at":"2025-04-01T06:38:31.470Z","avatar_url":"https://github.com/daaain.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rails Kata\n\nThis is a little exercise with Rails and all its dependencies running in Docker containers.\n\nIt's using Rails 6.1.4 on Ruby 3.0.2 with PostgreSQL 13.4.\n\n## Setup\n\nThe only system dependencies for development is Docker with Docker Compose and Make.\n\nNOTE: I only tried this on an AMD64 Mac laptop, it might need some adjustments for ARM64. There might also be some issues on Windows (try with WSL2), but should work on Linux too.\n\n## Development\n\nTo get everything going (Docker images built, database set up, app and webpacker running), just type:\n\n```sh\nmake\n```\n\nNow you're ready to try it on http://localhost:3000!\n\nNOTE: the containers are running in the background so you can close the logging output with Ctrl + C without killing the Rails server. You can reattach later with `make logs`.\n\nTo run Rails commands, you can either shell in to the running container with `make app_shell` or start up or run in a separate container using:\n\n```sh\nmake rails -- generate controller Greetings hello\n```\n\n### Testing\n\nTo run unit and watch changes with `autotest`, type:\n\n```sh\nmake test logs\n```\n\nAnd system tests like this (they will only run once, without a watcher):\n\n```sh\nmake systemtest logs\n```\n\nNOTE: these assume you already ran `make` above and have the images built and database set up, otherwise you need to run:\n\n```sh\nmake build db_reset test logs\n```\n\n## Deployment to Google Cloud Run\n\nThe project is set up with the configuration and scripts required to easily deploy the Rails application image as a container in Google Cloud Run with a Cloud SQL Postgres instance. These provide Heroku-like simplicity, but for much less money and with much more flexibility!\n\n### Project and CLI setup\n\nFirst, you need to:\n\n1. [create a new project in GCP](https://console.cloud.google.com/projectselector2/home/dashboard) – note down the generated project ID\n2. [enable billing](https://cloud.google.com/billing/docs/how-to/modify-project)\n3. [enable the Cloud Run, Cloud SQL, and Compute Engine APIs](https://console.cloud.google.com/flows/enableapi?apiid=run.googleapis.com,sql-component.googleapis.com,sqladmin.googleapis.com,compute.googleapis.com)\n4. [install the Cloud SDK](https://cloud.google.com/sdk/docs/install) (you'll need the `gcloud` CLI in particular)\n5. authenticate `gcloud` with the Google account used for creating the project using `gcloud auth login`\n\n### Infrastructure setup\n\nNOTE: this only works after the development setup step above is done as it'll use Rails in a container to set up the encrypted credentials. So if you skipped that, at least you should do:\n\n```sh\nmake build\n```\n\nDue to the simplicity of this exercise, the infrastructure is set up with a series of `gcloud` commands rather than using Terraform or any other \"proper\" Infrastructure as Code tool. This also makes it simpler to automatically save a generated database password into the Rails credentials without having to save it in a file or to display it in the terminal. If you want to see the database password and other secrets decrypted afterwards, you can use `make show_secrets`.\n\nBefore you can run the scripts below, you need to set up some environment variables by typing:\n\n```sh\nsed \"s/PROJECT_ID=/PROJECT_ID=\u003cyour-gcp-project-id\u003e/g\" env-template.sh \u003e env.sh \u0026\u0026 chmod +x env.sh\n```\n\nNow you can set up the GCP infrastructure by typing:\n\n```sh\ngcloud_setup.sh\n```\n\nThen you're ready to build a release image and push it to Google Container Registry:\n\n```sh\nmake release_build\nmake release_push\n```\n\nAnd finally push a deployment out to Cloud Run:\n\n```sh\nMIGRATE=true DB_SEED=true deploy.sh\n```\n\n### Possible improvements\n\n* Store precompiled assets in a bucket and serve from there with a CDN front – currently they are baked in the production image for quick startup, but leaving Rails to serve them up\n* Move Rails Master key to some key management system like Google Secrets Manager\n* Switch to Redis for Action Cable in production – currently using Postgres which is OK without heavy traffic\n* Find out if it's possible to stop Turbolinks from replacing React HTML and only used the cached version – though it might be better to switch to Turbo instead as Turbolinks isn't supported any more\n* Submit new reviews via WebSocket instead of JSON API\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaaain%2Frails-kata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaaain%2Frails-kata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaaain%2Frails-kata/lists"}