@@ -30,11 +30,16 @@ def cache_from(build_context)
3030 end
3131
3232 def build_push ( build_context )
33- [
34- build_context . local_branch =~ /:/ ?
35- build_context . image_name_for ( "pr-#{ build_context . pull_request } " ) :
36- build_context . image_name_for ( "br-#{ build_context . local_branch } " ) ,
37- ]
33+ if build_context . hosted?
34+ build_context . image_name_for ( build_context . build_id , prefix : nil )
35+ else
36+ [
37+ build_context . local_branch =~ /:/ ?
38+ build_context . image_name_for ( "pr-#{ build_context . pull_request } " ) :
39+ build_context . image_name_for ( "br-#{ build_context . local_branch } " ) ,
40+ build_context . image_name_for ( build_context . build_id )
41+ ]
42+ end
3843 end
3944 end
4045
@@ -66,23 +71,35 @@ def builder(ruby)
6671 compressed : ".buildkite.tgz"
6772 }
6873
69- plugin :docker_compose , {
70- build : "base" ,
71- config : ".buildkite/docker-compose.yml" ,
72- env : %w[ PRE_STEPS RACK ] ,
73- "image-name" => build_context . ruby . image_name_for ( build_context . build_id ) ,
74- "cache-from" => cache_from ( build_context ) ,
75- push : build_push ( build_context ) ,
76- "image-repository" => build_context . image_base ,
77- }
74+ if build_context . hosted?
75+ command <<~COMMAND . squish
76+ docker build --push
77+ --build-arg RUBY_IMAGE=#{ build_context . ruby . ruby_image }
78+ --tag #{ build_push ( build_context ) }
79+ --file .buildkite/Dockerfile .
80+ COMMAND
81+ else
82+ plugin :docker_compose , {
83+ build : "base" ,
84+ config : ".buildkite/docker-compose.yml" ,
85+ env : %w[ PRE_STEPS RACK ] ,
86+ "cache-from" => cache_from ( build_context ) ,
87+ push : build_push ( build_context ) ,
88+ }
89+ end
7890
79- env ( {
91+ env_opts = {
8092 BUNDLER : build_context . bundler ,
8193 RUBYGEMS : build_context . rubygems ,
82- RUBY_IMAGE : build_context . ruby . ruby_image ,
8394 encrypted_0fb9444d0374_key : nil ,
8495 encrypted_0fb9444d0374_iv : nil
85- } )
96+ }
97+
98+ if build_context . self_hosted?
99+ env_opts [ :RUBY_IMAGE ] = build_context . ruby . ruby_image
100+ end
101+
102+ env ( env_opts )
86103
87104 timeout_in_minutes 15
88105
0 commit comments