Skip to content

Commit 5dfefde

Browse files
authored
build: normalize install tree ownership and permissions (#8803)
1 parent c84bd83 commit 5dfefde

2 files changed

Lines changed: 18 additions & 32 deletions

File tree

build.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,10 +1167,10 @@ def create_dockerfile_linux(
11671167

11681168
df += f"""
11691169
WORKDIR /opt
1170-
COPY --chown=1000:1000 build/install tritonserver
1170+
COPY build/install tritonserver
11711171
11721172
WORKDIR /opt/tritonserver
1173-
COPY --chown=1000:1000 NVIDIA_Deep_Learning_Container_License.pdf .
1173+
COPY NVIDIA_Deep_Learning_Container_License.pdf .
11741174
RUN find /opt/tritonserver/python -maxdepth 1 -type f -name \\
11751175
"tritonserver-*.whl" | xargs -I {{}} pip install --upgrade {{}}[{FLAGS.triton_wheels_dependencies_group}] && \\
11761176
find /opt/tritonserver/python -maxdepth 1 -type f -name \\
@@ -1185,7 +1185,7 @@ def create_dockerfile_linux(
11851185
df += """
11861186
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
11871187
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
1188-
COPY --chown=1000:1000 docker/sagemaker/serve /usr/bin/.
1188+
COPY docker/sagemaker/serve /usr/bin/.
11891189
"""
11901190
# This is required since libcublasLt.so is not present during the build
11911191
# stage of the PyTorch backend
@@ -1248,8 +1248,9 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
12481248
ENV TRITON_SERVER_GPU_ENABLED {gpu_enabled}
12491249
12501250
# Create a user that can be used to run triton as
1251-
# non-root. Make sure that this user to given ID 1000. All server
1252-
# artifacts copied below are assign to this user.
1251+
# non-root. Make sure that this user is given ID 1000. Server
1252+
# artifacts copied below remain owned by root; the triton-server
1253+
# user reads and executes them via standard group/other permissions.
12531254
ENV TRITON_SERVER_USER=triton-server
12541255
RUN userdel tensorrt-server > /dev/null 2>&1 || true \\
12551256
&& userdel ubuntu > /dev/null 2>&1 || true \\
@@ -2115,8 +2116,8 @@ def cibase_build(
21152116

21162117

21172118
def finalize_build(cmake_script, install_dir, ci_dir):
2118-
cmake_script.cmd(f"chmod -R a+rw {install_dir}")
2119-
cmake_script.cmd(f"chmod -R a+rw {ci_dir}")
2119+
cmake_script.cmd(f"chmod -R u+rwX,go+rX,go-w {install_dir}")
2120+
cmake_script.cmd(f"chmod -R u+rwX,go+rX,go-w {ci_dir}")
21202121

21212122

21222123
def enable_all():

compose.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ def start_dockerfile(ddir, images, argmap, dockerfile_name, backends):
9898
# Copy over files
9999
df += """
100100
WORKDIR /opt/tritonserver
101-
COPY --chown=1000:1000 --from=full /opt/tritonserver/LICENSE .
102-
COPY --chown=1000:1000 --from=full /opt/tritonserver/TRITON_VERSION .
103-
COPY --chown=1000:1000 --from=full /opt/tritonserver/NVIDIA_Deep_Learning_Container_License.pdf .
104-
COPY --chown=1000:1000 --from=full /opt/tritonserver/bin bin/
105-
COPY --chown=1000:1000 --from=full /opt/tritonserver/lib lib/
106-
COPY --chown=1000:1000 --from=full /opt/tritonserver/include include/
101+
COPY --from=full /opt/tritonserver/LICENSE .
102+
COPY --from=full /opt/tritonserver/TRITON_VERSION .
103+
COPY --from=full /opt/tritonserver/NVIDIA_Deep_Learning_Container_License.pdf .
104+
COPY --from=full /opt/tritonserver/bin bin/
105+
COPY --from=full /opt/tritonserver/lib lib/
106+
COPY --from=full /opt/tritonserver/include include/
107107
"""
108108
with open(os.path.join(ddir, dockerfile_name), "w") as dfile:
109109
dfile.write(df)
@@ -112,47 +112,32 @@ def start_dockerfile(ddir, images, argmap, dockerfile_name, backends):
112112
def add_requested_backends(ddir, dockerfile_name, backends):
113113
df = "# Copying over backends \n"
114114
for backend in backends:
115-
df += """COPY --chown=1000:1000 --from=full /opt/tritonserver/backends/{} /opt/tritonserver/backends/{}
115+
df += """COPY --from=full /opt/tritonserver/backends/{} /opt/tritonserver/backends/{}
116116
""".format(
117117
backend, backend
118118
)
119-
if len(backends) > 0:
120-
df += """
121-
# Top-level /opt/tritonserver/backends not copied so need to explicitly set permissions here
122-
RUN chown triton-server:triton-server /opt/tritonserver/backends
123-
"""
124119
with open(os.path.join(ddir, dockerfile_name), "a") as dfile:
125120
dfile.write(df)
126121

127122

128123
def add_requested_repoagents(ddir, dockerfile_name, repoagents):
129124
df = "# Copying over repoagents \n"
130125
for ra in repoagents:
131-
df += """COPY --chown=1000:1000 --from=full /opt/tritonserver/repoagents/{} /opt/tritonserver/repoagents/{}
126+
df += """COPY --from=full /opt/tritonserver/repoagents/{} /opt/tritonserver/repoagents/{}
132127
""".format(
133128
ra, ra
134129
)
135-
if len(repoagents) > 0:
136-
df += """
137-
# Top-level /opt/tritonserver/repoagents not copied so need to explicitly set permissions here
138-
RUN chown triton-server:triton-server /opt/tritonserver/repoagents
139-
"""
140130
with open(os.path.join(ddir, dockerfile_name), "a") as dfile:
141131
dfile.write(df)
142132

143133

144134
def add_requested_caches(ddir, dockerfile_name, caches):
145135
df = "# Copying over caches \n"
146136
for cache in caches:
147-
df += """COPY --chown=1000:1000 --from=full /opt/tritonserver/caches/{} /opt/tritonserver/caches/{}
137+
df += """COPY --from=full /opt/tritonserver/caches/{} /opt/tritonserver/caches/{}
148138
""".format(
149139
cache, cache
150140
)
151-
if len(caches) > 0:
152-
df += """
153-
# Top-level /opt/tritonserver/caches not copied so need to explicitly set permissions here
154-
RUN chown triton-server:triton-server /opt/tritonserver/caches
155-
"""
156141
with open(os.path.join(ddir, dockerfile_name), "a") as dfile:
157142
dfile.write(df)
158143

@@ -163,7 +148,7 @@ def end_dockerfile(ddir, dockerfile_name, argmap):
163148
if argmap["SAGEMAKER_ENDPOINT"]:
164149
df += """
165150
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
166-
COPY --chown=1000:1000 --from=full /usr/bin/serve /usr/bin/.
151+
COPY --from=full /usr/bin/serve /usr/bin/.
167152
"""
168153
with open(os.path.join(ddir, dockerfile_name), "a") as dfile:
169154
dfile.write(df)

0 commit comments

Comments
 (0)