| 114 | end |
| 115 | |
| 116 | def docker_run(os, architecture, console: false) |
| 117 | id = os |
| 118 | id = "#{id}-#{architecture}" if architecture |
| 119 | image = docker_image(os, architecture) |
| 120 | build_command_line = [ |
| 121 | "docker", |
| 122 | "build", |
| 123 | "--build-arg", "BUILDKIT_INLINE_CACHE=1", |
| 124 | "--cache-from", image, |
| 125 | "--tag", image, |
| 126 | ] |
| 127 | run_command_line = [ |
| 128 | "docker", |
| 129 | "run", |
| 130 | "--rm", |
| 131 | "--log-driver", "none", |
| 132 | "--volume", "#{Dir.pwd}:/host:rw", |
| 133 | ] |
| 134 | if $stdin.tty? |
| 135 | run_command_line << "--interactive" |
| 136 | run_command_line << "--tty" |
| 137 | else |
| 138 | run_command_line.concat(["--attach", "STDOUT"]) |
| 139 | run_command_line.concat(["--attach", "STDERR"]) |
| 140 | end |
| 141 | build_dir = ENV["BUILD_DIR"] |
| 142 | if build_dir |
| 143 | build_dir = "#{File.expand_path(build_dir)}/#{id}" |
| 144 | mkdir_p(build_dir) |
| 145 | run_command_line.concat(["--volume", "#{build_dir}:/build:rw"]) |
| 146 | end |
| 147 | if debug_build? |
| 148 | build_command_line.concat(["--build-arg", "DEBUG=yes"]) |
| 149 | run_command_line.concat(["--env", "DEBUG=yes"]) |
| 150 | end |
| 151 | pass_through_env_names = [ |
| 152 | "DEB_BUILD_OPTIONS", |
| 153 | "RPM_BUILD_NCPUS", |
| 154 | ] |
| 155 | # The following environment variables carry the build variations that |
| 156 | # reprotest injects to verify reproducibility. |
| 157 | if File.basename(Dir.pwd) == apt_dir |
| 158 | pass_through_env_names += [ |
| 159 | "CPU_LIST", |
| 160 | "FAKETIME", |
| 161 | "HOME", |
| 162 | "LANG", |
| 163 | "LANGUAGE", |
| 164 | "LC_ALL", |
| 165 | "NO_FAKE_STAT", |
| 166 | "TZ", |
| 167 | ] |
| 168 | end |
| 169 | pass_through_env_names.each do |name| |
| 170 | value = ENV[name] |
| 171 | next unless value |
| 172 | run_command_line.concat(["--env", "#{name}=#{value}"]) |
| 173 | end |