Docker Makefile
This Makefile is designed for managing the build, push, run, and development processes of Docker images and containers for NVIDIA TensorRT Large Language Models (LLM).
A Makefile is a special file used by the make
utility to automate the building, testing, and deployment of software projects.
It defines a set of rules and dependencies that specify how to compile and link source code files, generate documentation, run tests, and perform other project-related tasks.
Makefiles are commonly used in C/C++ projects but can be used with any programming language or project.
Variable Definitions
The Makefile starts by defining several variables using the ?=
operator, which assigns a default value to a variable if it is not already defined.
BASE_IMAGE
and BASE_TAG
specify the default base image and tag for the Docker build, extracted from the Dockerfile.multi
file.
IMAGE_NAME
and IMAGE_TAG
define the name and tag of the new Docker image to be built.
USER_ID
, USER_NAME
, GROUP_ID
, and GROUP_NAME
store the local user information.
LOCAL_USER
is a flag to indicate whether to add the current user to the Docker image and run the container with that user.Other variables like
STAGE
,IMAGE_WITH_TAG
,PUSH_TO_STAGING
,DOCKER_BUILD_OPTS
,DOCKER_BUILD_ARGS
,DOCKER_PROGRESS
,CUDA_ARCHS
,BUILD_WHEEL_ARGS
,TORCH_INSTALL_TYPE
,CUDA_VERSION
,CUDNN_VERSION
,NCCL_VERSION
,CUBLAS_VERSION
,TRT_VERSION
,DEVEL_IMAGE
,GIT_COMMIT
, andTRT_LLM_VERSION
are defined to customise the Docker build process.
Target Definitions
The Makefile defines several targets, each representing a specific task or stage of the build process.
The
%_build
target is responsible for building the Docker image. It uses thedocker build
command with various build arguments and options specified by the variables.The
%_user
target adds the local user to the Docker image using a separateDockerfile.user
.The
%_push
target pushes the built Docker image to a registry. It checks thePUSH_TO_STAGING
flag to determine whether to push to a staging registry or the main registry.The
%_pull
target pulls the specified Docker image from a registry.The
%_run
target runs the Docker container with the specified options and environment variables.
Phony Targets
The Makefile defines several phony targets like
build
,push
, andrun
, which are used to trigger the corresponding actions.These targets are marked as phony using the
.PHONY
directive to ensure they are always executed, even if a file with the same name exists.
Specific Build Targets
The Makefile defines specific build targets for different stages and environments, such as
devel_%
,wheel_%
,release_%
,jenkins_%
,jenkins-aarch64_%
,centos7_%
,ubuntu22_%
,old-cuda_%
, andtrtllm_%
.These targets set specific variables and options for each stage or environment, allowing for customised builds.
Helper Functions
The Makefile includes helper functions defined using the
define
directive.The
add_local_user
function is used to add the local user to the Docker image.The
rewrite_tag
function rewrites the image tag to include a staging suffix.
The purpose of this Makefile is to automate the build, push, and run processes for a Docker image related to the TensorRT-LLM project.
It provides flexibility and customisation options through the use of variables and targets, allowing for different build configurations and environments.
The Makefile leverages the power of make
to simplify complex build workflows and ensure consistent and reproducible builds.
By defining targets and dependencies, it enables users to easily trigger specific actions, such as building the Docker image, pushing it to a registry, or running the container with desired options.
Overall, this Makefile serves as a centralized and automated build system for the TensorRT-LLM project, making it easier for developers to manage and deploy the project using Docker containers.
Last updated