-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.proto
85 lines (69 loc) · 2.61 KB
/
Dockerfile.proto
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
# syntax=docker/dockerfile:1
ARG UBUNTU_VERSION=22.04
ARG TFSERVING_VERSION=2.9.0
ARG GRPC_VERSION=1.65.5
ARG PROTOBUF_VERSION=5.28.1
ARG SIX_VERSION=1.16.0
ARG GRPCIO_TOOLS_VERSION=1.65.5
# Build image, generates proto files
FROM --platform=linux/arm64/v8 ubuntu:${UBUNTU_VERSION} AS build-image
ARG TFSERVING_VERSION
ARG GRPC_VERSION
ARG PROTOBUF_VERSION
ARG SIX_VERSION
ARG GRPCIO_TOOLS_VERSION
RUN <<EOF
apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
git
rm -rf /var/lib/apt/lists/*
EOF
# grpcio-tools contains protoc, which allows to build the pb2.py files in the install-tf.sh script.
# Installing directly grpcio-tools result in an older version of protobuf.
RUN <<EOF
pip install --no-cache-dir \
grpcio==${GRPC_VERSION} \
protobuf==${PROTOBUF_VERSION} \
six==${SIX_VERSION}
pip install --no-dependencies \
grpcio-tools==${GRPCIO_TOOLS_VERSION}
EOF
# Build TensorFlow serving proto files
WORKDIR /build/tf
RUN <<EOF
git clone --depth 1 --branch v${TFSERVING_VERSION} https://github.com/tensorflow/tensorflow.git
git clone --depth 1 --branch ${TFSERVING_VERSION} https://github.com/tensorflow/serving.git
TF_DIR="./tensorflow"
TFS_DIR="./serving"
OUT_DIR="./proto_utils"
mkdir -p $OUT_DIR
PROTO_FILES="$TF_DIR/tensorflow/core/example/*.proto
$TF_DIR/tensorflow/core/framework/*.proto \
$TF_DIR/tensorflow/core/protobuf/*.proto \
$TFS_DIR/tensorflow_serving/apis/*.proto \
"
PROTO_FILES_GRPC="$TFS_DIR/tensorflow_serving/apis/predict.proto \
$TFS_DIR/tensorflow_serving/apis/prediction_service.proto \
"
python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --python_out="$OUT_DIR" $PROTO_FILES
python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --grpc_python_out="$OUT_DIR" $PROTO_FILES_GRPC
EOF
COPY apis/wrappers/tf_proto_utils.py ./proto_utils
#Build vdo proto
WORKDIR /build/vdo
COPY apis/videocapture.proto ./
RUN <<EOF
mkdir -p ./proto_utils
python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils videocapture.proto
EOF
COPY apis/wrappers/vdo_proto_utils.py ./proto_utils
# Build keyvalue proto
WORKDIR /build/param
COPY apis/keyvaluestore.proto ./
RUN <<EOF
mkdir -p ./proto_utils
python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils keyvaluestore.proto
EOF
# Saving required libraries versions into a file
RUN pip freeze | grep -E '^(grpcio|protobuf|six)==' > /build/requirements.txt