File tree Expand file tree Collapse file tree 5 files changed +24
-4
lines changed Expand file tree Collapse file tree 5 files changed +24
-4
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "description" : " allow disabling buildkit for container engines lacking buildkit support." ,
3
+ "type" : " added"
4
+ }
Original file line number Diff line number Diff line change @@ -186,6 +186,8 @@ fn split_to_cloned_by_ws(string: &str) -> Vec<String> {
186
186
string. split_whitespace ( ) . map ( String :: from) . collect ( )
187
187
}
188
188
189
+ /// this takes the value of the environment variable,
190
+ /// so you should call `bool_from_envvar(env::var("FOO"))`
189
191
pub fn bool_from_envvar ( envvar : & str ) -> bool {
190
192
if let Ok ( value) = bool:: from_str ( envvar) {
191
193
value
Original file line number Diff line number Diff line change @@ -71,8 +71,11 @@ impl<'a> Dockerfile<'a> {
71
71
msg_info : & mut MessageInfo ,
72
72
) -> Result < String > {
73
73
let uses_zig = options. cargo_variant . uses_zig ( ) ;
74
- let mut docker_build = docker:: subcommand ( & options. engine , "buildx" ) ;
75
- docker_build. arg ( "build" ) ;
74
+ let mut docker_build = docker:: command ( & options. engine ) ;
75
+ match docker:: Engine :: has_buildkit ( ) {
76
+ true => docker_build. args ( [ "buildx" , "build" ] ) ,
77
+ false => docker_build. arg ( "build" ) ,
78
+ } ;
76
79
docker_build. env ( "DOCKER_SCAN_SUGGEST" , "false" ) ;
77
80
self . runs_with ( )
78
81
. specify_platform ( & options. engine , & mut docker_build) ;
Original file line number Diff line number Diff line change @@ -108,6 +108,13 @@ impl Engine {
108
108
. map ( |s| bool_from_envvar ( & s) )
109
109
. unwrap_or_default ( )
110
110
}
111
+
112
+ #[ must_use]
113
+ pub fn has_buildkit ( ) -> bool {
114
+ !env:: var ( "CROSS_CONTAINER_ENGINE_NO_BUILDKIT" )
115
+ . map ( |x| bool_from_envvar ( & x) )
116
+ . unwrap_or_default ( )
117
+ }
111
118
}
112
119
113
120
// determine if the container engine is docker. this fixes issues with
Original file line number Diff line number Diff line change @@ -176,7 +176,11 @@ pub fn build_docker_image(
176
176
msg_info. note ( format_args ! ( "Build {target} for {}" , platform. target) ) ?;
177
177
}
178
178
let mut docker_build = docker:: command ( engine) ;
179
- docker_build. args ( [ "buildx" , "build" ] ) ;
179
+ let has_buildkit = docker:: Engine :: has_buildkit ( ) ;
180
+ match has_buildkit {
181
+ true => docker_build. args ( [ "buildx" , "build" ] ) ,
182
+ false => docker_build. arg ( "build" ) ,
183
+ } ;
180
184
docker_build. current_dir ( & docker_root) ;
181
185
182
186
docker_build. args ( [ "--platform" , & platform. docker_platform ( ) ] ) ;
@@ -185,7 +189,7 @@ pub fn build_docker_image(
185
189
docker_build. arg ( "--push" ) ;
186
190
} else if engine. kind . is_docker ( ) && no_output {
187
191
docker_build. args ( [ "--output" , "type=tar,dest=/dev/null" ] ) ;
188
- } else {
192
+ } else if has_buildkit {
189
193
docker_build. arg ( "--load" ) ;
190
194
}
191
195
You can’t perform that action at this time.
0 commit comments