forked from Xilinx/inference-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
890 lines (798 loc) · 32.8 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
# Copyright 2022 Xilinx Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG PROTEUS_ROOT=/workspace/proteus
ARG BASE_IMAGE=ubuntu:18.04
ARG DEV_BASE_IMAGE=${DEV_BASE_IMAGE:-proteus_dev_final}
ARG COPY_DIR=/root/deps
ARG TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ARG UNAME=proteus-user
ARG ENABLE_VITIS=${ENABLE_VITIS:-yes}
ARG ENABLE_TFZENDNN=${ENABLE_TFZENDNN:-no}
ARG TFZENDNN_PATH
ARG ENABLE_PTZENDNN=${ENABLE_PTZENDNN:-no}
ARG PTZENDNN_PATH
FROM ${BASE_IMAGE} AS proteus_base
ARG UNAME
ARG GNAME=proteus
ARG UID=1000
ARG GID=1000
ARG PROTEUS_ROOT
ARG ENABLE_VITIS
LABEL project="proteus"
LABEL vitis=${ENABLE_VITIS}
ENV TZ=America/Los_Angeles
ENV LANG=en_US.UTF-8
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
locales \
sudo \
tzdata \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
# set up timezone
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata \
# set up locale
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
# add a user
RUN groupadd -g $GID -o $GNAME \
&& useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME \
&& passwd -d $UNAME \
&& usermod -aG sudo $UNAME \
&& echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& usermod -aG $GNAME root
ENV PROTEUS_ROOT=$PROTEUS_ROOT
FROM proteus_base AS dev_base
ARG TARGETPLATFORM
SHELL ["/bin/bash", "-c"]
# install a newer compiler for all development images
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
gcc \
make \
# add the add-apt-repository command
software-properties-common \
# used to get packages
wget \
# install gcc-9 for a newer compiler
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
gcc-9 \
g++-9 \
# link gcc-9 and g++-9 to gcc and g++
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-9 \
# clean up
&& apt-get -y purge --auto-remove software-properties-common \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# install Cmake 3.21.1
RUN if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then \
archive="cmake-3.22.1-linux-x86_64.tar.gz"; \
elif [[ ${TARGETPLATFORM} == "linux/arm64" ]]; then \
archive="cmake-3.22.1-linux-aarch64.tar.gz"; \
else false; fi; \
url="https://github.com/Kitware/CMake/releases/download/v3.22.1/${archive}" \
&& cd /tmp/ \
&& wget --progress=dot:mega ${url} \
&& tar --strip-components=1 -xzf ${archive} -C /usr/local \
# && mkdir -p {COPY_DIR}/usr/local \
# && tar --strip-components=1 -xzf ${archive} -C ${COPY_DIR}/usr/local \
&& rm -rf /tmp/*
FROM dev_base AS builder
ARG COPY_DIR
ARG TARGETPLATFORM
WORKDIR /tmp
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
ca-certificates \
checkinstall \
git \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# make a directory to hold everything to be copied later
RUN mkdir ${COPY_DIR}
# install gosu 1.12 for dropping down to the user in the entrypoint
RUN if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then \
url="https://github.com/tianon/gosu/releases/download/1.12/gosu-amd64"; \
elif [[ ${TARGETPLATFORM} == "linux/arm64" ]]; then \
url="https://github.com/tianon/gosu/releases/download/1.12/gosu-arm64"; \
else false; fi; \
wget -O gosu --progress=dot:mega ${url} \
&& chmod 755 gosu \
&& mkdir -p ${COPY_DIR}/usr/local/bin/ && cp gosu ${COPY_DIR}/usr/local/bin/ \
&& rm -rf /tmp/*
# install git-lfs 2.13.3 for managing large files
RUN if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then \
archive="git-lfs-linux-amd64-v2.13.3.tar.gz"; \
elif [[ ${TARGETPLATFORM} == "linux/arm64" ]]; then \
archive="git-lfs-linux-arm64-v2.13.3.tar.gz"; \
else false; fi; \
url="https://github.com/git-lfs/git-lfs/releases/download/v2.13.3/${archive}" \
&& wget --progress=dot:mega ${url} \
&& mkdir git-lfs \
&& tar -xzf ${archive} -C git-lfs \
&& mkdir -p ${COPY_DIR}/usr/local/bin/ && cp git-lfs/git-lfs ${COPY_DIR}/usr/local/bin/ \
&& rm -rf /tmp/*
# install lcov 1.15 for test coverage measurement
RUN wget --progress=dot:mega https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz \
&& tar -xzf lcov-1.15.tar.gz \
&& cd lcov-1.15 \
&& checkinstall -y --pkgname lcov --pkgversion 1.15 --pkgrelease 1 make install \
&& cd /tmp \
&& dpkg -L lcov | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& rm -rf /tmp/*
# install NodeJS 14.16.0 for web gui development
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
xz-utils \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then \
archive="node-v14.16.0-linux-x64.tar.xz"; \
elif [[ ${TARGETPLATFORM} == "linux/arm64" ]]; then \
archive="node-v14.16.0-linux-arm64.tar.xz"; \
else false; fi; \
url="https://nodejs.org/dist/v14.16.0/${archive}" \
&& wget --progress=dot:mega ${url} \
&& tar --strip-components=1 -xf ${archive} -C /usr/local \
&& mkdir -p ${COPY_DIR}/usr/local \
&& tar --strip-components=1 -xf ${archive} -C ${COPY_DIR}/usr/local \
&& rm -rf /tmp/*
# install cxxopts 2.2.1 for argument parsing
RUN wget --progress=dot:mega https://github.com/jarro2783/cxxopts/archive/refs/tags/v2.2.1.tar.gz \
&& tar -xzf v2.2.1.tar.gz \
&& cd cxxopts-2.2.1 \
&& mkdir -p ${COPY_DIR}/usr/local/include/cxxopts \
&& cp include/cxxopts.hpp ${COPY_DIR}/usr/local/include/cxxopts \
&& rm -rf /tmp/*
# install concurrentqueue 1.0.3 for a lock-free multi-producer and consumer queue
RUN wget --progress=dot:mega https://github.com/cameron314/concurrentqueue/archive/refs/tags/v1.0.3.tar.gz \
&& tar -xzf v1.0.3.tar.gz \
&& cd concurrentqueue-1.0.3 \
&& cmake . \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install drogon 1.7.5 for a http server
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
libbrotli-dev \
libjsoncpp-dev \
libc-ares-dev \
libssl-dev \
uuid-dev \
zlib1g-dev \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
# symlink libjsoncpp to json to maintain include compatibility with Drogon
&& cp -rfs /usr/include/jsoncpp/json/ /usr/include/ \
# install drogon
&& cd /tmp && git clone -b v1.7.5 https://github.com/an-tao/drogon \
&& cd drogon \
&& git submodule update --init --recursive \
&& mkdir -p build && cd build \
&& cmake .. \
-DBUILD_EXAMPLES=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_ORM=OFF \
-DBUILD_DROGON_SHARED=ON \
-DBUILD_CTL=OFF \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install libb64 2.0.0.1. The default version in apt adds linebreaks when encoding
RUN wget --progress=dot:mega https://github.com/libb64/libb64/archive/refs/tags/v2.0.0.1.tar.gz \
&& tar -xzf v2.0.0.1.tar.gz \
&& cd libb64-2.0.0.1 \
&& make -j$(($(nproc) - 1)) all_src \
&& mkdir -p ${COPY_DIR}/usr/local/lib && cp src/libb64.a ${COPY_DIR}/usr/local/lib \
&& mkdir -p ${COPY_DIR}/usr/local/include && cp -r include/b64 ${COPY_DIR}/usr/local/include \
&& rm -rf /tmp/*
# install GTest 1.11.0 for C++ testing
RUN wget --progress=dot:mega https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz \
&& tar -xzf release-1.11.0.tar.gz \
&& cd googletest-release-1.11.0 \
&& mkdir -p build && cd build \
&& cmake .. \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install FFmpeg 3.4.8 for opencv
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
nasm \
&& wget --progress=dot:mega https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n3.4.8.tar.gz \
&& tar -xzf n3.4.8.tar.gz \
&& cd FFmpeg-n3.4.8 \
&& ./configure --disable-static --enable-shared --disable-doc \
&& make -j$(($(nproc) - 1)) \
&& checkinstall -y --pkgname ffmpeg --pkgversion 3.4.8 --pkgrelease 1 make install \
&& cd /tmp \
&& dpkg -L ffmpeg | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& rm -rf /tmp/*
# install opencv 3.4.3 for image and video processing
# pkg-config is needed to find ffmpeg
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
pkg-config \
&& wget --progress=dot:mega https://github.com/opencv/opencv/archive/3.4.3.tar.gz \
&& tar -xzf 3.4.3.tar.gz \
&& cd opencv-3.4.3 \
&& mkdir -p build \
&& cd build \
&& cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=OFF -DBUILD_PERF_TESTS=OFF -DWITH_FFMPEG=ON .. \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install protobuf 3.19.4 for Vitis AI runtime and gRPC
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
autoconf \
automake \
checkinstall \
curl \
libtool \
unzip \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& VERSION=3.19.4 \
&& wget --progress=dot:mega https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protobuf-cpp-${VERSION}.tar.gz \
&& tar -xzf protobuf-cpp-${VERSION}.tar.gz \
&& cd protobuf-${VERSION} \
&& ./autogen.sh \
&& ./configure \
&& make -j$(($(nproc) - 1)) \
&& checkinstall -y --pkgname protobuf --pkgversion ${VERSION} --pkgrelease 1 make install \
&& cd /tmp \
&& dpkg -L protobuf | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& rm -rf /tmp/*
# install spdlog 1.8.2
RUN wget --progress=dot:mega https://github.com/gabime/spdlog/archive/refs/tags/v1.8.2.tar.gz \
&& tar -xzf v1.8.2.tar.gz \
&& cd spdlog-1.8.2 \
&& mkdir -p build && cd build \
&& cmake .. \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install prometheus-cpp 0.12.2 for metrics
RUN wget --progress=dot:mega https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v0.12.2.tar.gz \
&& tar -xzf v0.12.2.tar.gz \
&& cd prometheus-cpp-0.12.2 \
&& mkdir -p build && cd build \
&& cmake .. \
-DENABLE_PUSH=OFF \
-DENABLE_PULL=OFF \
-DENABLE_TESTING=OFF \
-DBUILD_SHARED_LIBS=ON \
-DUSE_THIRDPARTY_LIBRARIES=OFF \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# get Nlohmann JSON for building opentelemetry
RUN wget --progress=dot:mega https://github.com/nlohmann/json/archive/refs/tags/v3.7.3.tar.gz \
&& tar -xzf v3.7.3.tar.gz \
&& cd json-3.7.3 \
&& mkdir -p build && cd build \
&& cmake .. \
-DBUILD_TESTING=OFF \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& rm -rf /tmp/*
# install Apache Thrift 0.12.0 for running the jaeger exporter in opentelemetry
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
bison \
flex \
libboost-all-dev \
&& VERSION=0.15.0 \
&& cd /tmp && wget --progress=dot:mega https://github.com/apache/thrift/archive/refs/tags/v${VERSION}.tar.gz \
&& tar -xzf v${VERSION}.tar.gz \
&& cd thrift-${VERSION} \
&& mkdir -p build && cd build \
&& cmake .. \
-DBUILD_TESTING=OFF \
-DBUILD_TUTORIALS=OFF \
-DBUILD_COMPILER=ON \
-DBUILD_CPP=ON \
-DBUILD_C_GLIB=OFF \
-DBUILD_JAVA=OFF \
-DBUILD_PYTHON=OFF \
-DBUILD_JAVASCRIPT=OFF \
-DBUILD_NODEJS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=OFF \
&& make -j$(($(nproc) - 1)) \
&& make install \
# && cd /tmp \
# && dpkg -L thrift | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& rm -rf /tmp/*
# install opentelemetry 1.1.0 for tracing
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
libcurl4-openssl-dev \
&& VERSION=1.1.0 \
&& wget https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v${VERSION}.tar.gz \
&& tar -xzf v${VERSION}.tar.gz \
&& cd opentelemetry-cpp-${VERSION} \
&& mkdir build && cd build \
&& cmake .. \
-DWITH_JAEGER=ON \
-DBUILD_TESTING=OFF \
-DWITH_EXAMPLES=OFF \
-DWITH_PROMETHEUS=ON \
-DWITH_STL=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=ON \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -rf /tmp/*
# install wrk for http benchmarking
RUN wget --progress=dot:mega https://github.com/wg/wrk/archive/refs/tags/4.1.0.tar.gz \
&& tar -xzf 4.1.0.tar.gz \
&& cd wrk-4.1.0 \
&& make -j$(($(nproc) - 1)) \
&& mkdir -p ${COPY_DIR}/usr/local/bin && cp wrk ${COPY_DIR}/usr/local/bin \
&& rm -rf /tmp/*
# install include-what-you-use 0.14
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
libclang-10-dev \
clang-10 \
llvm-10-dev \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& wget --progress=dot:mega https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/0.14.tar.gz \
&& tar -xzf 0.14.tar.gz \
&& cd include-what-you-use-0.14 \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_PREFIX_PATH=/usr/lib/llvm-10 .. \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -fr /tmp/*
# install gRPC 1.44.0
RUN git clone --depth=1 --branch v1.44.0 --single-branch https://github.com/grpc/grpc \
&& cd grpc \
&& git submodule update --init third_party/abseil-cpp third_party/re2 \
&& mkdir -p build && cd build \
&& cmake -DgRPC_ZLIB_PROVIDER=package \
-DgRPC_CARES_PROVIDER=custom \
-D_gRPC_CARES_LIBRARIES=cares \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_RE2_PROVIDER=module \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_PROTOBUF_PACKAGE_TYPE="" \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_ABSL_PROVIDER=module \
.. \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -fr /tmp/*
# install pybind11 2.9.1
RUN VERSION=2.9.1 \
&& wget https://github.com/pybind/pybind11/archive/refs/tags/v${VERSION}.tar.gz \
&& tar -xzf v${VERSION}.tar.gz \
&& cd pybind11-${VERSION}/ \
&& mkdir build \
&& cd build \
&& cmake -DPYBIND11_TEST=OFF .. \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -fr /tmp/*
# install efsw for directory monitoring
RUN git clone https://github.com/SpartanJ/efsw.git \
&& cd efsw && mkdir build && cd build \
&& cmake .. \
&& make -j \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp && rm -fr /tmp/*
# Delete /usr/local/man which is a symlink and cannot be copied later by BuildKit.
# Note: this works without BuildKit: https://github.com/docker/buildx/issues/150
# RUN cp -rf ${COPY_DIR}/usr/local/man/ ${COPY_DIR}/usr/local/share/man/ \
# && rm -rf ${COPY_DIR}/usr/local/man/
# install doxygen 1.9.2
# RUN cd /tmp && wget --progress=dot:mega https://github.com/doxygen/doxygen/archive/refs/tags/Release_1_9_2.tar.gz \
# && tar -xzf Release_1_9_2.tar.gz \
# && cd doxygen-Release_1_9_2/ \
# && mkdir -p build \
# && cd build \
# && cmake ..
# && make -j$(($(nproc) - 1)) \
# && make install \
# && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
# && cd /tmp \
# && rm -fr /tmp/*
FROM dev_base AS proteus_dev
ARG TARGETPLATFORM
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
# used for auto-completing bash commands
bash-completion \
curl \
git \
make \
# used for git
openssh-client \
python3 \
python3-dev \
# install documentation dependencies
doxygen \
graphviz \
# install debugging tools
gdb \
valgrind \
vim \
# used to turn absolute symlinks into relative ones
symlinks \
# used for code formatting and style
clang-format-10 \
clang-tidy-10 \
# used for json objects in proteus since it's also used in Drogon
libjsoncpp-dev \
# used for z compression in proteus
zlib1g-dev \
# used by drogon. It needs the -dev versions to pass Cmake
libbrotli-dev \
libc-ares-dev \
libssl-dev \
uuid-dev \
# symlink the versioned clang-*-10 executables to clang-*
&& ln -s /usr/bin/clang-format-10 /usr/bin/clang-format \
&& ln -s /usr/bin/clang-tidy-10 /usr/bin/clang-tidy \
# symlink libjsoncpp to json to maintain include compatibility with Drogon
&& cp -rfs /usr/include/jsoncpp/json/ /usr/include/ \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
python3-pip \
&& python3 -m pip install --upgrade --force-reinstall pip \
&& pip install --no-cache-dir \
# install these first
setuptools \
wheel \
# the sphinx theme has a bug with docutils>=0.17
"docutils<0.17" \
&& pip install --no-cache-dir \
# install testing dependencies
pytest \
pytest-cpp \
pytest-xprocess \
requests \
# install documentation dependencies
breathe \
fastcov \
sphinx \
sphinx_copybutton \
sphinxcontrib-confluencebuilder \
sphinx-argparse \
sphinx-issues \
# install linting tool
black \
cpplint \
# install opencv
opencv-python-headless \
# install benchmarking dependencies
pytest-benchmark \
rich \
# used for Python bindings
pybind11_mkdoc \
pybind11-stubgen \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
FROM proteus_dev as proteus_install_vitis_no
FROM builder as proteus_install_vitis_builder
WORKDIR /tmp/
SHELL ["/bin/bash", "-c"]
ARG COPY_DIR
ARG TARGETPLATFORM
RUN mkdir -p ${COPY_DIR}
# install json-c 0.15 for Vitis AI runtime
RUN wget --progress=dot:mega https://github.com/json-c/json-c/archive/refs/tags/json-c-0.15-20200726.tar.gz \
&& tar -xzf json-c-0.15-20200726.tar.gz \
&& cd json-c-json-c-0.15-20200726 \
&& mkdir build \
&& cd build \
&& cmake .. \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
&& make -j$(($(nproc) - 1)) \
&& make install \
&& cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp \
&& rm -fr /tmp/*
# Install XRT and XRM
RUN apt-get update \
&& if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then \
cd /tmp \
&& wget --progress=dot:mega -O xrt.deb https://www.xilinx.com/bin/public/openDownload?filename=xrt_202120.2.12.427_18.04-amd64-xrt.deb \
&& wget --progress=dot:mega -O xrm.deb https://www.xilinx.com/bin/public/openDownload?filename=xrm_202120.1.3.29_18.04-x86_64.deb \
&& apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
./xrt.deb \
./xrm.deb \
# copy over debians to COPY_DIR so we can install them as debians in
# the final image for easy removal later if needed
&& cp ./xrt.deb ${COPY_DIR} \
&& cp ./xrm.deb ${COPY_DIR}; \
fi; \
# clean up
apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /tmp/*
# Install Vitis AI runtime and build dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
git \
libgoogle-glog-dev \
libssl-dev \
pkg-config \
python3-dev \
&& git clone --recursive --single-branch --branch v2.5 --depth 1 https://github.com/Xilinx/Vitis-AI.git \
&& export VITIS_ROOT=/tmp/Vitis-AI/src/Vitis-AI-Runtime/VART \
&& git clone --single-branch -b v2.0 --depth 1 https://github.com/Xilinx/rt-engine.git ${VITIS_ROOT}/rt-engine; \
cd ${VITIS_ROOT}/unilog \
&& ./cmake.sh --clean --type=release --install-prefix /usr/local/ --build-dir ./build \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd ${VITIS_ROOT}/xir \
&& ./cmake.sh --clean --type=release --install-prefix /usr/local/ --build-dir ./build --build-python \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd ${VITIS_ROOT}/target_factory \
&& ./cmake.sh --clean --type=release --install-prefix /usr/local/ --build-dir ./build \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd ${VITIS_ROOT}/vart \
&& ./cmake.sh --clean --type=release --install-prefix /usr/local/ --cmake-options="-DBUILD_TEST=OFF" --build-python --build-dir ./build \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd ${VITIS_ROOT}/rt-engine \
&& ./cmake.sh --clean --build-dir=./build --type=release --cmake-options="-DXRM_DIR=/opt/xilinx/xrm/share/cmake" --install-prefix /usr/local/ \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
&& cd /tmp/Vitis-AI/src/AKS \
# fix bug in AKS
&& sed -i '46i _global = nullptr;' ./src/AksTopContainer.cpp \
&& ./cmake.sh --clean --type=release --install-prefix /usr/local/ --build-dir ./build \
&& cd ./build && cat install_manifest.txt | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
# copy over debians to COPY_DIR so we can install them as debians in
# the final image for easy removal later if needed
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /tmp/*
FROM proteus_dev as proteus_install_vitis_yes
ARG COPY_DIR
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
# used by vitis ai runtime
libgoogle-glog-dev \
libboost-filesystem1.65.1 \
libboost-system1.65.1 \
libboost-serialization1.65.1 \
libboost-thread1.65.1 \
libboost1.65-dev \
# used to detect if ports are in use for XRM
net-tools \
# used by libunilog as a fallback to find glog
pkg-config \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=proteus_install_vitis_builder ${COPY_DIR} /
# install all the Vitis AI runtime libraries built from source as debians
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
/*.deb \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm /*.deb
FROM proteus_install_vitis_${ENABLE_VITIS} as proteus_builder
ARG COPY_DIR
ARG PROTEUS_ROOT
ARG ENABLE_VITIS
SHELL ["/bin/bash", "-c"]
# pyinstaller 4.6 has a bug https://github.com/pyinstaller/pyinstaller/issues/6331
RUN pip install --no-cache-dir "pyinstaller!=4.6" \
# docker-systemctl-replacement v1.5.4504
&& cd /tmp && wget --progress=dot:mega https://github.com/gdraheim/docker-systemctl-replacement/archive/refs/tags/v1.5.4505.tar.gz \
&& tar -xzf v1.5.4505.tar.gz \
&& cd docker-systemctl-replacement-1.5.4505 \
&& pyinstaller files/docker/systemctl3.py --onefile \
&& chmod a+x dist/systemctl3 \
&& mkdir -p ${COPY_DIR}/bin/ \
&& cp dist/systemctl3 ${COPY_DIR}/bin/systemctl \
&& rm -fr /tmp/*
# COPY --from=builder ${COPY_DIR} /
COPY . $PROTEUS_ROOT
RUN if [[ ${ENABLE_VITIS} == "yes" ]]; then \
# make binary for custom script to get FPGAs
pyinstaller $PROTEUS_ROOT/docker/fpga_util.py --onefile \
&& chmod a+x dist/fpga_util \
&& mkdir -p ${COPY_DIR}/usr/local/bin/ \
&& cp dist/fpga_util ${COPY_DIR}/usr/local/bin/fpga-util; \
fi
FROM proteus_install_vitis_${ENABLE_VITIS} as proteus_install_tfzendnn_no
FROM proteus_install_vitis_${ENABLE_VITIS} as proteus_install_tfzendnn_yes
ARG TFZENDNN_PATH
SHELL ["/bin/bash", "-c"]
COPY $TFZENDNN_PATH /tmp/
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
zip unzip \
&& cd /tmp/ \
# Check to verify if package is TF+ZenDNN
&& echo "51b3b4093775ff2b67e06f18d01b41ac $(basename $TFZENDNN_PATH)" | md5sum -c - \
&& unzip $(basename $TFZENDNN_PATH) \
&& cd $(basename ${TFZENDNN_PATH%.*}) \
# To avoid protobuf version issues, create subfolder and copy include files
&& mkdir -p /usr/include/tfzendnn/ \
&& cp -r include/* /usr/include/tfzendnn \
&& cp -r lib/*.so* /usr/lib \
&& sudo apt remove zip unzip -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /tmp/*
FROM proteus_install_tfzendnn_${ENABLE_TFZENDNN} as proteus_install_ptzendnn_no
FROM proteus_install_tfzendnn_${ENABLE_TFZENDNN} as proteus_install_ptzendnn_yes
ARG PTZENDNN_PATH
SHELL ["/bin/bash", "-c"]
COPY $PTZENDNN_PATH /tmp/
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
zip unzip \
&& cd /tmp/ \
# Check to verify if package is PT+ZenDNN
&& echo "a191f2305f1cae6e00c82a1071df9708 $(basename $PTZENDNN_PATH)" | md5sum -c - \
&& unzip $(basename $PTZENDNN_PATH) \
&& cd $(basename ${PTZENDNN_PATH%.*}) \
# To avoid protobuf version issues, create subfolder and copy include files
&& mkdir -p /usr/include/ptzendnn/ \
&& cp -r include/* /usr/include/ptzendnn \
&& cp -r lib/*.so* /usr/lib \
&& apt remove zip unzip -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /tmp/*
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
autoconf \
&& cd /tmp/ && wget -q https://github.com/jemalloc/jemalloc/archive/refs/tags/5.3.0.tar.gz \
&& tar -xzf 5.3.0.tar.gz \
&& cd jemalloc-5.3.0 && ./autogen.sh \
&& make -j \
&& make install \
&& apt-get remove autoconf -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /tmp/*
FROM proteus_install_ptzendnn_${ENABLE_PTZENDNN} as proteus_dev_final
ARG COPY_DIR
ARG PROTEUS_ROOT
ARG UNAME
COPY --from=builder ${COPY_DIR} /
COPY --from=proteus_builder ${COPY_DIR} /
COPY --from=proteus_builder $PROTEUS_ROOT/docker/entrypoint.sh /root/entrypoint.sh
COPY --from=proteus_builder $PROTEUS_ROOT/docker/.bash* /home/${UNAME}/
COPY --from=proteus_builder $PROTEUS_ROOT/docker/.env /home/${UNAME}/
# run any final commands before finishing the dev image
RUN git lfs install \
&& npm install -g gh-pages \
&& ldconfig
ENTRYPOINT [ "/root/entrypoint.sh", "user"]
CMD [ "/bin/bash" ]
FROM ${DEV_BASE_IMAGE} as proteus_builder_2
ARG COPY_DIR
ARG PROTEUS_ROOT
ARG ENABLE_VITIS
COPY . $PROTEUS_ROOT
RUN ldconfig \
&& mkdir -p ${COPY_DIR} \
# install libproteus.so
&& cd ${PROTEUS_ROOT} \
&& ./proteus install --all \
&& ./proteus install --get-manifest | xargs -i bash -c "if [ -f {} ]; then cp --parents -P {} ${COPY_DIR}; fi" \
# build the static GUI files
# && cd src/gui && npm install && npm run build \
# get all the runtime shared library dependencies for the server
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
# needed for get_dynamic_dependencies.sh
file \
# clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
# create a copy of all the dynamic libraries needed by the server and workers
&& cd ${PROTEUS_ROOT} \
&& ./docker/get_dynamic_dependencies.sh --copy ${COPY_DIR} --vitis ${ENABLE_VITIS}
FROM proteus_base AS proteus_production_vitis_yes
ARG COPY_DIR
ARG PROTEUS_ROOT
# get AKS kernels
COPY --from=proteus_builder_2 $PROTEUS_ROOT/external/aks/libs/ /opt/xilinx/proteus/aks/libs/
# get the fpga-util executable
COPY --from=proteus_builder ${COPY_DIR}/usr/local/bin/fpga-util /opt/xilinx/proteus/bin/
# we need the xclbins in the image and they must be copied from a path local
# to the build tree. But we also need this hack so the copy doesn't fail
# if this directory doesn't exist
COPY --from=proteus_builder_2 $PROTEUS_ROOT/docker/.env $PROTEUS_ROOT/external/overlaybin[s]/ /opt/xilinx/overlaybins/
# get the pre-defined AKS graphs and kernels
COPY --from=proteus_builder_2 $PROTEUS_ROOT/external/aks/graph_zoo/ /opt/xilinx/proteus/aks/graph_zoo/
COPY --from=proteus_builder_2 $PROTEUS_ROOT/external/aks/kernel_zoo/ /opt/xilinx/proteus/aks/kernel_zoo/
ENV LD_LIBRARY_PATH="/usr/local/lib/proteus:/opt/xilinx/proteus/aks"
ENV XILINX_XRT="/opt/xilinx/xrt"
# TODO(varunsh): we shouldn't hardcode dpuv3int8 here
ENV XLNX_VART_FIRMWARE="/opt/xilinx/overlaybins/dpuv3int8"
ENV AKS_ROOT="/opt/xilinx/proteus/aks"
ENV AKS_XMODEL_ROOT="/opt/xilinx/proteus"
ENV PATH="/opt/xilinx/proteus/bin:${PATH}"
FROM proteus_base AS proteus_production_vitis_no
FROM proteus_production_vitis_${ENABLE_VITIS} AS proteus
ARG PROTEUS_ROOT
ARG COPY_DIR
ARG UNAME
WORKDIR /home/${UNAME}
# get all the installed files: the server, workers, C++ headers and dependencies
COPY --from=proteus_builder_2 ${COPY_DIR} /
# get the static gui files
# COPY --from=proteus_builder_2 $PROTEUS_ROOT/src/gui/build/ /opt/xilinx/proteus/gui/
# get the entrypoint script
COPY --from=proteus_builder_2 $PROTEUS_ROOT/docker/entrypoint.sh /root/entrypoint.sh
# get the systemctl executable - pulled in by get_dynamic_dependencies.sh
# COPY --from=proteus_builder ${COPY_DIR}/bin/systemctl /bin/systemctl
# get the gosu executable
COPY --from=builder ${COPY_DIR}/usr/local/bin/gosu /usr/local/bin/
# get the .bashrc and .env to configure the environment for all shells
COPY --from=proteus_builder_2 $PROTEUS_ROOT/docker/.bash* $PROTEUS_ROOT/docker/.env /home/${UNAME}/
COPY --from=proteus_builder_2 $PROTEUS_ROOT/docker/.root_bashrc /root/.bashrc
COPY --from=proteus_builder_2 $PROTEUS_ROOT/docker/.env /root/
# run any final commands before finishing the production image
RUN ldconfig
# we need to run as root because KServe mounts models to /mnt/models which means
# the server needs root access to access the mounted assets
ENTRYPOINT [ "/root/entrypoint.sh", "root" ]
CMD [ "proteus-server" ]