m5kpuq
Last Updated: February 25, 2016
·
8.449K
· dz0ny
842dac7e3ee429930f6b9de12837fe60

capistrano + ftp only hosting provider

The story

You get client, he buys cheap hosting with FTP only. Now in modern times we all use git, VM, some CI and Capistrano to ease work. Oh and FTP?

The solution

Cli ftp client LFTP, hard to understand, but overall great tool. Bellow is my Cap file for such hosts.

config/deploy.rb

#APP
set :application, "GreatWebsite"
set :app_path, "./worpdress/"
set :scm, :none

#FTP
set :login, "great_website"
set :password, "changeme"
set :ftp_host, "www.great_website.squarebox.eu"
set :deploy_to, "/domains/www.great_website.si/public/"

Capfile

load 'config/deploy'

desc "FTP Sync && Mount"
namespace :deploy do

  desc "Sync remote by default"
  task :default do
    remote.default
  end

  namespace :remote do
      desc "Mount remote to local #{application}"
      task :mount do
          `mkdir ./mnt/#{application} -p`
          `curlftpfs ftp://#{login}:#{password}@#{url} ./mnt/#{application}`
      end

      desc "Unmount #{application}"
      task :umount do
          `fusermount -u ./mnt/#{application}`
      end

      desc "Sync to remote server using lftp"
      task :sync do
          `lftp -c "set ftp:list-options -a; open ftp://#{login}:#{password}@#{ftp_host}; lcd #{app_path}; cd #{deploy_to}; mirror --reverse --delete --use-cache --verbose --allow-chown --allow-suid --no-umask --parallel=2 --exclude-glob .git --exclude-glob *.log"`

      end

      desc "Sync app to remote server"
      task :default do
          self.sync
      end
  end

end
Say Thanks
Respond

3 Responses
Add your response

12446
Caa8460e6e3965d920f1a048eb7c1456

coool!!!

over 1 year ago ·
15562
D82cb6c273de08920e8afcc45653f69a

simply awesome!

over 1 year ago ·
16710
3237026b96d1245f70851bdca6070821

does it sync to bitbucket/github remote branch? thanks

over 1 year ago ·