Skip to content
Open
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
20 changes: 11 additions & 9 deletions dcuc
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ COMMAND_ARGS=()
# Function to add a bind mount for a file
add_bind_mount() {
local FILE_PATH=$1
local ABS_PATH=""
local DIR_PATH=""
local ABS_PATH
ABS_PATH=$(realpath "$FILE_PATH")
DIR_PATH=$(dirname "$ABS_PATH")
DOCKER_ARGS+=("-v" "$DIR_PATH:$DIR_PATH")
echo "$ABS_PATH"
FILENAME="$(basename "$ABS_PATH")"
DOCKER_ARGS+=( '-v' "$ABS_PATH":/"${FILENAME}" )
}

# 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")
if [[ -v CI ]]; then
COMMAND_ARGS+=("$(realpath "$ARG")")
else
# Convert the file path to an absolute path and add a bind mount
add_bind_mount "$ARG"
COMMAND_ARGS+=("/$FILENAME")
fi
else
COMMAND_ARGS+=("$ARG")
fi
Expand All @@ -38,4 +40,4 @@ 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
fi
Loading