Skip to content

Instantly share code, notes, and snippets.

@gremax
Forked from the-teacher/vagrant.md
Created November 13, 2015 11:49
Show Gist options
  • Save gremax/5787c48f190411f668d0 to your computer and use it in GitHub Desktop.
Save gremax/5787c48f190411f668d0 to your computer and use it in GitHub Desktop.
Vagrant.startup

HOST MACHINE

  brew cask install virtualbox
  brew cask install vagrant
  brew cask install vagrant-manager
  vagrant plugin install vagrant-vbguest
  vagrant plugin install vagrant-librarian-chef-nochef
  git clone git@github.com:the_teacher/PROJECT
  cd PROJECT

Place config files:

  >> PROJECT/config/database.yml
  >> PROJECT/config/settings/development.local.yml
  >> PROJECT/DeployTool/settings/production.yml
  vagrant up
  vagrant ssh

VAGRANT MACHINE

  cd /vagrant
  bundle
  rake db:create && rake db:migrate
  ssh-keygen -t rsa -b 4096 -C "vagrant@open-cook.ru"
  >>
  >>
  >>

  ssh-add ~/.ssh/id_rsa && ssh-add -L

  cat ~/.ssh/id_rsa.pub | ssh deployer@server.com 'cat >> ~/.ssh/authorized_keys'
  >> password
  cd /vagrant/DeployTool/

  bundle

  mkdir -p ~/DUMPS

  cap production db:dump
  >> YES

  mysql -u root -pqwerty project_db_dev -S /run/mysql-vagrant/mysqld.sock < ~/DUMPS/project_production.XXX.mysql.sql

  cap production rsync:files
  >> YES

PROXY ASSETS VIA NGINX

  sudo apt-get install nginx
  sudo nano /etc/nginx/nginx.conf
  ##
  # Logging Settings
  ##

  # access_log /var/log/nginx/access.log;
  # error_log /var/log/nginx/error.log;
  # include /etc/nginx/conf.d/*.conf;
  # include /etc/nginx/sites-enabled/*;
  include /vagrant/config/nginx.development.conf;
  sudo /etc/init.d/nginx restart
  sudo service nginx restart
  nginx -t
  cd /vagrant

  |=> rails s -b 0.0.0.0
  -- or --
  |=> unicorn_rails -c ./config/unicorn.development.rb
  -- or --
  |=> ( sudo /etc/init.d/nginx restart ) && ( unicorn_rails -c ./config/unicorn.development.rb )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment