| 1601 | |
| 1602 | |
| 1603 | def create_docker_build_script(script_name, container_install_dir, container_ci_dir): |
| 1604 | with BuildScript( |
| 1605 | os.path.join(FLAGS.build_dir, script_name), |
| 1606 | verbose=FLAGS.verbose, |
| 1607 | desc=("Docker-based build script for Triton Inference Server"), |
| 1608 | ) as docker_script: |
| 1609 | # |
| 1610 | # Build base image... tritonserver_buildbase |
| 1611 | # |
| 1612 | docker_script.commentln(8) |
| 1613 | docker_script.comment("Create Triton base build image") |
| 1614 | docker_script.comment( |
| 1615 | "This image contains all dependencies necessary to build Triton" |
| 1616 | ) |
| 1617 | docker_script.comment() |
| 1618 | |
| 1619 | cachefrommap = [ |
| 1620 | "tritonserver_buildbase", |
| 1621 | "tritonserver_buildbase_cache0", |
| 1622 | "tritonserver_buildbase_cache1", |
| 1623 | ] |
| 1624 | |
| 1625 | baseargs = [ |
| 1626 | "docker", |
| 1627 | "build", |
| 1628 | "-t", |
| 1629 | "tritonserver_buildbase", |
| 1630 | "-f", |
| 1631 | os.path.join(FLAGS.build_dir, "Dockerfile.buildbase"), |
| 1632 | ] |
| 1633 | |
| 1634 | if not FLAGS.no_container_pull: |
| 1635 | baseargs += [ |
| 1636 | "--pull", |
| 1637 | ] |
| 1638 | |
| 1639 | baseargs += ["--cache-from={}".format(k) for k in cachefrommap] |
| 1640 | |
| 1641 | baseargs += ["."] |
| 1642 | |
| 1643 | docker_script.cwd(THIS_SCRIPT_DIR) |
| 1644 | docker_script.cmd(baseargs, check_exitcode=True) |
| 1645 | |
| 1646 | # |
| 1647 | # Build... |
| 1648 | # |
| 1649 | docker_script.blankln() |
| 1650 | docker_script.commentln(8) |
| 1651 | docker_script.comment("Run build in tritonserver_buildbase container") |
| 1652 | docker_script.comment("Mount a directory into the container where the install") |
| 1653 | docker_script.comment("artifacts will be placed.") |
| 1654 | docker_script.comment() |
| 1655 | |
| 1656 | # Don't use '-v' to communicate the built artifacts out of the |
| 1657 | # build, because we want this code to work even if run within |
| 1658 | # Docker (i.e. docker-in-docker) and not just if run directly |
| 1659 | # from host. |
| 1660 | runargs = [ |