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 660f9d6 commit d6b6e68
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 31 deletions.
18 changes: 4 additions & 14 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
FROM mcr.microsoft.com/devcontainers/rust:dev-1-bookworm

ARG TARGETPLATFORM
ARG ONNXRUNTIME_VERSION
ARG DENO_VERSION

RUN apt-get update && apt-get install -y build-essential cmake libclang-dev lldb \
nodejs npm hyperfine

COPY .env /tmp/.env
COPY .devcontainer/install.sh /tmp/install.sh
COPY scripts/install_onnx.sh /tmp/install_onnx.sh
COPY scripts/download_models.sh /tmp/download_models.sh

WORKDIR /tmp
RUN ./install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /usr/local/bin/libonnxruntime.so
RUN ./download_models.sh
RUN mkdir -p /etc/sb_ai && cp -r /tmp/models /etc/sb_ai/models

ENV ORT_DYLIB_PATH=/usr/local/bin/libonnxruntime.so
ENV SB_AI_MODELS_DIR=/etc/sb_ai/models

# Ollama
RUN curl -fsSL https://ollama.com/install.sh | sh

# Deno
ENV DENO_INSTALL=/deno
RUN mkdir -p /deno \
&& curl -fsSL https://deno.land/install.sh | bash -s -- v$DENO_VERSION \
&& chown -R vscode /deno

RUN /tmp/install.sh $TARGETPLATFORM
20 changes: 20 additions & 0 deletions .devcontainer/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e

TARGETPLATFORM=$1

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

# ONNX Runtime
/tmp/install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /tmp/onnxruntime
mv /tmp/onnxruntime/lib/libonnxruntime.so* /usr/lib
/tmp/download_models.sh
mkdir -p /etc/sb_ai && cp -r /tmp/models /etc/sb_ai/models

# Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Deno
mkdir -p /deno
curl -fsSL https://deno.land/install.sh | bash -s -- v$DENO_VERSION
chown -R vscode /deno
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
GIT_V_TAG=0.1.0
ONNXRUNTIME_VERSION=1.19.2
DENO_VERSION=1.45.2
EDGE_RUNTIME_PORT=9998
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
ORT_DYLIB_PATH: /usr/local/bin/onnxruntime/lib/libonnxruntime.so
ORT_DYLIB_PATH: /usr/local/lib/onnxruntime/lib/libonnxruntime.so

jobs:
cargo-fmt:
Expand Down Expand Up @@ -54,5 +54,5 @@ jobs:
with:
envFile: ".env"
- name: Install ONNX Runtime Library
run: ./scripts/install_onnx.sh ${{ env.ONNXRUNTIME_VERSION }} x64 /usr/local/bin/onnxruntime
run: ./scripts/install_onnx.sh ${{ env.ONNXRUNTIME_VERSION }} x64 /usr/local/lib/onnxruntime
- run: ./scripts/test.sh
9 changes: 3 additions & 6 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_TAG
ARG ONNXRUNTIME_VERSION
ARG GIT_V_TAG
ARG PROFILE=release
ARG FEATURES

Expand Down Expand Up @@ -36,8 +36,6 @@ RUN apt-get remove -y perl && apt-get autoremove -y
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
COPY --from=builder /root/edge-runtime.debug /usr/local/bin/edge-runtime.debug

ENV ORT_DYLIB_PATH=/usr/local/bin/onnxruntime/lib/libonnxruntime.so


# ONNX Runtime provider
# Application runtime with ONNX
Expand All @@ -60,10 +58,9 @@ FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as edge-runtime-cuda

COPY --from=edge-runtime-base /usr/local/bin/edge-runtime /usr/local/bin/edge-runtime
COPY --from=builder /root/edge-runtime.debug /usr/local/bin/edge-runtime.debug
COPY --from=ort-cuda /root/onnxruntime /usr/local/bin/onnxruntime
COPY --from=ort-cuda /root/onnxruntime/lib/libonnxruntime.so* /usr/lib
COPY --from=preload-models /usr/src/edge-runtime/models /etc/sb_ai/models

ENV ORT_DYLIB_PATH=/usr/local/bin/onnxruntime/lib/libonnxruntime.so
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility

Expand All @@ -72,7 +69,7 @@ ENTRYPOINT ["edge-runtime"]

# Base
FROM edge-runtime-base as edge-runtime
COPY --from=ort /root/onnxruntime /usr/local/bin/onnxruntime
COPY --from=ort /root/onnxruntime/lib/libonnxruntime.so* /usr/lib
COPY --from=preload-models /usr/src/edge-runtime/models /etc/sb_ai/models

ENTRYPOINT ["edge-runtime"]
6 changes: 5 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -e

export $(grep -v '^#' ../.env | xargs)
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

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

# --features cli/tracing
cargo build --features cli/tracing && \
Expand Down
10 changes: 4 additions & 6 deletions scripts/run_dind.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env bash
set -e

FEATURES=cli/tracing
RUST_BACKTRACE=full

PWD=$(pwd)
PROFILE=${1:-dind}
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

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

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

export $(grep -v '^#' ../.env | xargs)
docker run \
--privileged \
--rm \
Expand All @@ -34,5 +34,3 @@ docker run \
--main-service ./examples/main \
--event-worker ./examples/event-manager \
--static "./examples/**/*.bin"

cd $PWD
2 changes: 1 addition & 1 deletion scripts/test_indefinitely.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ while true; do
fi

echo "Tests passed. Running again..."
done
done

0 comments on commit d6b6e68

Please sign in to comment.