These are the steps necessary when you are deploying from a new Debian/Ubuntu based server.
- Git
- Curl
- Nginx
- RVM
- Postgres
To update and then install Curl, Git, Nginx and Postgres:
sudo apt-get update && sudo apt-get install curl git-core nginx postgresql postgresql-contrib libpq-dev -y
You'll need to create the database user that is used by the Flosscoach application:
sudo -u postgres createuser -s floss
After that set the user password.
sudo -u postgres psql
\password floss
Keep in mind that the same user and password need to be present on the
config/database.yml
file
Type \q
to exit postgres
Import the RVM GPG key:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Install RVM to manage Ruby Versions:
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
Install Ruby 2.4.0
using RVM:
rvm install 2.4.0
rvm use 2.4.0 --default
To install Rails
and Bundler
gems do:
gem install rails -v '5.0.0' -V --no-ri --no-rdoc
gem install bundler -V --no-ri --no-rdoc
Mina
it's a gem that handles deployment by cloning the repository and doing the tasks necessary to set up the application.
If not already present, add Mina
and Puma
to Gemfile:
group :development do
gem 'mina', require: false
gem 'mina-puma', require: false
gem 'mina-nginx', require: false
end
gem 'puma'
Update changes to the Gemfile
bundle
Install Mina
gem on your local machine(only needed on the local machine):
gem install mina
If it's a new project you're adding Mina
support, create config files:
touch config/deploy.rb
Initialize the deploy process on your local machine.
bundle exec mina deploy
Nginx is configured by mina config/deploy.rb
file. Below are some the constants you need to set to configure properly:
set :nginx_socket_path, '/home/flosscoach/app/shared/tmp/sockets/puma.sock'
set :current_path, '/home/flosscoach/app/current'
set :domain, 'flosscoach.com'
Restart Nginx service:
sudo service nginx restart
- Be able to SSH into the server
- Mina gem (on local machine)
In order to deploy changes from local machine to the server you need to be allowed to ssh to the DigitalOcean droplet.
To deploy simply execute the following command:
bundle exec mina deploy
To deploy another branch you need to change the config/deploy.rb
file in order to specify the desired brach. Below is the constant you need to change:
set :branch, 'name_of_the_branch'
After that you just need to run the following command:
bundle exec mina deploy
Gemfile.lock
should be outside.gitignore
file