hak 0.4.3 → 0.4.4
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 +4 -4
- data/bin/hak +79 -6
- data/lib/hak/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8f9ecb7498303641f93e19e511c4fb5b9f3f4446
|
|
4
|
+
data.tar.gz: 093934177e9841cd16981e999250b4cd9710b279
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c72719204fc61e693967a6a46ae2f872c89dcc7981be58320dc3b800b85eaeebe84194799fc62d899b9271000212819708da05bbcd4bcf620db103381e0bc2f
|
|
7
|
+
data.tar.gz: 67279990432f049116bc2a5f22a0b6a6609da8b69649c4ac3ac5941b14d46e5c4d1ddccb5ebae134193aecbfffa3bcbc98689a33fd45ec16cdecd34bd14e0920
|
data/bin/hak
CHANGED
|
@@ -6,7 +6,7 @@ require 'yaml'
|
|
|
6
6
|
require 'colorize'
|
|
7
7
|
|
|
8
8
|
program :name, 'hak'
|
|
9
|
-
program :version, '0.4.
|
|
9
|
+
program :version, '0.4.4'
|
|
10
10
|
program :description, 'Hak - start hacking!'
|
|
11
11
|
|
|
12
12
|
default_command :help
|
|
@@ -159,11 +159,7 @@ command :create do |c|
|
|
|
159
159
|
repo = args[1]
|
|
160
160
|
end
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
#if !Dir.exists?(File.expand_path("~/.hak/" + repo))
|
|
164
|
-
#puts "#{repo} not exists, pulling"
|
|
165
|
-
system "hak pull #{repo}"
|
|
166
|
-
#end
|
|
162
|
+
system "hak pull #{repo}"
|
|
167
163
|
|
|
168
164
|
# copies the package from local ~/.hak/[repo] to local folder
|
|
169
165
|
puts "copying ~/.hak/#{repo} to ./#{folder}"
|
|
@@ -297,6 +293,83 @@ command :upgrade do |c|
|
|
|
297
293
|
end
|
|
298
294
|
end
|
|
299
295
|
|
|
296
|
+
command :deploy do |c|
|
|
297
|
+
c.syntax = 'hak deploy jae@someserver.com'
|
|
298
|
+
c.summary = 'deploys current site'
|
|
299
|
+
c.description = ''
|
|
300
|
+
c.example 'description', 'hak deploy jae@someserver.com'
|
|
301
|
+
c.action do |args, options|
|
|
302
|
+
|
|
303
|
+
dest = args[0]
|
|
304
|
+
dest_docker_installed = true
|
|
305
|
+
|
|
306
|
+
if args.empty?
|
|
307
|
+
puts "ex: hak deploy jae@someserver.com".yellow
|
|
308
|
+
else
|
|
309
|
+
|
|
310
|
+
# get app name, make sure hak deploy is run from root of your app
|
|
311
|
+
pwd = `pwd`
|
|
312
|
+
dirs = pwd.split("/")
|
|
313
|
+
app = dirs[dirs.length - 1].strip
|
|
314
|
+
|
|
315
|
+
# check if docker-compose-production.yml is there
|
|
316
|
+
res = `ls -l |grep docker-compose-production.yml`
|
|
317
|
+
if res == ""
|
|
318
|
+
puts "docker-compose-production file not exists".red
|
|
319
|
+
puts "copying docker-compose.yml to docker-compose-production.yml".green
|
|
320
|
+
domain = ask "what domain do you want to use? ex) myawesomesite.com".light_blue
|
|
321
|
+
puts "#{domain} set in docker-compose-production.yml"
|
|
322
|
+
system "cp docker-compose.yml docker-compose-production.yml"
|
|
323
|
+
|
|
324
|
+
# rename virtual host to new domain name
|
|
325
|
+
file_path = "docker-compose-production.yml"
|
|
326
|
+
file = File.open(file_path, "r+")
|
|
327
|
+
content = file.read
|
|
328
|
+
host = domain
|
|
329
|
+
new_content = content.gsub(/VIRTUAL_HOST=(.*?)\n/, "VIRTUAL_HOST=#{host}\n")
|
|
330
|
+
File.write(file_path, new_content)
|
|
331
|
+
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# check if docker is installed
|
|
335
|
+
res = `ssh #{dest} which docker`
|
|
336
|
+
if res == ""
|
|
337
|
+
dest_docker_installed = false
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# check if docker-compose is installed
|
|
341
|
+
res = `ssh #{dest} which docker-compose`
|
|
342
|
+
if res == ""
|
|
343
|
+
dest_docker_installed = false
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# if docker and/or docker-compose is not installed in dest server, install it
|
|
347
|
+
if dest_docker_installed == false
|
|
348
|
+
res = `ssh #{dest} curl -s https://gist.githubusercontent.com/jaequery/d61ce5371068bc4b386e80b120e8f217/raw/6f14fb1a373335606e86e76627a2debfb8737ab3/install_latest_docker_compose.sh | bash /dev/stdin`
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# if jwilder/nginx-proxy is not running, run it
|
|
352
|
+
res = `ssh #{dest} docker ps |grep jwilder/nginx-proxy`
|
|
353
|
+
if res == ""
|
|
354
|
+
res = `ssh #{dest} "docker run -d --restart=always -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --name=proxy jwilder/nginx-proxy"`
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# deploy to dest
|
|
358
|
+
#res = `rsync -avzr ../#{app} #{dest}:~/sites/`
|
|
359
|
+
#res = `ssh #{dest} \"cd ~/sites/#{app} && docker-compose stop && docker-compose up && docker-compose logs -f\"`
|
|
360
|
+
puts "rsyncing files ... ".yellow
|
|
361
|
+
res = `rsync -avzr ../#{app} #{dest}:~/sites/`
|
|
362
|
+
puts "files rsynced".green
|
|
363
|
+
|
|
364
|
+
puts "running docker-compose -f docker-compose-production.yml up".yellow
|
|
365
|
+
res = `ssh #{dest} "cd ~/sites/#{app} && docker-compose stop && docker-compose -f docker-compose-production.yml up && docker-compose logs"`
|
|
366
|
+
puts "all up".green
|
|
367
|
+
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
300
373
|
|
|
301
374
|
def run(command, hide=false)
|
|
302
375
|
exec = "eval $(dinghy env) && #{command}"
|
data/lib/hak/version.rb
CHANGED