├── .gitignore
├── CNAME
├── install.sh
├── readme.md
└── setup.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | nano-node-monitor/config.php
2 | nano-node-watchdog/.idea/*
3 | nano-node-watchdog/*/*.log
4 | /docker-compose.generated.yml
5 | /docker-compose.generated.yml-e
6 | /nano-node-monitor/config.php-e
7 | /settings
8 | /nano-node/
9 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | docker.nano.to
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | git clone https://github.com/fwd/nano-docker.git
2 | cd nano-docker && sudo ./setup.sh -f -t V28
3 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 |
5 | 
6 |
7 | ## ❯ Quick
8 |
9 | ```bash
10 | curl -sL "http://docker.nano.to/install.sh" | sh
11 | ```
12 |
13 | 
14 |
15 | ## ❯ Custom
16 |
17 | ```bash
18 | git clone https://github.com/fwd/nano-docker.git
19 | ```
20 |
21 | ```bash
22 | cd nano-docker && sudo ./setup.sh -f -t V28 -m -p 8080
23 | ```
24 |
25 | #### Flags
26 | - **-f**: Fast Sync (Default: True)
27 | - **-t**: Node Version (Default: Latest)
28 | - **-m**: Node [Monitor](https://github.com/NanoTools/nanoNodeMonitor) (Default: False)
29 | - **-p**: Node Monitor Port (Default: 80)
30 | - **-q**: Console Output (Default: False)
31 | - **-s**: Print Private Key (Default: False)
32 | - **-v**: Alias of **-t**. Because life.
33 |
34 | 
35 |
36 | ## Requirements
37 |
38 | **Software:**
39 |
40 | - Ubuntu/Debian ✅
41 | - Other Linux ❌
42 | - Mac ❌ (Run Ubuntu in VM)
43 | - Window ❌ (Run Ubuntu in VM)
44 |
45 | **Minimum Hardware:**
46 |
47 | - 4 CPU
48 | - 8GB RAM
49 | - 320 GB SSD (Ledger: ~110GB 7Zip, Expandable attached storage recommended)
50 | - 1TB BANDWIDTH
51 | - ON 24/7
52 |
53 | 
54 |
55 | ## Sponsor (DigitalOcean)
56 |
57 |
59 |
60 | 
61 |
62 | Optional Reading: [How To Setup a Server on Digital Ocean](https://docs.digitalocean.com/products/droplets/how-to/create/)
63 |
64 | ---
65 |
66 | ### Understand The Magic 🪄 (Optional)
67 |
68 | #### 1. Install [Docker](https://docs.docker.com/engine/install/ubuntu)
69 |
70 | ```bash
71 | # Install Basic Tools
72 | sudo apt-get -y install jq curl p7zip-full
73 |
74 | # Add Docker PGP Key
75 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
76 |
77 | # Add Remote Docker Repo
78 | echo \
79 | "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
80 | $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
81 |
82 | # Run Update (Fetch latest packages)
83 | sudo apt-get update
84 |
85 | # Finally, Install Docker and Dependencies.
86 | sudo apt-get -y install jq docker-ce docker-ce-cli containerd.io
87 | ```
88 |
89 | #### 2. Install [Docker Compose](https://docs.docker.com/compose/)
90 |
91 | ```bash
92 | # Download latest script.
93 | curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
94 |
95 | # Make it executable
96 | sudo chmod +x /usr/local/bin/docker-compose
97 |
98 | # Make it a global
99 | sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
100 | ```
101 |
102 | #### 3. Install This Repo
103 |
104 | ```bash
105 | # Move to HOME, and clone repo
106 | cd ~ && git clone https://github.com/fwd/nano-docker.git
107 |
108 | # For "Docker" reasons. We need to move in the cloned dir.
109 | cd ~/nano-docker
110 |
111 | # Leave -v blank for latest version
112 | sudo ./setup.sh -s
113 | ```
114 |
115 | #### 4. Configure Node
116 |
117 | - [Unlock](https://docs.nano.org/running-a-node/wallet-setup/#update-configuration) Wallet RPC.
118 | - Set up Node on localhost port 7076. Use '[::1]:7076' for IPv6.
119 | - Node Websocket set up on localhost port 7078. Use '[::1]:7078' for IPv6.
120 | - **Node **not** accessible from Internet. Bring your own "Proxy".**
121 | - See [setup.sh](/setup.sh) for complete setup script.
122 |
123 | #### 5. Talk to Node
124 |
125 | ```bash
126 | Usage:
127 | $ curl -g -d '{ "action": "version" }' '[::1]:7076'
128 | $ curl -g -d '{ "action": "block_count" }' '[::1]:7076'
129 | $ curl -g -d '{ "action": "telemetry" }' '[::1]:7076'
130 | ```
131 |
132 | #### Node Docker IP
133 |
134 | ```
135 | docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
136 | ```
137 |
138 | ```
139 | nano-node - 172.XX.X.X
140 | ```
141 |
142 | ## Further Reading
143 |
144 | - [Official Node CLI Docs](https://docs.nano.org/commands/rpc-protocol)
145 | - [Common RPC Errors](https://docs.nano.to/rpc-errors)
146 | - [Nano.to Docs](https://docs.nano.to)
147 | - [**More Packages**](https://github.com/fwd/nano-packages)
148 |
149 | 
150 |
151 | ## Contributing
152 |
153 | Give a ⭐️ if this project helped you!
154 |
155 | Contributions, issues and feature requests are welcome at [issues page](https://github.com/fwd/nano-docker/issues).
156 |
157 | 
158 |
159 | ## Nano.to Support
160 |
161 | - Email: support@nano.to
162 | - Twitter: [@nano2dev](https://twitter.com/nano2dev)
163 | - Discord: [Nano.to Discord](https://discord.gg/HgqDCkzP)
164 |
165 | 
166 |
167 | ## License
168 |
169 | MIT License
170 |
171 | Copyright [@nano2dev](https://twitter.com/nano2dev).
172 |
173 | 
174 |
175 | ## ❯ Stargazers
176 |
177 | [](https://starchart.cc/fwd/nano-docker)
178 |
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################ORIGINAL#####################
4 | # NANO Node Docker #
5 | # https://github.com/lephleg/nano-node-docker #
6 | #################################################
7 |
8 | ######################FORK#######################
9 | # Modified by @nano2dev #
10 | # https://github.com/fwd/nano-docker #
11 | #################################################
12 |
13 | # VERSION
14 | version='1.1'
15 |
16 | # OUTPUT VARS
17 | red=`tput setaf 1`
18 | green=`tput setaf 2`
19 | yellow=`tput setaf 3`
20 | bold=`tput bold`
21 | reset=`tput sgr0`
22 |
23 | # Initialize default values
24 | displaySeed='false'
25 | quiet='false'
26 | fastSync='false'
27 | monitor='false'
28 | port=''
29 | tag=''
30 |
31 | # Iterate over the input arguments
32 | while [[ $# -gt 0 ]]; do
33 | case "$1" in
34 | -s)
35 | displaySeed='true'
36 | ;;
37 | -q)
38 | quiet='true'
39 | ;;
40 | -f)
41 | fastSync='true'
42 | ;;
43 | -m)
44 | monitor='true'
45 | ;;
46 | -p)
47 | shift
48 | port="$1"
49 | ;;
50 | -t)
51 | shift
52 | tag="$1"
53 | ;;
54 | -v)
55 | shift
56 | tag="$1"
57 | ;;
58 | esac
59 | shift
60 | done
61 |
62 | # PRINT INSTALLER DETAILS
63 | if [[ $quiet = 'false' ]]; then
64 | echo ""
65 | echo "${green}================================${reset}"
66 | echo "${green}${bold}1-CLICK NANO NODE${reset}"
67 | echo "${green}================================${reset}"
68 | echo "${green}${bold}github.com/fwd/nano-docker${reset}"
69 | echo "${green}============================${reset}"
70 | fi
71 |
72 | sleep 1
73 |
74 | # JQ used right below
75 | if ! command -v jq &> /dev/null; then
76 | if [ -n "$(uname -a | grep Ubuntu)" ]; then
77 | echo "${CYAN}JQ:${NC}: Installing."
78 | sudo apt install jq -y
79 | else
80 | echo "${CYAN}Error${NC}: Could not auto install 'jq'. Please install it manually, then run ./setup.sh again."
81 | exit 1
82 | fi
83 | fi
84 |
85 | if [[ -z $port ]]; then port='80'; fi
86 |
87 | ## Prone to get Rate limited by Github
88 | ## TODO fix this
89 | latest=$(curl -s https://api.github.com/repos/nanocurrency/nano-node/releases/latest -s | jq .name -r)
90 |
91 | if [[ "$OSTYPE" == "linux-gnu"* ]]; then
92 | echo ""
93 | elif [[ "$OSTYPE" == "darwin"* ]]; then
94 | echo "Operating system not supported."
95 | exit 1
96 | # Mac OSX
97 | elif [[ "$OSTYPE" == "cygwin" ]]; then
98 | echo "Operating system not supported."
99 | exit 1
100 | # POSIX compatibility layer and Linux environment emulation for Windows
101 | elif [[ "$OSTYPE" == "msys" ]]; then
102 | echo "Operating system not supported."
103 | exit 1
104 | # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
105 | elif [[ "$OSTYPE" == "win32" ]]; then
106 | # I'm not sure this can happen.
107 | echo "Operating system not supported."
108 | exit 1
109 | elif [[ "$OSTYPE" == "freebsd"* ]]; then
110 | # ...
111 | echo "Operating system not supported."
112 | exit 1
113 | else
114 | # Unknown.
115 | echo "Operating system not supported."
116 | exit 1
117 | fi
118 |
119 | DEFAULT_COMPOSE=$(cat < docker-compose.yml < /dev/null
178 | if [ $? -ne 0 ]; then
179 |
180 | # Docs: https://docs.docker.com/engine/install/ubuntu
181 | echo "Installing Docker..."
182 |
183 | # Basics
184 | sudo apt-get -y install curl p7zip-full
185 |
186 | # PGP Key
187 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
188 |
189 | # Set up Docker Repo
190 | echo \
191 | "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
192 | $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
193 |
194 | sudo apt-get update
195 |
196 | sudo apt-get -y install jq docker-ce docker-ce-cli containerd.io
197 |
198 | fi
199 |
200 | docker-compose --version &> /dev/null
201 | if [ $? -ne 0 ]; then
202 | echo "Installing Docker Compose..."
203 | curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
204 | sudo chmod +x /usr/local/bin/docker-compose
205 | sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
206 | fi
207 |
208 | if [[ $fastSync = 'true' ]]; then
209 | wget --version &> /dev/null
210 | if [ $? -ne 0 ]; then
211 | echo "${red}wget is not installed and is required for fast-syncing.${reset}";
212 | exit 2
213 | fi
214 |
215 | 7z &> /dev/null
216 | if [ $? -ne 0 ]; then
217 | echo "${red}7-Zip is not installed and is required for fast-syncing.${reset}";
218 | exit 2
219 | fi
220 | fi
221 |
222 | # FAST-SYNCING
223 | if [[ $fastSync = 'true' ]]; then
224 |
225 | # FAST-SYNC DOWNLOAD LINK
226 | # BIG THANKS TO @ThiagoSFS
227 | ledgerDownloadLink=$(curl -s 'https://s3.us-east-2.amazonaws.com/repo.nano.org/snapshots/latest')
228 |
229 | if [[ $quiet = 'false' ]]; then
230 | printf "=> ${yellow}Downloading latest ledger files...${reset}\n"
231 | wget -O todaysledger.7z ${ledgerDownloadLink} -q --show-progress
232 | printf "=> ${yellow}Unzipping and placing the files (takes a while)...${reset} "
233 | 7z x todaysledger.7z -o./nano-node/Nano -y &> /dev/null
234 | rm todaysledger.7z
235 | printf "${green}Done.${reset}\n"
236 | else
237 | wget -O todaysledger.7z ${ledgerDownloadLink} -q
238 | docker-compose stop nano-node &> /dev/null
239 | 7z x todaysledger.7z -o./nano-node/Nano -y &> /dev/null
240 | rm todaysledger.7z
241 | fi
242 |
243 | fi
244 |
245 | # DETERMINE IF THIS IS AN INITIAL INSTALL
246 | [[ $quiet = 'false' ]] && echo "=> ${yellow}Checking status...${reset}"
247 | [[ $quiet = 'false' ]] && echo ""
248 |
249 | # check if node mounted directory exists
250 | if [ -d "./nano-node" ]; then
251 | if [ ! -d "./nano-node/RaiBlocks" ]; then
252 | if [ ! -d "./nano-node/Nano" ]; then
253 | [[ $quiet = 'false' ]] && printf "${reset}Unsupported directory structure detected. Migrating files... "
254 | mkdir ./nano-node/RaiBlocks
255 | mv ./nano-node/* ./nano-node/RaiBlocks/ &> /dev/null
256 | [[ $quiet = 'false' ]] && printf "${green}done.\n${reset}"
257 | [[ $quiet = 'false' ]] && echo ""
258 | fi
259 | fi
260 | fi
261 |
262 | if [[ $tag ]]; then
263 | sed -i -e "s/ image: nanocurrency\/nano:.*/ image: nanocurrency\/nano:$tag/g" docker-compose.yml
264 | fi
265 |
266 | if [[ $quiet = 'false' ]]; then
267 | docker-compose up --remove-orphans -d
268 | else
269 | docker-compose up --remove-orphans -d &> /dev/null
270 | fi
271 |
272 | if [ $? -ne 0 ]; then
273 | echo "${red}It seems errors were encountered while spinning up the containers. Scroll up for more info on how to fix them.${reset}"
274 | exit 2
275 | fi
276 |
277 | isRpcLive="$(curl -s -d '{"action": "version"}' [::1]:7076 | grep "rpc_version")"
278 | while [ ! -n "$isRpcLive" ];
279 | do
280 | sleep 1s
281 | isRpcLive="$(curl -s -d '{"action": "version"}' [::1]:7076 | grep "rpc_version")"
282 | done
283 |
284 | nodeExec="docker exec -it nano-node /usr/bin/nano_node"
285 |
286 | # WALLET SETUP
287 | sed -i 's/enable_control = false/enable_control = true/g' ./nano-node/Nano/config-rpc.toml
288 |
289 | existedWallet="$(${nodeExec} --wallet_list | grep 'Wallet ID' | awk '{ print $NF}')"
290 |
291 | if [[ ! $existedWallet ]]; then
292 | walletId=$(${nodeExec} --wallet_create | tr -d '\r')
293 | sleep 1
294 | address="$(${nodeExec} --account_create --wallet=$walletId | awk '{ print $NF}')"
295 | sleep 1
296 | [[ $quiet = 'false' ]] && printf "${green}done.${reset}\n\n"
297 | else
298 | address="$(${nodeExec} --wallet_list | grep 'nano_' | awk '{ print $NF}' | tr -d '\r')"
299 | sleep 1
300 | walletId=$(echo $existedWallet | tr -d '\r')
301 | fi
302 |
303 | sleep 1
304 |
305 | if [[ $quiet = 'false' && $displaySeed = 'true' ]]; then
306 | seed=$(${nodeExec} --wallet_decrypt_unsafe --wallet=$walletId | grep 'Seed' | awk '{ print $NF}' | tr -d '\r')
307 | fi
308 |
309 | if [ $monitor = 'true' ]; then
310 |
311 | if [ ! -f ./nano-node-monitor/config.php ]; then
312 | [[ $quiet = 'false' ]] && echo "=> ${yellow}No existing NANO Node Monitor config file found. Fetching a fresh copy...${reset}"
313 | if [[ $quiet = 'false' ]]; then
314 | docker-compose restart nano-node-monitor
315 | else
316 | docker-compose restart nano-node-monitor > /dev/null
317 | fi
318 | fi
319 |
320 | sed -i -e "s/\/\/ \$nanoNodeRPCIP.*;/\$nanoNodeRPCIP/g" ./nano-node-monitor/config.php
321 | sed -i -e "s/\$nanoNodeRPCIP.*/\$nanoNodeRPCIP = 'nano-node';/g" ./nano-node-monitor/config.php
322 |
323 | sed -i -e "s/\/\/ \$nanoNodeAccount.*;/\$nanoNodeAccount/g" ./nano-node-monitor/config.php
324 | sed -i -e "s/\$nanoNodeAccount.*/\$nanoNodeAccount = '$address';/g" ./nano-node-monitor/config.php
325 |
326 | ipAddress=$(dig @resolver4.opendns.com myip.opendns.com +short -4)
327 |
328 | if [[ $ipAddress =~ .*:.* ]]; then
329 | ipAddress="[$ipAddress]"
330 | fi
331 |
332 | sed -i -e "s/\/\/ \$nanoNodeName.*;/\$nanoNodeName = 'nano-docker-$ipAddress';/g" ./nano-node-monitor/config.php
333 |
334 | sed -i -e "s/\/\/ \$welcomeMsg.*;/\$welcomeMsg = 'Welcome! This node was setup using Nano Docker<\/a>!';/g" ./nano-node-monitor/config.php
335 |
336 | sed -i -e "s/\/\/ \$blockExplorer.*;/\$blockExplorer = 'meltingice';/g" ./nano-node-monitor/config.php
337 |
338 | sed -i -e 's/\r//g' ./nano-node-monitor/config.php
339 |
340 | fi
341 |
342 | if [[ "$quiet" = "false" ]]; then
343 |
344 | echo "=========================================="
345 | echo " ${green}Welcome to the Nano Blockchain${reset} "
346 | echo "=========================================="
347 |
348 | if [[ $monitor == 'false' ]]; then
349 | echo " http://$(hostname -I | cut -d' ' -f3):7676 or [::1]:7076 "
350 | # echo "=========================================="
351 | else
352 | echo "=========================================="
353 | echo " http://$(dig @resolver4.opendns.com myip.opendns.com +short -4):$port or [::1]:$port "
354 | # echo "=========================================="
355 | fi
356 |
357 | if [[ $displaySeed = 'true' ]]; then
358 | echo "=================${yellow}SECRET${reset}==================="
359 | echo "${green}PUBLIC:${reset} $address"
360 | echo "${red}SECRET:${reset} $seed"
361 | echo "==============KEEP THIS SAFE=============="
362 | else
363 | echo "=================SECRET==================="
364 | echo "Use './setup.sh -s' to get private key. "
365 | echo "=========================================="
366 | fi
367 |
368 | if [[ $displaySeed = 'false' ]]; then
369 | cat <> ~/.bash_aliases;
387 | fi
388 | else
389 | echo "alias nano-node='${nodeExec}'" >> ~/.bash_aliases;
390 | fi
391 |
392 | exit 1
--------------------------------------------------------------------------------