From 9640d82908dfea465a5f5b798c4b8416db7550c1 Mon Sep 17 00:00:00 2001 From: Roman Meshko Date: Mon, 4 May 2026 23:01:20 +0300 Subject: [PATCH] Push model to docker registry --- e2e/engine-artifact.Dockerfile | 5 ++++ e2e/scripts/publish_jetson_engine.sh | 43 ++++++++++++++++++++++++++++ e2e/scripts/pull_jetson_engine.sh | 28 ++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 e2e/engine-artifact.Dockerfile create mode 100644 e2e/scripts/publish_jetson_engine.sh create mode 100644 e2e/scripts/pull_jetson_engine.sh diff --git a/e2e/engine-artifact.Dockerfile b/e2e/engine-artifact.Dockerfile new file mode 100644 index 0000000..1d43e4c --- /dev/null +++ b/e2e/engine-artifact.Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:3.20 + +COPY . /models/ + +CMD ["sh"] diff --git a/e2e/scripts/publish_jetson_engine.sh b/e2e/scripts/publish_jetson_engine.sh new file mode 100644 index 0000000..8b41a64 --- /dev/null +++ b/e2e/scripts/publish_jetson_engine.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -euo pipefail + +COMPOSE="${COMPOSE:-docker compose -f docker-compose.test.yml --profile jetson}" +REGISTRY_HOST="${REGISTRY_HOST:?REGISTRY_HOST is required}" +ENGINE_REPOSITORY="${JETSON_ENGINE_REPOSITORY:-$REGISTRY_HOST/azaion/detections-jetson-engine}" +BRANCH="${CI_COMMIT_BRANCH:-local}" +ENGINE_TAG="${JETSON_ENGINE_TAG:-$(printf '%s' "$BRANCH" | tr -c 'A-Za-z0-9_.-' '-')}" +OUT_DIR="${JETSON_ENGINE_OUT_DIR:-results/jetson-engine}" + +mkdir -p "$OUT_DIR/models" + +loader_id="$($COMPOSE ps -q mock-loader)" +if [[ -z "$loader_id" ]]; then + echo "ERROR: mock-loader container is not running" + exit 1 +fi + +docker cp "$loader_id:/models/models/." "$OUT_DIR/models/" +find "$OUT_DIR/models" -maxdepth 1 -type f ! -name 'azaion*.engine' -delete + +engine_count="$(find "$OUT_DIR/models" -maxdepth 1 -type f -name 'azaion*.engine' | wc -l | tr -d ' ')" +if [[ "$engine_count" == "0" ]]; then + echo "ERROR: no converted TensorRT engine found in mock-loader /models/models" + find "$OUT_DIR/models" -maxdepth 2 -type f -print + exit 1 +fi + +echo "--- Converted TensorRT engine files:" +find "$OUT_DIR/models" -maxdepth 1 -type f -name 'azaion*.engine' -print -exec ls -lh {} \; + +image="$ENGINE_REPOSITORY:$ENGINE_TAG" +echo "--- Building Jetson engine artifact image: $image" +docker build -f engine-artifact.Dockerfile -t "$image" "$OUT_DIR/models" +docker push "$image" + +if [[ -n "${CI_COMMIT_SHA:-}" ]]; then + sha_tag="$(printf '%s' "$CI_COMMIT_SHA" | cut -c1-12)" + docker tag "$image" "$ENGINE_REPOSITORY:$sha_tag" + docker push "$ENGINE_REPOSITORY:$sha_tag" +fi + +echo "--- Published Jetson engine artifact image: $image" diff --git a/e2e/scripts/pull_jetson_engine.sh b/e2e/scripts/pull_jetson_engine.sh new file mode 100644 index 0000000..43673ef --- /dev/null +++ b/e2e/scripts/pull_jetson_engine.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ -z "${REGISTRY_HOST:-}" ]]; then + echo "--- REGISTRY_HOST is not set; skipping Jetson engine artifact pull" + exit 0 +fi + +ENGINE_REPOSITORY="${JETSON_ENGINE_REPOSITORY:-$REGISTRY_HOST/azaion/detections-jetson-engine}" +BRANCH="${CI_COMMIT_BRANCH:-local}" +ENGINE_TAG="${JETSON_ENGINE_TAG:-$(printf '%s' "$BRANCH" | tr -c 'A-Za-z0-9_.-' '-')}" +TARGET_DIR="${JETSON_ENGINE_TARGET_DIR:-fixtures/models}" +image="$ENGINE_REPOSITORY:$ENGINE_TAG" + +echo "--- Pulling Jetson engine artifact image: $image" +if ! docker pull "$image"; then + echo "--- Jetson engine artifact image not found; smoke will use ONNX fallback" + exit 0 +fi + +cid="$(docker create "$image")" +trap 'docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT + +mkdir -p "$TARGET_DIR" +docker cp "$cid:/models/." "$TARGET_DIR/" + +echo "--- Installed Jetson engine files:" +find "$TARGET_DIR" -maxdepth 1 -type f -name 'azaion*.engine' -print -exec ls -lh {} \;