Skip to content

Commit 444a334

Browse files
Angelo DelliSantijohan-olsson-work
Angelo DelliSanti
authored andcommitted
Moving proto-build to ACAP runtime
1 parent 7c63884 commit 444a334

File tree

8 files changed

+448
-4
lines changed

8 files changed

+448
-4
lines changed

.github/actions/docker-build-push-action/action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ inputs:
6363
description: List of output destinations (format type=local,dest=path)
6464
required: false
6565
default: ''
66+
platform:
67+
description: "Target platform for the build (e.g., linux/amd64, linux/arm64)"
68+
required: false
69+
default: ''
6670

6771
runs:
6872
using: composite
@@ -94,3 +98,4 @@ runs:
9498
target: ${{ inputs.target }}
9599
provenance: ${{ inputs.provenance }}
96100
outputs: ${{ inputs.outputs }}
101+
platforms: ${{ inputs.platform }}

.github/workflows/build-proto-image.yml

+94-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,104 @@
33
name: Proto Build Workflow
44

55
on:
6-
workflow_dispatch:
6+
push:
7+
branches:
8+
- "main"
9+
tags:
10+
# semver, e.g. 1.2.0 (does not match 0.1.2)
11+
- "[1-9]+.[0-9]+.[0-9]+"
12+
# semver with prerelease info, e.g. 1.0.2-beta.1 or 1.2.3-rc.10
13+
- "[1-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+"
14+
# do not match prerelease starting w/ 0, e.g. 1.0.2-beta.0 or 1.2.3-rc.01
15+
- "![1-9]+.[0-9]+.[0-9]+-[a-z]+.[0]*"
16+
# semver with date info, e.g. 1.0.2-20221125
17+
- "[1-9]+.[0-9]+.[0-9]+-[0-9]+"
18+
# do not match date starting w/ 0, e.g. 1.0.2-01232023
19+
- "![1-9]+.[0-9]+.[0-9]+-[0]*"
720
pull_request:
21+
paths-ignore:
22+
# do not run if only markdown or other administrative files have been updated
23+
- "*.md"
24+
- "CODEOWNERS"
25+
- "LICENSE"
826
branches:
927
- "main"
1028

