Skip to content

Commit

Permalink
fix: volume map to default Docker Deskotp file sharing (/Users) (#211)
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 7, 2024
1 parent dc3ae7d commit 3fc51d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
17 changes: 16 additions & 1 deletion packages/cardano-cli/files/cardano-cli.sh.gotmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash

declare -a valid_paths=(
"/Users"
"/Volumes"
"/private"
"/tmp"
"/var/folders"
)

_args=()

# Remap absolute paths to /host in the container
Expand All @@ -26,13 +34,20 @@ else
_docker_args+=( "-v" "{{ .Paths.ContextDir }}/node-ipc:/ipc" )
fi

if [[ $(uname -s) == Darwin ]]; then
for _path in "${_darwin_allowed_paths[@]}"; do
_docker_args+=( "-v" "${_path}:/host${_path}" )
done
else
_docker_args+=( "-v" "/:/host" )
fi

# Run cardano-cli via Docker
# We map the host filesystem and node socket into the container
docker run \
-ti \
--rm \
-u $(id -u):$(id -g) \
-v /:/host \
-w /host$(pwd) \
-e CARDANO_NODE_SOCKET_PATH=/ipc/node.socket \
"${_docker_args[@]}" \
Expand Down
20 changes: 17 additions & 3 deletions packages/mithril-client/files/mithril-client.sh.gotmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash

declare -a _darwin_allowed_paths=(
"/Users"
"/Volumes"
"/private"
"/tmp"
"/var/folders"
)

# setup options
_options=(${@})
for i in ${!_options[@]}; do
Expand Down Expand Up @@ -36,6 +44,13 @@ if [[ -z ${GENESIS_VERIFICATION_KEY} && -f ${GENESIS_VERIFICATION_KEY_PATH} ]];
fi

_docker_args=()
if [[ $(uname -s) == Darwin ]]; then
for _path in "${_darwin_allowed_paths[@]}"; do
_docker_args+=( "-v" "${_path}:/host${_path}" )
done
else
_docker_args+=( "-v" "/:/host" )
fi

# flatten options into args
for i in ${_options[@]}; do
Expand All @@ -49,11 +64,10 @@ docker run \
-ti \
--rm \
-u $(id -u):$(id -g) \
-v /:/host \
-w /host$(pwd) \
--entrypoint /bin/bash \
-e AGGREGATOR_ENDPOINT=${AGGREGATOR_ENDPOINT} \
-e GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY} \
-e AGGREGATOR_ENDPOINT="${AGGREGATOR_ENDPOINT}" \
-e GENESIS_VERIFICATION_KEY="${GENESIS_VERIFICATION_KEY}" \
"${_docker_args[@]}" \
ghcr.io/blinklabs-io/mithril-client:{{ .Package.Version }} \
-c "GENESIS_VERIFICATION_KEY=\${GENESIS_VERIFICATION_KEY:-\$(</opt/cardano/config/{{ .Context.Network }}/genesis.vkey)} /bin/mithril-client ${_args}"

0 comments on commit 3fc51d9

Please sign in to comment.