Skip to content

Commit

Permalink
Minor enhancements (#143)
Browse files Browse the repository at this point in the history
* feat: specify workdir for container

* feat: add .env file generation, backup existing config
  • Loading branch information
maroskukan authored Feb 1, 2024
1 parent d6246cf commit 5ed081e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/examples/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ First, define a function and export it. This could be done in your environment s
function medusa(){
docker run \
-v $(pwd):/tmp/output/ \
-w /tmp/output/ \
--user $(id -u):$(id -u) \
-e VAULT_ADDR=$VAULT_ADDR \
-e VAULT_TOKEN=$VAULT_TOKEN \
Expand All @@ -27,6 +28,10 @@ VAULT_TOKEN=00000000-0000-0000-0000-000000000000

And now you are ready to run medusa like this

```
medusa import medusa import secret ./test/data/import-example-1.yaml
```

```
medusa export secret/A
A:
Expand Down
11 changes: 10 additions & 1 deletion scripts/start-vault.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ VAULT_IP=$(docker inspect vault --format='{{range .NetworkSettings.Networks}}{{.
echo "Vault container ip is : $VAULT_IP"

# Run a `Vault status` to check if it is alive
docker run --network=container:vault --cap-add IPC_LOCK -e VAULT_ADDR=https://$VAULT_IP:8201 -e VAULT_SKIP_VERIFY=true --rm vault:latest vault status
docker run --network=container:vault --cap-add IPC_LOCK -e VAULT_ADDR=https://$VAULT_IP:8201 -e VAULT_SKIP_VERIFY=true --rm hashicorp/vault:latest vault status

# Echo help on how to interact with Vault from the same host
echo "
Expand All @@ -59,10 +59,19 @@ To run vault commands, use the following docker command:
"

# Generate .env file
echo "Generating .env file"
echo -e "VAULT_ADDR=$VAULT_ADDR\nVAULT_SKIP_VERIFY=true\nVAULT_TOKEN=$VAULT_TOKEN" > .env

# Cleanup the temp folder
if [ ! -d "~/.medusa" ]; then
mkdir -p ~/.medusa
fi

if [ -f "$HOME/.medusa/config.yaml" ]; then
echo "Backing up existing Medusa config file"
cp ~/.medusa/config.yaml{,_backup}
fi

echo "Generating Medusa config file"

echo "VAULT_ADDR: $VAULT_ADDR
Expand Down

0 comments on commit 5ed081e

Please sign in to comment.