Skip to content

Commit

Permalink
fix: volume map to default Docker Deskotp file sharing (/Users)
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <verbotenj@blinklabs.io>
  • Loading branch information
verbotenj committed May 5, 2024
1 parent ed0c041 commit 1d1b8a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
14 changes: 10 additions & 4 deletions packages/cardano-cli/files/cardano-cli.sh.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ _args=()
# Remap absolute paths to /host in the container
while [[ $# -gt 0 ]]; do
_arg=$1
# If the path starts with / and begins with $HOME, remap it to /host
if [[ $_arg =~ ^/ ]]; then
_arg="/host${_arg}"
if [[ "$_arg" == "$HOME"* ]]; then
_arg="/host${_arg#$HOME}"
else
echo "Warning: Path $_arg is outside of the mounted home directory"
_arg="/host$_arg"
fi
fi
_args+=( $_arg )
shift
Expand All @@ -27,13 +33,13 @@ else
fi

# Run cardano-cli via Docker
# We map the host filesystem and node socket into the container
# We map the $HOME and node socket into the container
docker run \
-ti \
--rm \
-u $(id -u):$(id -g) \
-v /:/host \
-w /host$(pwd) \
-v $HOME:/host \
-w /host$(pwd | sed "s:^$HOME::") \
-e CARDANO_NODE_SOCKET_PATH=/ipc/node.socket \
"${_docker_args[@]}" \
ghcr.io/blinklabs-io/cardano-cli:{{ .Package.Version }} \
Expand Down
23 changes: 15 additions & 8 deletions packages/mithril-client/files/mithril-client.sh.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ for i in ${!_options[@]}; do
v=${_options[j]}
_found=false
# remap absolute paths to /host in the container
if [[ ${k} =~ ^/ ]]; then
k="/host${k}"
_options[i]=${k};
continue
fi
# Remap absolute paths to /host in the container if they start with /
if [[ "$k" =~ ^/ ]]; then
# If the path starts with $HOME, replace it with /host
if [[ "$k" == "$HOME"* ]]; then
k="/host${k#$HOME}"
else
echo "Warning: Path $k is outside of the mounted home directory"
k="/host${k}"
fi
_options[i]="$k"
continue
fi
case ${k} in
--aggregator-endpoint) AGGREGATOR_ENDPOINT=${v}; _found=true ;;
--genesis-verification-key) GENESIS_VERIFICATION_KEY=${v}; _found=true ;;
Expand Down Expand Up @@ -44,13 +51,13 @@ done
_args=$(echo ${_args} | sed -e 's/^ //')

# Run mithril-client-cli via Docker
# We map the host filesystem into the container
# We map the $HOME into the container
docker run \
-ti \
--rm \
-u $(id -u):$(id -g) \
-v /:/host \
-w /host$(pwd) \
-v $HOME:/host \
-w /host$(pwd | sed "s:^$HOME::") \
--entrypoint /bin/bash \
-e AGGREGATOR_ENDPOINT=${AGGREGATOR_ENDPOINT} \
-e GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY} \
Expand Down

0 comments on commit 1d1b8a2

Please sign in to comment.