Skip to content

Commit

Permalink
fix(ci): makes share common env vars from dotenv file
Browse files Browse the repository at this point in the history
  • Loading branch information
nyannyacha committed Nov 7, 2024
1 parent 8a3a36c commit 79ec34a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 25 deletions.
8 changes: 3 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"name": "Rust",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"ONNXRUNTIME_VERSION": "1.19.2",
"DENO_VERSION": "1.45.2"
}
"context": ".."
},
"containerEnv": {
"PATH": "${localEnv:PATH}:/deno/bin"
Expand All @@ -16,6 +12,8 @@
"ghcr.io/jungaretti/features/make:1": {}
},
"runArgs": [
"--env-file",
"../.env",
"--rm",
"--privileged",
"--security-opt",
Expand Down
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GIT_V_TAG=0.1.1
ONNXRUNTIME_VERSION=1.19.2
DENO_VERSION=1.45.2
EDGE_RUNTIME_PORT=9998
AI_INFERENCE_API_HOST=http://localhost:11434
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
ORT_DYLIB_PATH: /usr/local/bin/libonnxruntime.so

jobs:
cargo-fmt:
Expand Down Expand Up @@ -49,4 +50,9 @@ jobs:
- uses: actions/checkout@v4
- run: rustup show
- uses: Swatinem/rust-cache@v2
- uses: cardinalby/export-env-action@v2
with:
envFile: ".env"
- name: Install ONNX Runtime Library
run: ./scripts/install_onnx.sh ${{ env.ONNXRUNTIME_VERSION }} x64 /usr/local/bin/libonnxruntime.so
- run: ./scripts/test.sh
12 changes: 10 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: cardinalby/export-env-action@v2
with:
envFile: ".env"
- id: build
uses: docker/build-push-action@v3
with:
Expand All @@ -61,7 +64,8 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_V_VERSION=${{ needs.release.outputs.version }}
GIT_V_TAG=${{ needs.release.outputs.version }}
ONNXRUNTIME_VERSION=${{ env.ONNXRUNTIME_VERSION }}
publish_arm:
needs:
Expand Down Expand Up @@ -95,6 +99,9 @@ jobs:
image=moby/buildkit:master
network=host
- uses: cardinalby/export-env-action@v2
with:
envFile: ".env"
- id: build
uses: docker/build-push-action@v3
with:
Expand All @@ -104,7 +111,8 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
no-cache: true
build-args: |
GIT_V_VERSION=${{ needs.release.outputs.version }}
GIT_V_TAG=${{ needs.release.outputs.version }}
ONNXRUNTIME_VERSION=${{ env.ONNXRUNTIME_VERSION }}
merge_manifest:
needs: [release, publish_x86, publish_arm]
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
FROM rust:1.79.0-bookworm as builder

ARG TARGETPLATFORM
ARG GIT_V_VERSION
ARG ONNXRUNTIME_VERSION=1.19.2
ARG GIT_V_TAG
ARG ONNXRUNTIME_VERSION
ARG PROFILE=release
ARG FEATURES

Expand All @@ -15,7 +15,7 @@ WORKDIR /usr/src/edge-runtime
COPY . .

RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --mount=type=cache,target=/usr/src/edge-runtime/target,id=${TARGETPLATFORM} \
GIT_V_TAG=${GIT_V_VERSION} cargo build --profile ${PROFILE} --features "${FEATURES}" && \
${GIT_V_TAG} cargo build --profile ${PROFILE} --features "${FEATURES}" && \
mv /usr/src/edge-runtime/target/${PROFILE}/edge-runtime /root

RUN objcopy --compress-debug-sections \
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_onnx.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

ONNX_VERSION=${1:-1.19.2}
ONNX_VERSION=$1
TARGETPLATFORM=$2
SAVE_PATH=${3:-"./onnx-runtime"}

Expand Down
7 changes: 4 additions & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

export $(grep -v '^#' ../.env | xargs)

# --features cli/tracing
GIT_V_TAG=0.1.1 cargo build --features cli/tracing && \
AI_INFERENCE_API_HOST=http://localhost:11434 \
EDGE_RUNTIME_PORT=9998 RUST_BACKTRACE=full ./target/debug/edge-runtime "$@" start \
cargo build --features cli/tracing && \
RUST_BACKTRACE=full ./target/debug/edge-runtime "$@" start \
--main-service ./examples/main \
--event-worker ./examples/event-manager
20 changes: 9 additions & 11 deletions scripts/run_dind.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env bash

GIT_V_TAG=0.1.1
EDGE_RUNTIME_PORT=9998
ONNXRUNTIME_VERSION=1.19.2
FEATURES=cli/tracing
RUST_BACKTRACE=full

Expand All @@ -11,15 +8,16 @@ PROFILE=${1:-dind}
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

cd "$SCRIPTPATH" &&
docker build \
-t edge_runtime \
--build-arg GIT_V_TAG=$GIT_V_TAG \
--build-arg ONNXRUNTIME_VERSION=$ONNXRUNTIME_VERSION \
--build-arg PROFILE=$PROFILE \
--build-arg FEATURES=$FEATURES \
"$SCRIPTPATH/.."
cd "$SCRIPTPATH"

docker build \
-t edge_runtime \
--env-file ../.env \
--build-arg PROFILE=$PROFILE \
--build-arg FEATURES=$FEATURES \
"$SCRIPTPATH/.."

export $(grep -v '^#' ../.env | xargs)
docker run \
--privileged \
--rm \
Expand Down

0 comments on commit 79ec34a

Please sign in to comment.