Files
dcu/dcuc
Filip Gołaś ac6ec86efb Add CI build & tests
test: Prepare for using in GH CI
test/approvals: Add approvals for CI
.github/workflows/tests.yml: Add CI workflow for testing dcuc

Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
2024-10-15 09:42:59 +02:00

41 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Dasharo Configuration Utility Container
SCRIPT_DIR=$(dirname "$(readlink -f ${BASH_SOURCE[0]})")
DOCKER_IMAGE="ghcr.io/dasharo/dasharo-sdk:v1.5.0"
# Initialize an array to store Docker arguments
DOCKER_ARGS=()
# Initialize an array to store the command to be executed in the container
COMMAND_ARGS=()
# Function to add a bind mount for a file
add_bind_mount() {
local FILE_PATH=$1
local ABS_PATH=""
local DIR_PATH=""
ABS_PATH=$(realpath "$FILE_PATH")
DIR_PATH=$(dirname "$ABS_PATH")
DOCKER_ARGS+=("-v" "$DIR_PATH:$DIR_PATH")
echo "$ABS_PATH"
}
# Iterate over the command line arguments
for ARG in "$@"; do
if [[ -f "$ARG" ]]; then
# Convert the file path to an absolute path and add a bind mount
ABS_PATH=$(add_bind_mount "$ARG")
COMMAND_ARGS+=("$ABS_PATH")
else
COMMAND_ARGS+=("$ARG")
fi
done
if [[ -v CI ]]; then
../dcu "${COMMAND_ARGS[@]}"
else
docker run -t --rm -v "${SCRIPT_DIR}:${SCRIPT_DIR}" "${DOCKER_ARGS[@]}" -w "${SCRIPT_DIR}" $DOCKER_IMAGE ./dcu "${COMMAND_ARGS[@]}"
fi