diff --git a/data/helpers/init.sh b/data/helpers/init.sh index f0c9621..2035fad 100644 --- a/data/helpers/init.sh +++ b/data/helpers/init.sh @@ -1,12 +1,10 @@ apk add jq curl -export VAULT_ADDR=http://localhost:8200 - root_token=$(cat /helpers/keys.json | jq -r '.root_token') unseal_vault() { export VAULT_TOKEN=$root_token - vault operator unseal -address=${VAULT_ADDR} $(cat /helpers/keys.json | jq -r '.keys[0]') + vault operator unseal -address=${VAULT_HOST} $(cat /helpers/keys.json | jq -r '.keys[0]') vault login token=$VAULT_TOKEN } @@ -16,7 +14,7 @@ then unseal_vault else echo "Vault not initialized" - curl -s --request POST --data '{"secret_shares": 1, "secret_threshold": 1}' http://${VAULT_ADDR}/v1/sys/init > /helpers/keys.json + curl -s --request POST --data '{"secret_shares": 1, "secret_threshold": 1}' ${VAULT_HOST}/v1/sys/init > /helpers/keys.json root_token=$(cat /helpers/keys.json | jq -r '.root_token') unseal_vault diff --git a/docker-compose.yaml b/docker-compose.yaml index 19b21c6..b7563ac 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -29,16 +29,14 @@ services: retries: 12 start_period: 10s timeout: 10s - # expose: - # - 8200 - ports: - - "8200:8200" + expose: + - 8200 networks: - vault_net - # - webproxy + - webproxy networks: vault_net: name: vault_net - # webproxy: - # name: webproxy + webproxy: + name: webproxy diff --git a/start.sh b/start.sh index 52e0a5e..fe4ed51 100755 --- a/start.sh +++ b/start.sh @@ -1,9 +1,16 @@ #!bin/bash +[[ ! -f .env ]] && { + echo "Please create .env file and put domain" + exit 1 +} + +source .env + docker compose up -d while [[ ! $(docker inspect -f {{.State.Health.Status}} vault) == "healthy" ]]; do sleep 0.5; done -docker exec vault /bin/sh -c "source /helpers/init.sh" +docker exec vault /bin/sh -c "export VAULT_HOST=${VAULT_HOST} && source /helpers/init.sh"