Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mount option for ci script #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .ci/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ docker build \
--tag ci-runner/ov-xai:latest .
```

The simplest way using its defaults
Or, the simplest way using build script

```bash
docker build --tag ci-runner/ov-xai:latest .
.ci/docker$ ./build.sh lastest
```

## How to run a container
Expand All @@ -24,7 +24,15 @@ docker run -d --rm \
--ipc=host \
-e RUNNER_REPO_URL="https://github.com/openvinotoolkit/openvino_xai" \
-e RUNNER_NAME="ci-runner-ov-xai" \
-e RUNNER_LABELS="hello,labels" \
-e RUNNER_LABELS="large-disk" \
-e RUNNER_TOKEN= \
ci-runner/ov-xai:latest
```

Or, using start script

```bash
.ci/docker$ ./start-runner.sh <gh-token>
```

Use `--help` option to see all available options to the script.
29 changes: 29 additions & 0 deletions .ci/docker/start-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ACTIONS_RUNNER_TAG="latest"
ACTIONS_RUNNER_NAME="ov-xai-ci-runner"
LABELS="large-disk"
MOUNT_PATH=""

POSITIONAL=()

Expand All @@ -25,6 +26,11 @@ while [[ $# -gt 0 ]]; do
shift # past argument
shift # past value
;;
-m|--mount)
MOUNT_PATH="$2"
shift # past argument
shift # past value
;;
-h|--help)
DEFAULT="yes"
break
Expand All @@ -48,19 +54,42 @@ cat << EndofMessage
-n|--name Specify actions-runner name to be registered to the repository
-l|--labels Additional label string to set the actions-runner
-t|--tag Specify docker image tag to create container
-m|--mount Specify data path on the host machine to mount to the runner container
-h|--help Print this message
EndofMessage
exit 0
fi

ENV_FLAGS=""
MOUNT_FLAGS=""

if [ "$MOUNT_PATH" != "" ]; then
echo "mount path option = $MOUNT_PATH"
ENV_FLAGS="-e CI_DATA_ROOT=/home/cibot/data"
MOUNT_FLAGS="-v $MOUNT_PATH:/home/cibot/data:ro"
LABELS="$LABELS,dmount"
fi

GITHUB_TOKEN=$1

docker inspect "$ACTIONS_RUNNER_NAME"; RET=$?

if [ $RET -eq 0 ]; then
# if the named container exsiting, stop and remove it first
docker stop "$ACTIONS_RUNNER_NAME"
# wait completely stopped the container
sleep 10
yes | docker rm "$ACTIONS_RUNNER_NAME"
fi

docker run -d --rm \
--ipc=host \
-e RUNNER_REPO_URL="https://github.com/openvinotoolkit/openvino_xai" \
-e RUNNER_NAME="$ACTIONS_RUNNER_NAME" \
-e RUNNER_LABELS="$LABELS" \
-e RUNNER_TOKEN="$GITHUB_TOKEN" \
${ENV_FLAGS} \
${MOUNT_FLAGS} \
--name "$ACTIONS_RUNNER_NAME" \
ci-runner/ov-xai:"$ACTIONS_RUNNER_TAG"; RET=$?

Expand Down
Loading