forked from openSUSE/open-build-service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
123 lines (117 loc) · 4.73 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
CONTAINER_USERID = %x(id -u).freeze
VERSION = '42.3'.freeze
namespace :docker do
desc 'Build our development environment'
task :build do
begin
# Setup the git commit message template
sh 'git config commit.template .gitmessage'
sh 'touch docker-files/home/.bash_history docker-files/home/.irb_history docker-files/home/.pry_history'
sh "cat << EOF > docker-compose.override.yml
# This file is generated by our Rakefile. Do not change it!
version: '2.1'
services:
frontend:
build:
args:
CONTAINER_USERID: #{CONTAINER_USERID}
volumes:
- .:/obs
- ./docker-files/home/.bash_history:/home/frontend/.bash_history
- ./docker-files/home/.irb_history:/home/frontend/.irb_history
- ./docker-files/home/.pry_history:/home/frontend/.pry_history
- ./docker-files/home/.irbrc:/home/frontend/.irbrc
- ./docker-files/home/.pryrc:/home/frontend/.pryrc
EOF"
# Build the frontend container and pull newer version of the image if available
sh 'docker-compose build --pull frontend'
# Build the minitest container on top of that
sh 'docker-compose -f docker-compose.yml -f docker-compose.minitest.yml build minitest'
# Bootstrap the app
sh 'docker-compose up -d db'
sh 'docker-compose run --no-deps --rm frontend bundle exec rake dev:bootstrap RAILS_ENV=development'
ensure
sh 'docker-compose stop'
end
end
namespace :maintainer do
def tags_for(container_type)
"-t openbuildservice/#{container_type}:#{VERSION} -t openbuildservice/#{container_type}"
end
desc 'Rebuild all our static containers'
multitask rebuild: ['rebuild:all'] do
end
namespace :rebuild do
multitask all: [:base, :backend, 'frontend-base', :mariadb, :memcached] do
end
task :base do
sh "docker build docker-files/base/ #{tags_for(:base)} -f docker-files/base/Dockerfile.#{VERSION}"
end
task mariadb: [:base] do
sh "docker build docker-files/mariadb/ #{tags_for(:mariadb)} -f docker-files/mariadb/Dockerfile.mariadb"
end
task memcached: [:base] do
sh "docker build docker-files/memcached/ #{tags_for(:memcached)} -f docker-files/memcached/Dockerfile.memcached"
end
task 'frontend-base' => [:base] do
sh "docker build src/api/ #{tags_for('frontend-base')} -f src/api/docker-files/Dockerfile.frontend-base"
end
task 'frontend-backend' => [:base] do
sh "docker build src/api/ #{tags_for('frontend-backend')} -f src/api/docker-files/Dockerfile.frontend-backend"
end
task backend: [:base] do
sh "docker build src/backend/ #{tags_for(:backend)} -f src/backend/docker-files/Dockerfile.backend"
end
end
desc 'Rebuild and publish all our static containers'
task publish: [:rebuild, 'publish:all'] do
end
namespace :publish do
multitask all: [:base, :mariadb, :memcached, :backend, 'frontend-base'] do
end
task :base do
sh "docker push openbuildservice/base:#{VERSION}"
sh 'docker push openbuildservice/base'
end
task :mariadb do
sh "docker push openbuildservice/mariadb:#{VERSION}"
sh 'docker push openbuildservice/mariadb'
end
task :memcached do
sh "docker push openbuildservice/memcached:#{VERSION}"
sh 'docker push openbuildservice/memcached'
end
task :backend do
sh "docker push openbuildservice/backend:#{VERSION}"
sh 'docker push openbuildservice/backend'
end
task 'frontend-base' do
sh "docker push openbuildservice/frontend-base:#{VERSION}"
sh 'docker push openbuildservice/frontend-base'
end
end
end
namespace :ahm do
desc 'Prepare the application health monitoring containers'
task :prepare do
begin
sh 'docker-compose -f docker-compose.ahm.yml -f docker-compose.yml up -d rabbit'
sh 'wget http://localhost:15672/cli/rabbitmqadmin -O contrib/rabbitmqadmin'
sh 'chmod +x contrib/rabbitmqadmin'
sh './contrib/rabbitmqadmin declare exchange name=pubsub type=topic durable=true auto_delete=false internal=false'
# configure the app
sh 'docker-compose -f docker-compose.ahm.yml -f docker-compose.yml up -d db'
sh 'docker-compose -f docker-compose.ahm.yml -f docker-compose.yml run --no-deps --rm frontend bundle exec rake dev:ahm:configure'
ensure
sh 'docker-compose -f docker-compose.ahm.yml -f docker-compose.yml stop'
end
end
end
end
def environment_vars(with_coverage = true)
environment = []
environment.concat(['-e', 'DO_COVERAGE=1']) if with_coverage && ENV['CIRCLECI']
environment.concat(['-e', 'EAGER_LOAD=1'])
environment.concat(['-e', "TEST_SUITE='#{ENV['TEST_SUITE']}'"])
environment
end