-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·67 lines (55 loc) · 1.49 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true
desc 'Run application console (pry)'
task :console do
sh 'pry -r ./init.rb'
end
USERNAME = 'taigo'
IMAGE = 'taigo-update_notifier'
VERSION = '0.1.0'
WORKER_APP = 'ruby application/update_notifier.rb'
desc 'Build Docker image'
task :worker do
sh WORKER_APP
end
# Docker tasks
namespace :docker do
desc 'Build Docker image'
task :build do
puts "\nBUILDING WORKER IMAGE"
sh "docker build --force-rm -t #{USERNAME}/#{IMAGE}:#{VERSION} ."
end
desc 'Run the local Docker container as a worker'
task :run do
env = ENV['WORKER_ENV']
puts "\nRUNNING WORKER WITH LOCAL CONTEXT"
puts " Running in #{env} mode"
sh 'docker run -e WORKER_ENV -v $(pwd)/config:/worker/config --rm -it ' \
"#{USERNAME}/#{IMAGE}:#{VERSION}"
end
desc 'Remove exited containers'
task :rm do
sh 'docker rm -v $(docker ps -a -q -f status=exited)'
end
desc 'List all containers, running and exited'
task :ps do
sh 'docker ps -a'
end
# desc 'Push Docker image to Docker Hub'
# task :push do
# puts "\nPUSHING IMAGE TO DOCKER HUB"
# sh "docker push #{USERNAME}/#{IMAGE}:#{VERSION}"
# end
end
# Heroku container registry tasks
namespace :heroku do
desc 'Build and Push Docker image to Heroku Container Registry'
task :push do
puts "\nBUILDING + PUSHING IMAGE TO HEROKU"
sh 'heroku container:push web'
end
desc 'Run worker on Heroku'
task :run do
puts "\nRUNNING CONTAINER ON HEROKU"
sh 'heroku run rake worker'
end
end