diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b0f18f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +secrets/** +!secrets/settings_pattern.json \ No newline at end of file diff --git a/README.md b/README.md index 6f520f3..b3f56c3 100644 --- a/README.md +++ b/README.md @@ -8,24 +8,30 @@ No clearnet for i2p, only yggdrasil! At startup, the script searches YGGDRASIL public peers and chooses several best of them. Then it generates YGGDRASIL *PublicKey* and *PrivateKey* unless the keys not set in environment variables. +## Preparations + +Before building and deploying i2pd_yggdrasil docker image, you need to run the script + +> bash support/requirements.sh + ## Building You can build docker image by simply run script *make_i2pd_yggdrasil_docker_image.sh*. -> bash make_i2pd_yggdrasil_docker_image.sh +> bash support/make_docker_image.sh Feel free to modify it with your own building arguments. ## Running -To run docker container just run script *run_i2pd_yggdrasil_docker_image.sh* +To run docker container just use docker-compose like this -> bash run_i2pd_yggdrasil_docker_image.sh +> docker-compose -f src/docker-compose.yml up -d ## Deploy -To deploy built image to your host just execute this from command line +To deploy built image to your host use script -> docker save i2pd_yggdrasil:latest | bzip2 | pv | ssh user@host docker load +> bash support/docker_deploy.sh -> scp run_i2pd_yggdrasil_docker_image.sh user@host:. \ No newline at end of file +Note, this script takes parameters from *secrets/settings.json*, look *secrets/settings_pattern.json* for example. \ No newline at end of file diff --git a/secrets/settings_pattern.json b/secrets/settings_pattern.json new file mode 100644 index 0000000..03fbaac --- /dev/null +++ b/secrets/settings_pattern.json @@ -0,0 +1,8 @@ +{ + "deploy" : + { + "host" : "0.0.0.0", + "user" : "root", + "path" : "/opt" + } +} \ No newline at end of file diff --git a/src/docker-compose.yml b/src/docker-compose.yml index db49936..eb240f0 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -21,4 +21,4 @@ services: - "10765:10765" - "10654:10654" - "9001:9001" - \ No newline at end of file + restart: always \ No newline at end of file diff --git a/support/docker_deploy.sh b/support/docker_deploy.sh new file mode 100644 index 0000000..9b7e9a6 --- /dev/null +++ b/support/docker_deploy.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "Deploy i2pd yggdrasil" +host=$(cat secrets/settings.json | jq -r .deploy.host) +user=$(cat secrets/settings.json | jq -r .deploy.user) +path=$(cat secrets/settings.json | jq -r .deploy.path) +echo " stop docker container" +ssh -l ${user} ${host} "cd ${path} ; docker-compose down" +echo " upload docker images" +ssh ${user}@${host} "mkdir -p ${path}" +docker save i2pd_yggdrasil:latest | bzip2 | pv | ssh ${user}@${host} docker load +echo " upload docker compose" +scp src/docker-compose.yml ${user}@${host}:${path} +echo " start docker container" +ssh -l ${user} ${host} "cd ${path} ; docker-compose up -d" +echo " all done" diff --git a/support/requirements.sh b/support/requirements.sh new file mode 100644 index 0000000..05325d7 --- /dev/null +++ b/support/requirements.sh @@ -0,0 +1 @@ +sudo apt install pv jq \ No newline at end of file