1129
jobs:
12-
dummy:
30+
build_proto_image:
31+
name: Build Proto Image
1332
runs-on: ubuntu-latest
33+
1434
steps:
15-
- run: echo "Placeholder workflow"
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Create image metadata
39+
id: meta
40+
uses: ./.github/actions/metadata-action
41+
with:
42+
repository: axisecp/acap-runtime
43+
get_version: "true"
44+
45+
- name: Build Proto image
46+
uses: ./.github/actions/docker-build-push-action
47+
with:
48+
dockerfile: ./Dockerfile.proto
49+
push: false
50+
load: true
51+
tags: axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles
52+
use_qemu: true
53+
platform: linux/arm64
54+
55+
- name: Extract proto files
56+
run: |
57+
container_id=$(docker create --platform linux/arm64 axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles)
58+
docker cp $container_id:/build/param/proto_utils ./proto_utils_param
59+
docker cp $container_id:/build/vdo/proto_utils ./proto_utils_vdo
60+
docker cp $container_id:/build/tf/proto_utils ./proto_utils_tf
61+
docker rm $container_id
62+
63+
- name: Verify proto files
64+
run: |
65+
echo "Verifying proto files..."
66+
67+
# Check param proto files
68+
if [ "$(ls -A ./proto_utils_param)" ]; then
69+
echo "param proto files found:"
70+
ls -l ./proto_utils_param
71+
else
72+
echo "Error: param proto files are missing"
73+
exit 1
74+
fi
75+
76+
# Check vdo proto files
77+
if [ "$(ls -A ./proto_utils_vdo)" ]; then
78+
echo "vdo proto files found:"
79+
ls -l ./proto_utils_vdo
80+
else
81+
echo "Error: vdo proto files are missing"
82+
exit 1
83+
fi
84+
85+
# Check tf proto files
86+
if [ "$(ls -A ./proto_utils_tf)" ]; then
87+
echo "tf proto files found:"
88+
ls -l ./proto_utils_tf
89+
else
90+
echo "Error: tf proto files are missing"
91+
exit 1
92+
fi
93+
94+
echo "All proto files verified successfully"
95+
96+
- name: Push Proto image
97+
if: success()
98+
uses: ./.github/actions/docker-build-push-action
99+
with:
100+
dockerfile: ./Dockerfile.proto
101+
push: true
102+
platform: linux/arm64
103+
use_qemu: true
104+
tags: axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles
105+
registry_user: ${{ secrets.ECOSYSTEM_SERVICE_USER_DOCKER_HUB }}
106+
registry_token: ${{ secrets.ECOSYSTEM_ACCESS_TOKEN_DOCKER_HUB }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.github/test/__pycache__/
33
apis/
44
!apis/keyvaluestore.proto
5+
!apis/wrappers
56
build/
67
build_x86_64-linux-gnu/
78
larod/

Dockerfile.proto

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG UBUNTU_VERSION=22.04
4+
ARG TFSERVING_VERSION=2.9.0
5+
ARG GRPC_VERSION=1.46.3
6+
ARG PROTOBUF_VERSION=4.21.1
7+
ARG SIX_VERSION=1.16.0
8+
ARG GRPCIO_TOOLS_VERSION=1.47.0
9+
10+
# Build image, generates proto files
11+
FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS build-image
12+
13+
ARG TFSERVING_VERSION
14+
ARG GRPC_VERSION
15+
ARG PROTOBUF_VERSION
16+
ARG SIX_VERSION
17+
ARG GRPCIO_TOOLS_VERSION
18+
19+
RUN <<EOF
20+
apt-get update && apt-get install -y --no-install-recommends \
21+
python3 \
22+
python3-pip \
23+
git
24+
rm -rf /var/lib/apt/lists/*
25+
EOF
26+
27+
# grpcio-tools contains protoc, which allows to build the pb2.py files in the install-tf.sh script.
28+
# Installing directly grpcio-tools result in an older version of protobuf.
29+
RUN <<EOF
30+
pip install --no-cache-dir \
31+
grpcio==${GRPC_VERSION} \
32+
protobuf==${PROTOBUF_VERSION} \
33+
six==${SIX_VERSION}
34+
pip install --no-dependencies \
35+
grpcio-tools==${GRPCIO_TOOLS_VERSION}
36+
EOF
37+
38+
# Build TensorFlow serving proto files
39+
WORKDIR /build/tf
40+
41+
RUN <<EOF
42+
git clone --depth 1 --branch v${TFSERVING_VERSION} https://github.com/tensorflow/tensorflow.git
43+
git clone --depth 1 --branch ${TFSERVING_VERSION} https://github.com/tensorflow/serving.git
44+
45+
TF_DIR="./tensorflow"
46+
TFS_DIR="./serving"
47+
OUT_DIR="./proto_utils"
48+
49+
mkdir -p $OUT_DIR
50+
51+
PROTO_FILES="$TF_DIR/tensorflow/core/example/*.proto
52+
$TF_DIR/tensorflow/core/framework/*.proto \
53+
$TF_DIR/tensorflow/core/protobuf/*.proto \
54+
$TFS_DIR/tensorflow_serving/apis/*.proto \
55+
"
56+
57+
PROTO_FILES_GRPC="$TFS_DIR/tensorflow_serving/apis/predict.proto \
58+
$TFS_DIR/tensorflow_serving/apis/prediction_service.proto \
59+
"
60+
61+
python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --python_out="$OUT_DIR" $PROTO_FILES
62+
python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --grpc_python_out="$OUT_DIR" $PROTO_FILES_GRPC
63+
EOF
64+
65+
COPY apis/wrappers/tf_proto_utils.py ./proto_utils
66+
67+
#Build vdo proto
68+
WORKDIR /build/vdo
69+
COPY apis/videocapture.proto ./
70+
RUN <<EOF
71+
mkdir -p ./proto_utils
72+
python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils videocapture.proto
73+
EOF
74+
COPY apis/wrappers/vdo_proto_utils.py ./proto_utils
75+
76+
# Build keyvalue proto
77+
WORKDIR /build/param
78+
COPY apis/keyvaluestore.proto ./
79+
RUN <<EOF
80+
mkdir -p ./proto_utils
81+
python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils keyvaluestore.proto
82+
EOF
83+
84+
# Saving required libraries versions into a file
85+
RUN pip freeze | grep -E '^(grpcio|protobuf|six)==' > /build/requirements.txt

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ If you are new to the world of ACAPs take a moment to check out
2727
- [gRPC socket](#grpc-socket)
2828
- [Examples](#examples)
2929
- [Building ACAP Runtime](#building-acap-runtime)
30+
- [Building protofiles for Python](#building-protofiles-for-python)
3031
- [Test suite](#test-suite)
3132
- [Contributing](#contributing)
3233
- [License](#license)
@@ -234,6 +235,16 @@ docker buildx build --file Dockerfile --build-arg ARCH=<ARCH> --tag acap-runtime
234235
235236
where `<ARCH>` is either `armv7hf` or `aarch64`.
236237
238+
## Building protofiles for Python
239+
240+
The repository includes a Dockerfile (`Dockerfile.proto`) for building the APIs protofiles for Python. The Dockerfile generates the necessary Python files from the protobuf definitions, allowing gRPC communication with the ACAP Runtime service. This means that applications can copy these prebuilt files from ACAP Runtime container image instead of having to build the protofiles themselves.
241+
242+
To build the protofiles:
243+
244+
```sh
245+
docker build -f Dockerfile.proto -t acap-runtime-proto:latest .
246+
```
247+
237248
## Test suite
238249
239250
The repo contains a test suite project to verify that ACAP Runtime works as expected

apis/keyvaluestore.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

0 commit comments

Comments
 (0)