d47738bc by Jeff Balicki

rrr

1 parent ade29bcf
1 set :application, 'fp-canada' 1 set :application, 'fp-canada'
2 set :repo_url, 'git@git.gotenzing.com:jeffmbalicki/FP_Canada.git' 2 set :repo_url, 'git@git.gotenzing.com:jeffmbalicki/FP_Canada.git'
3 3
4
4 # Branch options 5 # Branch options
5 # Prompts for the branch name (defaults to current branch) 6 # Prompts for the branch name (defaults to current branch)
6 #ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp } 7 #ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }
7 8
8 # Hardcodes branch to always be master 9 # Hardcodes branch to always be master
9 # This could be overridden in a stage config file 10 # This could be overridden in a stage config file
10 set :branch, "master" 11 set :branch, :master
11 12 SSHKit.config.command_map[:composer] = "/usr/bin/php72 /home/tenzing_www/composer.phar"
12 13
13 set :keep_releases, 2 14 set :keep_releases, 2
14 set :deploy_to, -> { "/var/www/html/production/#{fetch(:application)}" } 15 set :deploy_to, -> { "/var/www/html/production/#{fetch(:application)}" }
...@@ -17,13 +18,24 @@ set :deploy_to, -> { "/var/www/html/production/#{fetch(:application)}" } ...@@ -17,13 +18,24 @@ set :deploy_to, -> { "/var/www/html/production/#{fetch(:application)}" }
17 set :log_level, :info 18 set :log_level, :info
18 19
19 # Put all shared files/directories here (e.g. uploads that need to go on the NFS drive) 20 # Put all shared files/directories here (e.g. uploads that need to go on the NFS drive)
20 set :linked_files, fetch(:linked_files, []).push('.env') 21 set :linked_files, fetch(:linked_files, []).push('.env', 'wordfence-waf.php', 'wp-content/wp-cache-config.php')
21 set :linked_dirs, fetch(:linked_dirs, []).push('wp-content/wflogs','wp-content/uploads', 'wp-content/storage', 'wp-content/cache') 22 set :linked_dirs, fetch(:linked_dirs, []).push('wp-content/wflogs','wp-content/uploads', 'wp-content/storage', 'wp-content/languages', 'wp-content/cache' , 'wp-content/wp-rocket-config')
23
24 namespace :deploy do
25 desc 'Restart application'
26 task :restart do
27 on roles(:app), in: :sequence, wait: 5 do
28 # Your restart mechanism here, for example:
29 # execute :service, :nginx, :reload
30 end
31 end
32 end
22 33
23 namespace :deploy do 34 namespace :deploy do
24 desc 'Sync servers' 35 desc 'Sync servers'
25 task :sync do 36 task :sync do
26 on roles(:web), in: :sequence, wait: 5 do 37 on roles(:web), in: :sequence, wait: 5 do
38 execute "cd '#{release_path}/'; rm -Rf .git/ "
27 execute("si #{fetch(:application)}") 39 execute("si #{fetch(:application)}")
28 end 40 end
29 end 41 end
...@@ -38,20 +50,30 @@ namespace :deploy do ...@@ -38,20 +50,30 @@ namespace :deploy do
38 end 50 end
39 end 51 end
40 52
53
41 namespace :deploy do 54 namespace :deploy do
42 desc 'Install composer packages' 55 desc 'Install composer packages in understrap-child theme'
43 task :install_theme_packages do 56 task :install_theme_packages do
44 on roles(:web), in: :sequence, wait: 5 do 57 on roles(:web), in: :sequence, wait: 5 do
45 execute "cd '#{release_path}'; /usr/bin/php73 /home/tenzing_www/bin/composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader" 58 execute "cd '#{release_path}/wp-content/themes/understrap-child'; /usr/bin/php73 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader"
46 end 59 end
47 end 60 end
48 end 61 end
49 62
50 namespace :deploy do 63 namespace :deploy do
51 desc 'Install composer packages' 64 desc 'Install composer packages in root'
52 task :install_theme_packages do 65 task :install_packages do
53 on roles(:web), in: :sequence, wait: 5 do 66 on roles(:web), in: :sequence, wait: 5 do
54 execute "cd '#{release_path}/wp-content/themes/understrap-child'; /usr/bin/php73 /home/tenzing_www/bin/composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader" 67 execute "cd '#{release_path}'; /usr/bin/php73 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader"
68 end
69 end
70 end
71
72 namespace :deploy do
73 desc 'set file permissions'
74 task :set_permissions do
75 on roles(:web), in: :sequence, wait: 5 do
76 execute "cd '#{release_path}/'; chmod 777 .htaccess .user.ini wordfence-waf.php"
55 end 77 end
56 end 78 end
57 end 79 end
...@@ -59,56 +81,12 @@ end ...@@ -59,56 +81,12 @@ end
59 81
60 82
61 83
62 # Override `git#create_release` to handle submodules
63 # namespace :git do
64 # desc 'Copy repo to releases'
65 # task create_release: :'git:update' do
66 # on roles(:all) do
67 # with fetch(:git_environmental_variables) do
68 # within repo_path do
69 # execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
70 # end
71 # end
72 # end
73 # end
74 # end
75 84
76 # The above restart task is not run by default 85 # The above restart task is not run by default
77 # Uncomment the following line to run it on deploys if needed 86 # Uncomment the following line to run it on deploys if needed
78 # after 'deploy:publishing', 'deploy:restart' 87 # after 'deploy:publishing', 'deploy:restart'
79 88
80 namespace :deploy do 89
81 desc 'Remove Git Files'
82 task :cleanup do
83 on roles(:web), in: :sequence, wait: 5 do
84 execute "cd '#{release_path}/'; rm -Rf .git/ "
85 end
86 end
87 end
88
89
90
91
92 # namespace :deploy do
93 # desc 'Update WordPress template root paths to point to the new release'
94 # task :update_option_paths do
95 # on roles(:app) do
96 # within fetch(:release_path) do
97 # if test :wp, :core, 'is-installed'
98 # [:stylesheet_root, :template_root].each do |option|
99 # # Only change the value if it's an absolute path
100 # # i.e. The relative path "/themes" must remain unchanged
101 # # Also, the option might not be set, in which case we leave it like that
102 # value = capture :wp, :option, :get, option, raise_on_non_zero_exit: false
103 # if value != '' && value != '/themes'
104 # execute :wp, :option, :set, option, fetch(:release_path).join('web/wp/wp-content/themes')
105 # end
106 # end
107 # end
108 # end
109 # end
110 # end
111 # end
112 90
113 91
114 92
...@@ -116,7 +94,8 @@ end ...@@ -116,7 +94,8 @@ end
116 # Note that you need to have WP-CLI installed on your server 94 # Note that you need to have WP-CLI installed on your server
117 # Uncomment the following line to run it on deploys if needed 95 # Uncomment the following line to run it on deploys if needed
118 # after 'deploy:publishing', 'deploy:update_option_paths' 96 # after 'deploy:publishing', 'deploy:update_option_paths'
119 97 after 'deploy:updated', 'deploy:install_packages'
120 after 'deploy:updated', 'deploy:install_theme_packages' 98 after 'deploy:updated', 'deploy:install_theme_packages'
121 after 'deploy:updated', 'deploy:sync' 99 after 'deploy:updated', 'deploy:sync'
100 after 'deploy:updated', 'deploy:set_permissions'
122 after 'deploy:finished', 'deploy:sync_again' 101 after 'deploy:finished', 'deploy:sync_again'
......