{"id":15152539,"url":"https://github.com/odhiambo-ed/rails-docker-setup-2","last_synced_at":"2026-01-19T23:02:17.030Z","repository":{"id":254343717,"uuid":"846245245","full_name":"odhiambo-ed/rails-docker-setup-2","owner":"odhiambo-ed","description":"This repository contains the source code for a Ruby on Rails application configured to use PostgreSQL as the database and run within Docker containers.","archived":false,"fork":false,"pushed_at":"2024-08-28T06:23:04.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T13:18:39.521Z","etag":null,"topics":["docker","docker-compose","postgresql","ruby","ruby-gem","ruby-on-rails"],"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/odhiambo-ed.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":"2024-08-22T20:07:36.000Z","updated_at":"2024-08-28T06:23:08.000Z","dependencies_parsed_at":"2024-08-22T22:39:34.915Z","dependency_job_id":"6db67450-86af-4ce2-80d1-296bd56d4cc2","html_url":"https://github.com/odhiambo-ed/rails-docker-setup-2","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"89a88b6d6eb943e53519926dcd04baf377c1d12d"},"previous_names":["odhiambo-ed/rails-docker-setup-2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odhiambo-ed%2Frails-docker-setup-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odhiambo-ed%2Frails-docker-setup-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odhiambo-ed%2Frails-docker-setup-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odhiambo-ed%2Frails-docker-setup-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odhiambo-ed","download_url":"https://codeload.github.com/odhiambo-ed/rails-docker-setup-2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247639474,"owners_count":20971542,"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","postgresql","ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-09-26T16:03:35.514Z","updated_at":"2026-01-19T23:02:17.000Z","avatar_url":"https://github.com/odhiambo-ed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rails App with PostgreSQL and Docker\n\n## Description\n\n\u003e This repository contains the source code for a Ruby on Rails application configured to use PostgreSQL as the database and run within Docker containers.\n\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed on your machine:\n\n- Docker\n- Docker Compose\n\n## Getting Started\n\n### Step 1: Create a New Rails Application\n\n```\nrails new myapp --database=postgresql\ncd myapp\n```\n\n### Step 2: Add PostgreSQL as the Database\n```\n# Gemfile\ngem 'pg', '\u003e= 0.18', '\u003c 2.0'\n```\n\n```\nbundle install\n```\n\n### Step 3: Install the dockerfile-rails Gem\n\n```\n# Gemfile\ngroup :development do\n  gem 'dockerfile-rails', '~\u003e 1.6', '\u003e= 1.6.17'\nend\n```\n```\nbundle install\n```\n\n### Step 4: Generate Docker and Docker Compose Files\n\n```\nbin/rails generate dockerfile --compose --postgresql\n```\n\n### Step 5: Set Up the .env File\n\n```\ntouch .env\n```\n\nAdd the following content to the .env file:\n\n```\nPOSTGRES_USER=postgres\nPOSTGRES_PASSWORD=yourpassword\nPOSTGRES_DB=myapp_development\nDATABASE_URL=postgres://postgres:yourpassword@db:5432/myapp_development\n```\n\n```\nrails secret\n```\n\n### Step 6: Build and Run the Docker Containers\n\n```\ndocker-compose build\ndocker-compose up\n```\n\n### Final Steps\n\n```\ndocker-compose run web rake db:create db:migrate\n```\n\n## Generate a Secret Key Base:You can generate a new secret key base using the Rails command:\n\n```\nrails secret\n```\n\n#### docker-compose.yml\n\n```\nversion: '3.8'\nservices:\n  db:\n    image: postgres:latest\n    volumes:\n      - postgres_data:/var/lib/postgresql/data\n    environment:\n      POSTGRES_USER: ${POSTGRES_USER}\n      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}\n      POSTGRES_DB: ${POSTGRES_DB}\n\n  web:\n    build: .\n    command: bash -c \"rm -f tmp/pids/server.pid \u0026\u0026 bin/rails server -b 0.0.0.0\"\n    volumes:\n      - .:/third\n    ports:\n      - \"3000:3000\"\n    depends_on:\n      - db\n    environment:\n      DATABASE_URL: ${DATABASE_URL}\n      SECRET_KEY_BASE: \"your_generated_secret_key_base_here\"\n\nvolumes:\n  postgres_data:\n\n```\n\n\n## Author(s)\n\n  \u003ca href=\"https://github.com/odhiambo-ed\" target=\"blank\"\u003e\u003cimg align=\"center\"\n        src=\"https://github.com/white3d/GitHub-User-Content/blob/main/Passport_Ed-M.png\"\n        alt=\"Edward\" height=\"80\" width=\"80\"/\u003e\u003c/a\u003e   **Edward Odhiambo**\n\n- GitHub: [@whit3d](https://github.com/odhiambo-ed)\n- Twitter: [@odhiambo_ed](https://twitter.com/odhiambo_ed)\n- LinkedIn: [Edward Odhiambo](https://www.linkedin.com/in/edward-odhiambo/)\n- Portfolio: [Edward Odhiambo](https://edwardodhiambo.com/)\n\n## 🤝 Contributing\n\nContributions, issues, and feature requests are welcome!!!\n\nFeel free to check the [issues page]https://github.com/odhiambo-ed/rails-docker-setup-2/issues)\n\n## Show your support\n\nGive a ⭐️ if you like this project!\n\n## Acknowledgments\n\n- Hat tip to anyone whose code was used\n\n## 📝 License\n\nThis project is [MIT](https://github.com/white3d/GitHub-User-Content/blob/main/LICENSE) licensed.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodhiambo-ed%2Frails-docker-setup-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodhiambo-ed%2Frails-docker-setup-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodhiambo-ed%2Frails-docker-setup-2/lists"}