This commit is contained in:
Vassiliy Yegorov
2022-07-28 01:01:40 +07:00
parent b38288eba7
commit 2edf95fe70
3 changed files with 15 additions and 12 deletions

View File

@@ -1,12 +1,10 @@
apk add jq curl apk add jq curl
export VAULT_ADDR=http://localhost:8200
root_token=$(cat /helpers/keys.json | jq -r '.root_token') root_token=$(cat /helpers/keys.json | jq -r '.root_token')
unseal_vault() { unseal_vault() {
export VAULT_TOKEN=$root_token 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 vault login token=$VAULT_TOKEN
} }
@@ -16,7 +14,7 @@ then
unseal_vault unseal_vault
else else
echo "Vault not initialized" 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') root_token=$(cat /helpers/keys.json | jq -r '.root_token')
unseal_vault unseal_vault

View File

@@ -29,16 +29,14 @@ services:
retries: 12 retries: 12
start_period: 10s start_period: 10s
timeout: 10s timeout: 10s
# expose: expose:
# - 8200 - 8200
ports:
- "8200:8200"
networks: networks:
- vault_net - vault_net
# - webproxy - webproxy
networks: networks:
vault_net: vault_net:
name: vault_net name: vault_net
# webproxy: webproxy:
# name: webproxy name: webproxy

View File

@@ -1,9 +1,16 @@
#!bin/bash #!bin/bash
[[ ! -f .env ]] && {
echo "Please create .env file and put domain"
exit 1
}
source .env
docker compose up -d docker compose up -d
while [[ ! $(docker inspect -f {{.State.Health.Status}} vault) == "healthy" ]]; do while [[ ! $(docker inspect -f {{.State.Health.Status}} vault) == "healthy" ]]; do
sleep 0.5; sleep 0.5;
done 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"