_____________ ______ ______ _____ ______
___ __/__ /_____ __________ /_ ___ /____(_)________ /__
__ /_ __ /_ __ `/_ ___/_ __ \ __ //_/_ /_ ___/_ //_/
_ __/ _ / / /_/ /_(__ )_ / / / _ ,< _ / / /__ _ ,<
/_/ /_/ \__,_/ /____/ /_/ /_/ /_/|_| /_/ \___/ /_/|_|
Flash kick = Ansible + Mina + Nginx + Puma
This gem is a fork of Ahoy
- Ansible scripts to provision your server with Nginx, Ruby, PostgreSQL, and recommended security settings (ssh hardening, firewall, fail2ban, etc.)
- Mina scripts to deploy your Rails application
- Puma application server configuration files
- An .env directory that will use YAML to store your environment variables securely
RECOMMENDATION: You might want to first try this using a fresh Rails application so you can see how it effects your files before running this in your existing code base. Add this line to your application's Gemfile:
Add the gem to your Gemfile and bundle
gem 'flash_kick'
$ bundle install
Execute the following terminal command to launch flash_kick's interactive guide
$ rails g flash_kick:init
Continue to next step AFTER you complete the interactive guide
If you don't have a production secret_key_base, generate one using:
$ rake secret
This will produce something that looks like:
$ f67395912d0ddd0de80a734822e73b327d007809123...
Now just copy and paste it into the following file:
$ <YOUR RAILS APP>/.env/production_env.yml
IMPORTANT: At this point make sure to commit your changes and push them up to your repo!
IMPORTANT: For this step, you will need a freshly installed Ubuntu box with root ssh privileges. If you're not sure how to do this, contact your web hosting administrator.
From the root of your Rails application...
$ cd config/ansible && ./provision.sh production
Executing provision.sh <RAILS ENVIRONMENT FOR DEPLOYED APP>
will launch the provisioning process and setup your box so it can run Rails using Nginx as the web server, Puma as your application server, and PostgreSQL as your database.
NOTE: This process may take a while (15 mins or so), so sit back and relax.
Once the provisioning process is complete, log into your box with the server user (ex: deployer)
$ ssh deployer@<YOUR SERVER IP>
Once in, get your server user's public key
$ cat ~/.ssh/id_rsa.pub
This will print out something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOv2hw90hySH+41A6NVjp6GXhBS/PUVmTot...
Copy the public key and paste it into your git repo Github, Bitbucket settings to allow SSH access.
Go back to the ***root of your Rails application and execute the following command:
$ mina production setup
Then...
$ mina production deploy
If everything worked as it should have, your Rails application should be up and running on the Web. Enjoy!
- Fork it ( https://github.com/heliohead/flash_kick/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Bug reports and pull requests are welcome on GitHub at https://github.com/heliohead/flash_kick. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available under the terms of the wtfpl.