railman-deployment 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 035e656bf5a0be352ace26a8a8dad91753ac9ce6
4
- data.tar.gz: 2f2c3bfdd1c04c904a7270b28fc9448d14dff018
3
+ metadata.gz: 2e790b837727c32396377be2a1a794438861082e
4
+ data.tar.gz: 768754b7d663ad8f76c79d7fcf168992ce70a119
5
5
  SHA512:
6
- metadata.gz: b9c013a597e44e4e0735e78914470c8faac4d924f43ca94e9f226f11b26d66e1b535c64a50672776a2497a2ef96cd606440ca83c095562a87de58f1e6e0e7f74
7
- data.tar.gz: 96d3ba1cb98a340d5cce42deb3e7fcbbbe026ff4153c166aad348c63fd841a899e2d23e2b975cc6f78aaf85f315d1fb5250a044d4fc32eaf3a86c9918b303d46
6
+ metadata.gz: d8a7e04c95f41cc4c8388240312ba91ac438799818a171efe4089a09ada8b27a19d6546ca5e724202ff96c6586de6cbb67805eba53c43b810937de8da0842698
7
+ data.tar.gz: f8fd75cf235f8ceb66b66eb99f5b89adbdfe409f5a4fba75aa9f1ff20f041fd248fcd513e482ee5b829178ffd8575824be25197782d31c2544a02a7df7f58158
@@ -1,3 +1,3 @@
1
1
  module RailmanDeployment
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -2,6 +2,7 @@ desc 'Setup rails application for the first time on a server'
2
2
  task :setup do
3
3
  on roles(:all) do
4
4
  with fetch(:environment) do
5
+ # setup backend application
5
6
  if test "[ -d #{fetch(:deploy_to)} ]"
6
7
  invoke :fetch_and_reset_git_repository
7
8
  else
@@ -32,6 +33,33 @@ task :setup do
32
33
  end
33
34
  end
34
35
 
36
+ desc 'Setup spa application for the first time on a server'
37
+ task :setup_spa do
38
+ on roles(:all) do
39
+ with fetch(:environment) do
40
+ server_conf_dir = "#{fetch(:deploy_to)}/config/server"
41
+ if fetch(:spa_application)
42
+ if test "[ -d #{fetch(:deploy_spa_to)} ]"
43
+ invoke :fetch_and_reset_spa_git_repository
44
+ else
45
+ execute :git, :clone, fetch(:spa_repo_url), fetch(:deploy_spa_to)
46
+ end
47
+
48
+ within fetch(:deploy_spa_to) do
49
+ execute :mkdir, "-p #{fetch(:deploy_spa_to)}/public"
50
+ execute :yarn
51
+ execute :yarn, 'run build'
52
+ execute "rsync -avz --delete ./#{fetch(:deploy_spa_to)}/dist/ ./#{fetch(:deploy_spa_to)}/public/"
53
+ execute :cp, "#{server_conf_dir}/nginx_spa.conf /etc/nginx/sites-available/#{fetch(:spa_domain)}"
54
+ execute :ln, "-s -f /etc/nginx/sites-available/#{fetch(:spa_domain)} /etc/nginx/sites-enabled/"
55
+ execute :service, 'nginx restart'
56
+ execute :certbot, "--nginx -d #{fetch(:spa_domain)}"
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
35
63
  desc 'Remove the application completely from the server'
36
64
  task :remove do
37
65
  on roles(:all) do
@@ -45,12 +73,17 @@ task :remove do
45
73
  execute :su_rm, "-f /etc/nginx/sites-enabled/#{fetch(:domain)}"
46
74
  execute :su_rm, "-f /etc/nginx/sites-available/#{fetch(:domain)}"
47
75
  execute :su_rm, "-f /etc/logrotate.d/#{fetch(:application)}"
76
+ if test "[ -d #{fetch(:deploy_spa_to)} ]"
77
+ execute :su_rm, "-rf #{fetch(:deploy_spa_to)}"
78
+ execute :su_rm, "-f /etc/nginx/sites-enabled/#{fetch(:spa_domain)}"
79
+ execute :su_rm, "-f /etc/nginx/sites-available/#{fetch(:spa_domain)}"
80
+ end
48
81
  execute :service, 'nginx restart'
49
82
  end
50
83
  end
51
84
  end
52
85
 
53
- desc 'Deploy rails application'
86
+ desc 'Deploy rails application (and spa if configured)'
54
87
  task :deploy do
55
88
  on roles(:all) do
56
89
  with fetch(:environment) do
@@ -62,6 +95,22 @@ task :deploy do
62
95
  execute :eye, :restart, fetch(:application)
63
96
  execute :service, 'nginx restart'
64
97
  end
98
+ invoke :deploy_spa
99
+ end
100
+ end
101
+ end
102
+
103
+ desc 'Deploy SPA application'
104
+ task :deploy_spa do
105
+ on roles(:all) do
106
+ with fetch(:environment) do
107
+ within fetch(:deploy_spa_to) do
108
+ invoke :fetch_and_reset_spa_git_repository
109
+ execute :yarn
110
+ execute :yarn, 'run build'
111
+ execute "rsync -avz --delete ./#{fetch(:deploy_spa_to)}/dist/ ./#{fetch(:deploy_spa_to)}/public/"
112
+ execute :service, 'nginx restart'
113
+ end if test "[ -d #{fetch(:deploy_spa_to)} ]"
65
114
  end
66
115
  end
67
116
  end
@@ -80,13 +129,6 @@ task :update do
80
129
  end
81
130
  end
82
131
 
83
- if fetch(:spa_application)
84
- desc 'Deploy vue.js SPA'
85
- task :deploy_spa do
86
- warn 'TODO: deploy spa'
87
- end
88
- end
89
-
90
132
  desc "Recreate server database from db/#{fetch(:application)}.sql and sync local dirs if any"
91
133
  task :reset_server do
92
134
  on roles(:all) do
@@ -137,6 +179,17 @@ task :fetch_and_reset_git_repository do
137
179
  end
138
180
  end
139
181
 
182
+ task :fetch_and_reset_spa_git_repository do
183
+ on roles(:all) do
184
+ with fetch(:environment) do
185
+ within fetch(:deploy_spa_to) do
186
+ execute :git, :fetch, 'origin'
187
+ execute :git, :reset, "--hard origin/#{fetch(:spa_deploy_branch, 'master')}"
188
+ end
189
+ end
190
+ end
191
+ end
192
+
140
193
  task :create_database_from_sql_file do
141
194
  on roles(:all) do
142
195
  with fetch(:environment) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railman-deployment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Jancev