@@ -18,71 +18,34 @@ rpm_platforms = ENV['RPM_PLATFORMS'] || 'el-7,el-8,el-9,el-10,sles-15,amazon-202
1818@debs = deb_platforms . split ( ',' ) . map { |p | "base-#{ p . split ( '-' ) . join } -i386.cow" } . join ( ' ' )
1919@rpms = rpm_platforms . split ( ',' ) . map { |p | "pl-#{ p } -x86_64" } . join ( ' ' )
2020
21- def image_exists
22- !`docker images -q #{ @image } ` . strip . empty?
23- end
24-
25- def container_exists
26- !`docker container ls --all --filter 'name=#{ @container } ' --format json` . strip . empty?
27- end
28-
29- def teardown
30- if container_exists
31- puts "Stopping #{ @container } "
32- run_command ( "docker stop #{ @container } " , silent : false , print_command : true )
33- run_command ( "docker rm #{ @container } " , silent : false , print_command : true )
34- end
35- end
36-
37- def start_container ( ezbake_dir )
38- run_command ( "docker run -d --name #{ @container } -v .:/code -v #{ ezbake_dir } :/ezbake #{ @image } /bin/sh -c 'tail -f /dev/null'" , silent : false , print_command : true )
39- end
40-
41- def run ( cmd )
42- run_command ( "docker exec #{ @container } /bin/bash --login -c '#{ cmd } '" , silent : false , print_command : true )
43- end
44-
4521namespace :vox do
4622 desc 'Build openvox-server packages with Docker'
4723 task :build , [ :tag ] do |_ , args |
48- begin
49- #abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty?
50- if args [ :tag ] . nil? || args [ :tag ] . empty?
51- puts 'running build with current branch'
52- else
53- puts "running build on #{ args [ :tag ] } "
54- run_command ( "git fetch --tags && git checkout #{ args [ :tag ] } " )
55- end
56-
57- # If the Dockerfile has changed since this was last built,
58- # delete all containers and do `docker rmi ezbake-builder`
59- unless image_exists
60- puts "Building ezbake-builder image"
61- run_command ( "docker build -t ezbake-builder ." , silent : false , print_command : true )
62- end
63-
64- puts "Checking out ezbake"
65- tmp = Dir . mktmpdir ( "ezbake" )
66- ezbake_dir = "#{ tmp } /ezbake"
67- ezbake_repo = ENV . fetch ( 'EZBAKE_REPO' , 'https://github.com/openvoxproject/ezbake' )
68- ezbake_branch = ENV [ 'EZBAKE_BRANCH' ] || 'main'
69- run_command ( "git clone -b #{ ezbake_branch } #{ ezbake_repo } #{ ezbake_dir } " , silent : false , print_command : true )
70-
71- puts "Starting container"
72- teardown if container_exists
73- start_container ( ezbake_dir )
74-
75- puts "Installing ezbake from source"
76- run ( "cd /ezbake && lein install" )
77-
78- puts "Building openvox-server"
79- run ( "cd /code && rm -rf ruby && rm -rf output && bundle install --without test && lein install" )
80- run ( "cd /code && COW=\" #{ @debs } \" MOCK=\" #{ @rpms } \" GEM_SOURCE='https://rubygems.org' EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile user,ezbake,provided,internal ezbake local-build" )
81- run_command ( "sudo chown -R $USER output" , print_command : true )
82- Dir . glob ( 'output/**/*i386*' ) . each { |f | FileUtils . rm_rf ( f ) }
83- Dir . glob ( 'output/puppetserver-*.tar.gz' ) . each { |f | FileUtils . mv ( f , f . sub ( 'puppetserver' , 'openvox-server' ) ) }
84- ensure
85- teardown
24+ if args [ :tag ] . nil? || args [ :tag ] . empty?
25+ puts 'running build with current branch'
26+ else
27+ puts "running build on #{ args [ :tag ] } "
28+ run_command ( "git fetch --tags && git checkout #{ args [ :tag ] } " )
8629 end
30+
31+ puts "Checking out ezbake"
32+ tmp = Dir . mktmpdir ( "ezbake" )
33+ ezbake_dir = "#{ tmp } /ezbake"
34+ ezbake_repo = ENV . fetch ( 'EZBAKE_REPO' , 'https://github.com/openvoxproject/ezbake' )
35+ ezbake_branch = ENV [ 'EZBAKE_BRANCH' ] || 'main'
36+ run_command ( "git clone -b #{ ezbake_branch } #{ ezbake_repo } #{ ezbake_dir } " , silent : false , print_command : true )
37+
38+ # prepare git foo for packaging gem (????)
39+ run_command ( "git config --global user.email '[email protected] '; git config --global user.name 'Your Name'" ) 40+
41+ puts "Installing ezbake from source"
42+ run_command ( "cd #{ ezbake_dir } && lein install" )
43+
44+ puts "Building openvox-server"
45+ run_command ( "rm -rf ruby && rm -rf output && lein install" )
46+ run_command ( "COW=\" #{ @debs } \" MOCK=\" #{ @rpms } \" GEM_SOURCE='https://rubygems.org' EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile user,ezbake,provided,internal ezbake local-build" )
47+ run_command ( "sudo chown -R $USER output" , print_command : true )
48+ Dir . glob ( 'output/**/*i386*' ) . each { |f | FileUtils . rm_rf ( f ) }
49+ Dir . glob ( 'output/puppetserver-*.tar.gz' ) . each { |f | FileUtils . mv ( f , f . sub ( 'puppetserver' , 'openvox-server' ) ) }
8750 end
8851end
0 commit comments