Last active
March 29, 2017 15:12
-
-
Save piotr-galas/e4433d031a0d185b2d27cd5ff9a1d3f0 to your computer and use it in GitHub Desktop.
It shows steps to configure deploy with capistrano on almost empty server (OVH) ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add key to authorized keys: | |
1. create file `.ssh/authorized_keys` on server, then on local machine: | |
`cat ~/.ssh/id_rsa.pub | ssh [email protected] -p 5555 'cat >> .ssh/authorized_keys'` | |
2. Check if it possible to login without password | |
# base capistrano config | |
gem 'capistrano', '~> 3.8' | |
gem 'capistrano-rvm', '~> 0.1.2' | |
gem 'capistrano-rails', '~> 1.1.7' | |
gem 'capistrano3-puma', '~> 1.2.1' | |
gem 'capistrano-bundler', '~> 1.1.4' | |
Capfile | |
require 'capistrano/rvm' | |
require 'capistrano/bundler' | |
require 'capistrano/puma' | |
require 'capistrano/rails/assets' | |
require 'capistrano/rails/migrations' | |
# Add default capistrano config to `config/deploy/production.rb` | |
server '217.182.168.55', port: 5001, user: 'piotr', roles: %w(web app db) | |
set :rails_env, :production | |
set :default_shell, '/bin/bash --login' | |
set :deploy_to, '/home/babymeal/api' | |
set :keep_releases, 5 | |
set :puma_rackup, -> { File.join(current_path, 'config.ru') } | |
set :puma_state, "#{shared_path}/tmp/pids/puma.state" | |
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" | |
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" # accept array for multi-bind | |
set :puma_conf, "#{shared_path}/puma.rb" | |
set :puma_access_log, "#{shared_path}/log/puma_error.log" | |
set :puma_error_log, "#{shared_path}/log/puma_access.log" | |
set :puma_role, :app | |
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production')) | |
set :puma_worker_timeout, nil | |
set :puma_init_active_record, true | |
set :puma_preload_app, false | |
set :rvm_ruby_version, '2.4.0' | |
set :assets_roles, [:web, :app] | |
and to `config/deploy.rb` | |
# config valid only for current version of Capistrano | |
lock '3.8.0' | |
set :application, 'babymeal' | |
set :repo_url, 'ssh://[email protected]/piotr_galas/my_cool_repo.git' | |
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp | |
set :scm, :git | |
set :format, :pretty | |
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml', 'config/application.yml') | |
set :linked_dirs, fetch(:linked_dirs, []).push('log', | |
'tmp/pids', | |
'tmp/cache', | |
'tmp/sockets', | |
'vendor/bundle', | |
'public/uploads') | |
# Fix error occured | |
a)/home/user/.rvm/bin/rvm: No such file or directory -> Install rvm: | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
\curl -sSL https://get.rvm.io | bash -s stable | |
source /home/piotr/.rvm/scripts/rvm | |
b) Ruby ruby-2.4.0 is not installed. | |
rvm install ruby-2.4.0 | |
c) /home/piotr/babymeal/api/shared/config/database.yml does not exist on xxxx | |
add database.yml and secrets.yml application.yml to config | |
d) /home/piotr/.rvm/scripts/set: line 19: exec: bundle: not found | |
gem install bundle | |
e) mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' - install mysql on server | |
sudo su | |
apt-get -y install mariadb-server mariadb-client | |
apt-get install libmysqlclient-dev | |
mysql_secure_instalation | |
sudo mysql -u root | |
'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket'; | |
FLUSH PRIVILEGES; | |
f) Bundler::GemRequireError: There was an error while trying to load the gem 'coffee-rails', Could not find a JavaScript runtime | |
sudo apt-get install nodejs | |
g) Unknown database 'babymeal_prod' | |
Create database in mysql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment