Dockerfile

Example Dockerfile (contains various incoherent statements only, cannot be run):

 1# syntax=docker/dockerfile:1
 2
 3ARG NVIDIA_TRITON_IMAGE_FQN
 4FROM ${NVIDIA_TRITON_IMAGE_FQN}
 5
 6ARG ARTIFACTORY_HOST=aac-srv-artifactory.coretech.cerence.net
 7ARG BUILD_BACKENDS=${BUILD_BACKENDS:-ALL}
 8
 9USER root
10
11RUN <<EOF
12    apt-get update
13    apt-get install -y --no-install-recommends gnupg2 curl ca-certificates
14EOF
15
16ARG TRITON_SERVER_USER=triton-server
17ARG TRITON_SERVER_CHMOD=${TRITON_SERVER_USER}:${TRITON_SERVER_USER}
18COPY --chown=${TRITON_SERVER_CHMOD} 3rd_party/tensorrt-7.2.3.4-cp38-none-linux_x86_64.whl /pkgs/tensorrt-7.2.3.4-cp38-none-linux_x86_64.whl
19
20ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/usr/local/cuda-10.2/lib64
line 1:

Parser directive for Dockerfile frontend. This must be defined on top of the Dockerfile, because after the first comment, empty line or builder instruction has been processed, any following parser directives are treated as regular comments.

The Dockerfile frontend entry allows to dynamically load a custom Dockerfile syntax, whereas syntax=docker/dockerfile:1 points to the latest stable version 1 syntax.

line 3:

The ARG <NAME> instructions defines a variable that the user pass in at build-time. For example:

$ docker build --build-arg NVIDIA_TRITON_IMAGE_FQN="some_value"
line 6:

The ARG <NAME>=<VALUE> instruction defines a variable with a default value, so it is not mandatory to pass it in at build-time.

line 7:

The ARG <NAME>=${<VARIABLE>:-<DEFAULT>} instruction defines a variable <NAME> to the value of the variable <VARIABLE>. In case, <VARIABLE> is not passed in, the value assigned to <NAME> will be <DEFAULT>.

line 9:

From here onwards, all commands will be executed as user root.

line 11 - 15:

This section defines a Here-Document, which allows any lines after the opening (line 11) until the closing (line 15) to be part of the same command. This allows for multi-line scripts without chaining these lines together with && \ statements at the end of each of those lines. The delimiter (here: EOF) can be any single word string.

This were the substitute without the here-document:

RUN apt-get update && \
    apt-get install -y --no-install-recommends gnupg2 curl ca-certificates
line 18:

Copies a local file into the built Docker image using the --chown option to define the ownership of the copied file.

line 20:

Set an environment variable, here append :/usr/local/cuda-10.2/lib64 to the predefined environment variable LD_LIBRARY_PATH (the variable contains directories, which contain shared libraries, to be searched before using the default directories)