1#!/usr/bin/env python3 2# 3# Build the required docker image to run package unit tests 4# 5# Script Variables: 6# DOCKER_IMG_NAME: <optional, the name of the docker image to generate> 7# default is openbmc/ubuntu-unit-test 8# DISTRO: <optional, the distro to build a docker image against> 9# default is ubuntu:eoan 10# BRANCH: <optional, branch to build from each of the openbmc/ 11# repositories> 12# default is master, which will be used if input branch not 13# provided or not found 14# UBUNTU_MIRROR: <optional, the URL of a mirror of Ubuntu to override the 15# default ones in /etc/apt/sources.list> 16# default is empty, and no mirror is used. 17# http_proxy The HTTP address of the proxy server to connect to. 18# Default: "", proxy is not setup if this is not set 19 20import os 21import sys 22from sh import docker, git, nproc, uname 23 24# Read a bunch of environment variables. 25docker_image_name = os.environ.get("DOCKER_IMAGE_NAME", "openbmc/ubuntu-unit-test") 26distro = os.environ.get("DISTRO", "ubuntu:focal") 27branch = os.environ.get("BRANCH", "master") 28ubuntu_mirror = os.environ.get("UBUNTU_MIRROR") 29http_proxy = os.environ.get("http_proxy") 30 31# Set up some common variables. 32proc_count = nproc().strip() 33username = os.environ.get("USER") 34homedir = os.environ.get("HOME") 35gid = os.getgid() 36uid = os.getuid() 37 38# Determine the architecture for Docker. 39arch = uname("-m").strip() 40if arch == "ppc64le": 41 docker_base = "ppc64le/" 42elif arch == "x86_64": 43 docker_base = "" 44else: 45 print(f"Unsupported system architecture({arch}) found for docker image") 46 sys.exit(1) 47 48# Packages to include in image. 49packages = { 50 "boost": { 51 "rev": "1.74.0", 52 "url": ( 53 lambda pkg, rev: f"https://dl.bintray.com/boostorg/release/{rev}/source/{pkg}_{rev.replace('.', '_')}.tar.bz2" 54 ), 55 }, 56 "USCiLab/cereal": {"rev": "v1.3.0"}, 57 "catchorg/Catch2": {"rev": "v2.12.2"}, 58 "CLIUtils/CLI11": {"rev": "v1.9.0"}, 59 "fmtlib/fmt": {"rev": "6.2.1"}, 60 # Snapshot from 2020-01-03 61 "Naios/function2": {"rev": "3a0746bf5f601dfed05330aefcb6854354fce07d"}, 62 # Snapshot from 2020-02-13 63 "google/googletest": {"rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5"}, 64 # Release 2020-08-06 65 "nlohmann/json": {"rev": "v3.9.1"}, 66 # Snapshot from 2019-05-24 67 "linux-test-project/lcov": {"rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da"}, 68 # dev-5.0 2019-05-03 69 "openbmc/linux": {"rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327"}, 70 # Snapshot from 2019-09-03 71 "LibVNC/libvncserver": {"rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110"}, 72 "martinmoene/span-lite": {"rev": "v0.7.0"}, 73 # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb 74 "leethomason/tinyxml2": {"rev": "37bc3aca429f0164adf68c23444540b4a24b5778"}, 75 # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb 76 "CPPAlliance/url": {"rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b"}, 77 # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb 78 "tristanpenman/valijson": {"rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9"}, 79 # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb 80 "nlohmann/fifo_map": {"rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9"}, 81 "open-power/pdbg": {}, 82 "openbmc/gpioplus": {"depends": ["openbmc/stdplus"]}, 83 "openbmc/phosphor-dbus-interfaces": {"depends": ["openbmc/sdbusplus"]}, 84 "openbmc/phosphor-logging": { 85 "depends": [ 86 "USCiLab/cereal", 87 "nlohmann/fifo_map", 88 "openbmc/phosphor-dbus-interfaces", 89 "openbmc/sdbusplus", 90 "openbmc/sdeventplus", 91 ] 92 }, 93 "openbmc/phosphor-objmgr": { 94 "depends": [ 95 "boost", 96 "leethomason/tinyxml2", 97 "openbmc/phosphor-logging", 98 "openbmc/sdbusplus", 99 ] 100 }, 101 "openbmc/pldm": { 102 "depends": [ 103 "CLIUtils/CLI11", 104 "boost", 105 "nlohmann/json", 106 "openbmc/phosphor-dbus-interfaces", 107 "openbmc/phosphor-logging", 108 "openbmc/sdbusplus", 109 "openbmc/sdeventplus", 110 ] 111 }, 112 "openbmc/sdbusplus": {}, 113 "openbmc/sdeventplus": {"depends": ["Naios/function2", "openbmc/stdplus"]}, 114 "openbmc/stdplus": {"depends": ["fmtlib/fmt", "martinmoene/span-lite"]}, 115} 116 117 118def pkg_rev(pkg): 119 return packages[pkg]["rev"] 120 121 122def pkg_stagename(pkg): 123 if not pkg.startswith("openbmc/"): 124 pkg = "openbmc/" + pkg 125 return pkg.replace("/", "-") 126 127 128def pkg_url(pkg): 129 if "url" in packages[pkg]: 130 return packages[pkg]["url"](pkg, pkg_rev(pkg)) 131 return f"https://github.com/{pkg}/archive/{pkg_rev(pkg)}.tar.gz" 132 133 134def pkg_copycmds(pkg=None): 135 pkgs = [] 136 if pkg: 137 if "depends" not in packages[pkg]: 138 return "" 139 pkgs = sorted(packages[pkg]["depends"]) 140 else: 141 pkgs = sorted(packages.keys()) 142 143 copy_cmds = "" 144 for p in pkgs: 145 copy_cmds += f"COPY --from={pkg_stagename(p)} {prefix} {prefix}\n" 146 # Workaround for upstream docker bug and multiple COPY cmds 147 # https://github.com/moby/moby/issues/37965 148 copy_cmds += "RUN true\n" 149 return copy_cmds 150 151 152# Look up the HEAD for missing a static rev. 153pkg_lookups = {} 154for pkg in packages.keys(): 155 if "rev" in packages[pkg]: 156 continue 157 pkg_lookups[pkg] = git( 158 "ls-remote", "--heads", f"https://github.com/{pkg}", _bg=True 159 ) 160for pkg, result in pkg_lookups.items(): 161 for line in result.stdout.decode().split("\n"): 162 if f"refs/heads/{branch}" in line: 163 packages[pkg]["rev"] = line.strip().split()[0] 164 elif "refs/heads/master" in line and p not in packages: 165 packages[pkg]["rev"] = line.strip().split()[0] 166 167# Create the contents of the '/tmp/depcache'. 168# This needs to be sorted for consistency. 169depcache = "" 170for pkg in sorted(packages.keys()): 171 depcache += "%s:%s," % (pkg, pkg_rev(pkg)) 172 173# Define common flags used for builds 174prefix = "/usr/local" 175configure_flags = " ".join( 176 [ 177 f"--prefix={prefix}", 178 ] 179) 180cmake_flags = " ".join( 181 [ 182 "-DCMAKE_BUILD_TYPE=RelWithDebInfo", 183 "-DBUILD_SHARED_LIBS=ON", 184 f"-DCMAKE_INSTALL_PREFIX:PATH={prefix}", 185 ] 186) 187meson_flags = " ".join( 188 [ 189 "--wrap-mode=nodownload", 190 f"-Dprefix={prefix}", 191 ] 192) 193 194# Build the commands needed to compose our final image 195# We must sort the packages, otherwise we might produce an unstable 196# docker file and rebuild the image unnecessarily 197copy_cmds = pkg_copycmds() 198 199# Special flags if setting up a deb mirror. 200mirror = "" 201if "ubuntu" in distro and ubuntu_mirror: 202 mirror = f""" 203RUN echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME) main restricted universe multiverse" > /etc/apt/sources.list && \\ 204 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-updates main restricted universe multiverse" >> /etc/apt/sources.list && \\ 205 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-security main restricted universe multiverse" >> /etc/apt/sources.list && \\ 206 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-proposed main restricted universe multiverse" >> /etc/apt/sources.list && \\ 207 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-backports main restricted universe multiverse" >> /etc/apt/sources.list 208""" 209 210# Special flags for proxying. 211proxy_cmd = "" 212proxy_args = [] 213if http_proxy: 214 proxy_cmd = f""" 215RUN echo "[http]" >> {homedir}/.gitconfig && \ 216 echo "proxy = {http_proxy}" >> {homedir}/.gitconfig 217""" 218 proxy_args.extend( 219 [ 220 "--build-arg", 221 f"http_proxy={http_proxy}", 222 "--build-arg", 223 "https_proxy={https_proxy}", 224 ] 225 ) 226 227# Create docker image that can run package unit tests 228dockerfile = f""" 229FROM {docker_base}{distro} as openbmc-base 230 231{mirror} 232 233ENV DEBIAN_FRONTEND noninteractive 234 235ENV PYTHONPATH "/usr/local/lib/python3.8/site-packages/" 236 237# We need the keys to be imported for dbgsym repos 238# New releases have a package, older ones fall back to manual fetching 239# https://wiki.ubuntu.com/Debug%20Symbol%20Packages 240RUN apt-get update && ( apt-get install ubuntu-dbgsym-keyring || ( apt-get install -yy dirmngr && \ 241 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622 ) ) 242 243# Parse the current repo list into a debug repo list 244RUN sed -n '/^deb /s,^deb [^ ]* ,deb http://ddebs.ubuntu.com ,p' /etc/apt/sources.list >/etc/apt/sources.list.d/debug.list 245 246# Remove non-existent debug repos 247RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list 248 249RUN cat /etc/apt/sources.list.d/debug.list 250 251RUN apt-get update && apt-get dist-upgrade -yy && apt-get install -yy \ 252 gcc-10 \ 253 g++-10 \ 254 libc6-dbg \ 255 libc6-dev \ 256 libtool \ 257 bison \ 258 libdbus-1-dev \ 259 flex \ 260 cmake \ 261 python3 \ 262 python3-dev\ 263 python3-yaml \ 264 python3-mako \ 265 python3-pip \ 266 python3-setuptools \ 267 python3-git \ 268 python3-socks \ 269 pkg-config \ 270 autoconf \ 271 autoconf-archive \ 272 libsystemd-dev \ 273 systemd \ 274 libssl-dev \ 275 libevdev-dev \ 276 libevdev2-dbgsym \ 277 libjpeg-dev \ 278 libpng-dev \ 279 ninja-build \ 280 sudo \ 281 curl \ 282 git \ 283 dbus \ 284 iputils-ping \ 285 clang-10 \ 286 clang-format-10 \ 287 clang-tidy-10 \ 288 clang-tools-10 \ 289 shellcheck \ 290 npm \ 291 iproute2 \ 292 libnl-3-dev \ 293 libnl-genl-3-dev \ 294 libconfig++-dev \ 295 libsnmp-dev \ 296 valgrind \ 297 valgrind-dbg \ 298 libpam0g-dev \ 299 xxd \ 300 libi2c-dev \ 301 wget \ 302 libldap2-dev \ 303 libprotobuf-dev \ 304 libperlio-gzip-perl \ 305 libjson-perl \ 306 protobuf-compiler \ 307 libgpiod-dev \ 308 device-tree-compiler \ 309 cppcheck \ 310 libpciaccess-dev \ 311 libmimetic-dev \ 312 libxml2-utils \ 313 libxml-simple-perl 314 315RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 1000 \ 316 --slave /usr/bin/g++ g++ /usr/bin/g++-10 \ 317 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 \ 318 --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \ 319 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10 320 321 322RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \ 323 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \ 324 --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \ 325 --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \ 326 --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py 327 328RUN pip3 install inflection 329RUN pip3 install pycodestyle 330RUN pip3 install jsonschema 331RUN pip3 install meson==0.54.3 332RUN pip3 install protobuf 333 334FROM openbmc-base as {pkg_stagename('linux-test-project/lcov')} 335{pkg_copycmds('linux-test-project/lcov')} 336RUN curl -L {pkg_url('linux-test-project/lcov')} | tar -xz && \ 337cd lcov-* && \ 338make -j{proc_count} && \ 339make install 340 341FROM openbmc-base as {pkg_stagename('Naios/function2')} 342{pkg_copycmds('Naios/function2')} 343RUN curl -L {pkg_url('Naios/function2')} | tar -xz && \ 344cd function2-* && \ 345mkdir {prefix}/include/function2 && \ 346cp include/function2/function2.hpp {prefix}/include/function2/ 347 348FROM openbmc-base as {pkg_stagename('google/googletest')} 349{pkg_copycmds('google/googletest')} 350RUN curl -L {pkg_url('google/googletest')} | tar -xz && \ 351cd googletest-* && \ 352mkdir build && \ 353cd build && \ 354CXXFLAGS=-std=c++17 cmake {cmake_flags} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \ 355make -j{proc_count} && \ 356make install 357 358FROM openbmc-base as {pkg_stagename('catchorg/Catch2')} 359{pkg_copycmds('catchorg/Catch2')} 360RUN curl -L {pkg_url('catchorg/Catch2')} | tar -xz && \ 361cd Catch2-* && \ 362mkdir build && \ 363cd build && \ 364cmake {cmake_flags} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \ 365make -j{proc_count} && \ 366make install 367 368FROM openbmc-base as {pkg_stagename('USCiLab/cereal')} 369{pkg_copycmds('USCiLab/cereal')} 370RUN curl -L {pkg_url('USCiLab/cereal')} | tar -xz && \ 371cp -a cereal-*/include/cereal/ {prefix}/include/ 372 373FROM openbmc-base as {pkg_stagename('CLIUtils/CLI11')} 374{pkg_copycmds('CLIUtils/CLI11')} 375RUN curl -L {pkg_url('CLIUtils/CLI11')} | tar -xz && \ 376cd CLI11-* && \ 377mkdir build && \ 378cd build && \ 379cmake {cmake_flags} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \ 380make -j{proc_count} && \ 381make install 382 383FROM openbmc-base as {pkg_stagename('fmtlib/fmt')} 384{pkg_copycmds('fmtlib/fmt')} 385RUN curl -L {pkg_url('fmtlib/fmt')} | tar -xz && \ 386cd fmt-* && \ 387mkdir build && \ 388cd build && \ 389cmake {cmake_flags} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \ 390make -j{proc_count} && \ 391make install 392 393FROM openbmc-base as {pkg_stagename('nlohmann/json')} 394{pkg_copycmds('nlohmann/json')} 395RUN curl -L {pkg_url('nlohmann/json')} | tar -xz && \ 396cd json-* && \ 397mkdir {prefix}/include/nlohmann && \ 398cp include/nlohmann/json.hpp {prefix}/include/nlohmann && \ 399ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp 400 401FROM openbmc-base as {pkg_stagename('nlohmann/fifo_map')} 402{pkg_copycmds('nlohmann/fifo_map')} 403RUN curl -L {pkg_url('nlohmann/fifo_map')} | tar -xz && \ 404cd fifo_map-*/src && cp fifo_map.hpp {prefix}/include/ 405 406FROM openbmc-base as {pkg_stagename('martinmoene/span-lite')} 407{pkg_copycmds('martinmoene/span-lite')} 408RUN curl -L {pkg_url('martinmoene/span-lite')} | tar -xz && \ 409cd span-lite-* && \ 410mkdir build && \ 411cd build && \ 412cmake {cmake_flags} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \ 413make -j{proc_count} && \ 414make install 415 416FROM openbmc-base as {pkg_stagename('openbmc/linux')} 417{pkg_copycmds('openbmc/linux')} 418RUN curl -L {pkg_url('openbmc/linux')} | tar -xz && \ 419cd linux-* && \ 420make -j{proc_count} defconfig && \ 421make INSTALL_HDR_PATH=/usr/local headers_install 422 423FROM openbmc-base as {pkg_stagename('boost')} 424{pkg_copycmds('boost')} 425RUN curl -L {pkg_url('boost')} | tar -xj && \ 426cd boost_*/ && \ 427./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine && \ 428./b2 && ./b2 install --prefix={prefix} 429 430FROM openbmc-base as {pkg_stagename('leethomason/tinyxml2')} 431{pkg_copycmds('leethomason/tinyxml2')} 432RUN curl -L {pkg_url('leethomason/tinyxml2')} | tar -xz && \ 433cd tinyxml2-* && \ 434mkdir build && \ 435cd build && \ 436cmake {cmake_flags} .. && \ 437make -j{proc_count} && \ 438make install 439 440FROM openbmc-base as {pkg_stagename('CPPAlliance/url')} 441{pkg_copycmds('CPPAlliance/url')} 442RUN curl -L {pkg_url('CPPAlliance/url')} | tar -xz && \ 443cd url-* && \ 444mkdir buildir && \ 445cd buildir && \ 446cmake {cmake_flags} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \ 447make -j{proc_count} && \ 448make install 449 450FROM openbmc-base as {pkg_stagename('tristanpenman/valijson')} 451{pkg_copycmds('tristanpenman/valijson')} 452RUN curl -L {pkg_url('tristanpenman/valijson')} | tar -xz && \ 453cd valijson-* && \ 454mkdir build && \ 455cd build && \ 456cmake {cmake_flags} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \ 457make -j{proc_count} && \ 458make install 459 460FROM openbmc-base as {pkg_stagename('LibVNC/libvncserver')} 461{pkg_copycmds('LibVNC/libvncserver')} 462RUN curl -L {pkg_url('LibVNC/libvncserver')} | tar -xz && \ 463cd libvncserver-* && \ 464mkdir build && \ 465cd build && \ 466cmake {cmake_flags} .. && \ 467make -j{proc_count} && \ 468make install 469 470FROM openbmc-base as {pkg_stagename('openbmc/stdplus')} 471{pkg_copycmds('openbmc/stdplus')} 472RUN curl -L {pkg_url('openbmc/stdplus')} | tar -xz && \ 473cd stdplus-* && \ 474meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ 475ninja -C build && \ 476ninja -C build install 477 478FROM openbmc-base as {pkg_stagename('openbmc/sdbusplus')} 479{pkg_copycmds('openbmc/sdbusplus')} 480RUN curl -L {pkg_url('openbmc/sdbusplus')} | tar -xz && \ 481cd sdbusplus-* && \ 482cd tools && ./setup.py install --root=/ --prefix={prefix} && \ 483cd .. && meson build {meson_flags} -Dtests=disabled -Dexamples=disabled && \ 484ninja -C build && \ 485ninja -C build install 486 487FROM openbmc-base as {pkg_stagename('openbmc/sdeventplus')} 488{pkg_copycmds('openbmc/sdeventplus')} 489RUN curl -L {pkg_url('openbmc/sdeventplus')} | tar -xz && \ 490cd sdeventplus-* && \ 491meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ 492ninja -C build && \ 493ninja -C build install 494 495FROM openbmc-base as {pkg_stagename('openbmc/gpioplus')} 496{pkg_copycmds('openbmc/gpioplus')} 497RUN curl -L {pkg_url('openbmc/gpioplus')} | tar -xz && \ 498cd gpioplus-* && \ 499meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ 500ninja -C build && \ 501ninja -C build install 502 503FROM openbmc-base as {pkg_stagename('openbmc/phosphor-dbus-interfaces')} 504{pkg_copycmds('openbmc/phosphor-dbus-interfaces')} 505RUN curl -L {pkg_url('openbmc/phosphor-dbus-interfaces')} | tar -xz && \ 506cd phosphor-dbus-interfaces-* && \ 507meson build {meson_flags} -Ddata_org_open_power=true -Ddata_com_ibm=true && \ 508ninja -C build && \ 509ninja -C build install 510 511FROM openbmc-base as {pkg_stagename('openbmc/phosphor-logging')} 512{pkg_copycmds('openbmc/phosphor-logging')} 513RUN curl -L {pkg_url('openbmc/phosphor-logging')} | tar -xz && \ 514cd phosphor-logging-* && \ 515./bootstrap.sh && \ 516./configure {configure_flags} --enable-metadata-processing YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml && \ 517make -j{proc_count} && \ 518make install 519 520FROM openbmc-base as {pkg_stagename('openbmc/phosphor-objmgr')} 521{pkg_copycmds('openbmc/phosphor-objmgr')} 522RUN curl -L {pkg_url('openbmc/phosphor-objmgr')} | tar -xz && \ 523cd phosphor-objmgr-* && \ 524./bootstrap.sh && \ 525./configure {configure_flags} && \ 526make -j{proc_count} && \ 527make install 528 529FROM openbmc-base as {pkg_stagename('open-power/pdbg')} 530{pkg_copycmds('open-power/pdbg')} 531RUN curl -L {pkg_url('open-power/pdbg')} | tar -xz && \ 532cd pdbg-* && \ 533./bootstrap.sh && \ 534./configure {configure_flags} && \ 535make -j{proc_count} && \ 536make install 537 538FROM openbmc-base as {pkg_stagename('openbmc/pldm')} 539{pkg_copycmds('openbmc/pldm')} 540RUN curl -L {pkg_url('openbmc/pldm')} | tar -xz && \ 541cd pldm-* && \ 542meson build {meson_flags} -Dlibpldm-only=enabled -Doem-ibm=enabled -Dtests=disabled && \ 543ninja -C build && \ 544ninja -C build install 545 546# Build the final output image 547FROM openbmc-base 548{copy_cmds} 549 550# Some of our infrastructure still relies on the presence of this file 551# even though it is no longer needed to rebuild the docker environment 552# NOTE: The file is sorted to ensure the ordering is stable. 553RUN echo '{depcache}' > /tmp/depcache 554 555# Final configuration for the workspace 556RUN grep -q {gid} /etc/group || groupadd -g {gid} {username} 557RUN mkdir -p "{os.path.dirname(homedir)}" 558RUN grep -q {uid} /etc/passwd || useradd -d {homedir} -m -u {uid} -g {gid} {username} 559RUN sed -i '1iDefaults umask=000' /etc/sudoers 560RUN echo "{username} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers 561 562{proxy_cmd} 563 564RUN /bin/bash 565""" 566 567# Do the docker build. 568for line in docker.build( 569 proxy_args, 570 "--network=host", 571 "-t", 572 docker_image_name, 573 "-", 574 _in=dockerfile, 575 _iter=True, 576): 577 print(line, end="", flush=True) 578