{"id":13753184,"url":"https://github.com/phawk/rails-deploy","last_synced_at":"2025-08-01T22:41:48.664Z","repository":{"id":25286551,"uuid":"28712413","full_name":"phawk/rails-deploy","owner":"phawk","description":"Ansible scripts to setup a fully loaded ruby/rails web server","archived":false,"fork":false,"pushed_at":"2015-08-23T19:26:11.000Z","size":251,"stargazers_count":50,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T21:45:55.760Z","etag":null,"topics":["ansible","deployment","rails","rails-deployment"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/phawk.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-02T12:13:54.000Z","updated_at":"2023-07-06T10:06:38.000Z","dependencies_parsed_at":"2022-08-19T17:51:27.403Z","dependency_job_id":null,"html_url":"https://github.com/phawk/rails-deploy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phawk/rails-deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phawk%2Frails-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phawk%2Frails-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phawk%2Frails-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phawk%2Frails-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phawk","download_url":"https://codeload.github.com/phawk/rails-deploy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phawk%2Frails-deploy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268308961,"owners_count":24230161,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ansible","deployment","rails","rails-deployment"],"created_at":"2024-08-03T09:01:17.926Z","updated_at":"2025-08-01T22:41:48.622Z","avatar_url":"https://github.com/phawk.png","language":"Shell","readme":"# Rails deploy\n\nAnsible provisioning to setup a pre-configured Ruby/Rails server that contains the following:\n\n- Installs ruby via rbenv\n- Installs node.js for asset pipeline\n- Nginx + phusion passenger for serving your app\n- PostgreSQL + Redis databases\n- Setup some cron jobs to run rake tasks\n- Sets up ufw and fail2ban for basic security\n- Sets up swapon for when you run out of memory\n- Checkout the [changelog](CHANGELOG.md) for recent additions\n\n## Prerequisites\n\n- [Install ansible](http://docs.ansible.com/intro_installation.html) on your system\n- Setup a Ubuntu 14.04 VPS server. Try a [digital ocean](https://digitalocean.com) 1gb droplet (would recommend at least 1GB memory).\n- SSH into the server as root and ensure that is working from your local machine.\n\n## Usage\n\nFor each server you want to setup clone this repo. This allows you to keep the configuration around and deploy again at any time, or deploy multiple servers for some horizontal scailing (in this instance you will need a shared database server).\n\n```sh\n# Copy the example vars file over to vars/all.yml\n$ cp vars/example.yml vars/all.yml\n\n# Copy the example hosts file\n$ cp hosts.example hosts\n```\n\nEdit `./vars/all.yml` to meet your requirements. Replace the 127.0.0.1 IP address in `./hosts` with your servers IP\n\n```sh\n# Run the initial boostrap for your server (sets up deploy user etc)\n$ ansible-playbook -i hosts bootstrap.yml --user root --ask-pass\n\n# Install all the things\n$ ansible-playbook -i hosts rails_deploy.yml --user deploy\n```\n\n### Allow server to access source code\n\nFirst up you’ll need to allow your server access to wherever your source code is hosted, get the public SSH key generated on your serve by running a command like:\n\n```sh\n# Remember to substitue your servers IP (and the deploy username if you altered it)\n$ ssh deploy@127.0.0.1 -t cat /home/deploy/.ssh/id_rsa.pub\n```\n\nNext you’ll want to add this key to your ssh keys on github (or bitbucket or whatever git host you use)\n\n### Deploying your code\n\nThis is designed to work out of the box with capistrano for deploys. You’ll want to setup capistrano like so:\n\n#### Gemfile\n\nAdd the following gems to your Gemfile and run `bundle`.\n\n```ruby\ngem 'dotenv-rails', '~\u003e 1.0.2'\n\ngroup :development do\n  gem 'capistrano',  '~\u003e 3.1'\n  gem 'capistrano-rails', '~\u003e 1.1'\n  gem 'capistrano-rbenv', '~\u003e 2.0'\nend\n```\n\nOnce installed run `cap install` to create capistrano configuration files and then edit each file below.\n\n#### ./Capfile\n\nNext up make sure the following lines are uncommented from your `Capfile`.\n\n```ruby\nrequire 'capistrano/rbenv'\nrequire 'capistrano/bundler'\nrequire 'capistrano/rails/assets'\nrequire 'capistrano/rails/migrations'\n```\n\n#### ./config/deploy.rb\n\n```ruby\n# config valid only for Capistrano 3.1\nlock '3.2.1'\n\nset :application, 'APP_NAME'\nset :deploy_to, '/var/www/app' # Change this to match your deploy_dir in vars/app.yml\nset :repo_url, 'YOUR_GITHUB_URL'\nset :keep_releases, 3\nset :log_level, :info\nset :linked_files, %w{.env}\nset :migration_role, :app\nset :rbenv_type, :user\nset :rbenv_ruby, '2.1.5'\n\nnamespace :deploy do\n  desc 'Restart application'\n  task :restart do\n    on roles(:app), in: :sequence, wait: 3 do\n      execute :touch, release_path.join('tmp/restart.txt')\n    end\n  end\n\n  after :publishing, :restart\nend\n\nnamespace :rails do\n  desc 'Open the rails console on the primary remote server'\n  task :console do\n    on roles(:app), primary: true do |host|\n      command = \"cd #{deploy_to}/current \u0026\u0026 /home/#{host.user}/.rbenv/shims/bundle exec rails console #{fetch(:stage)}\"\n      exec \"ssh -l #{host.user} #{host.hostname} -p #{host.port || 22} -t 'cd #{deploy_to}/current \u0026\u0026 #{command}'\"\n    end\n  end\nend\n```\n\n#### ./config/deploy/production.rb\n\nReplace `127.0.0.1` with your servers IP address and update the user if you changed it from the defaults.\n\n```ruby\nserver '127.0.0.1', user: 'deploy', roles: %w{web app}\n```\n\n## TODO\n\n- SSL Support\n- Common exports like EDITOR and RAILS_ENV for running rake tasks etc\n","funding_links":[],"categories":["rails-deployment"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphawk%2Frails-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphawk%2Frails-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphawk%2Frails-deploy/lists"}