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
Written by Janez Troha
Related protips
3 Responses
coool!!!
over 1 year ago
·
simply awesome!
over 1 year ago
·
does it sync to bitbucket/github remote branch? thanks
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Capistrano
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#