Build Docker SCPrime Server leverage a Synology DS918+
- alexanderseelert
- 17. Jan. 2022
- 5 Min. Lesezeit
First Blog, helping others to create a SCPrime service running at a DIY (Do It Yourself) Synology solution.


“Before you start”
read the actual SCP documentation
- 2-4 cores - 4-8 GB Main Memory - 64Bit Operating System (Linux Preferred, do not use a Pi)
“Prepare Synology shared directories”
Create two shared directories! Why two? One folder will keep only Meta Data, the another one is only used to store the scp data. Also you can simply create a backup only for Meta Data using HyperBackup or Replicate Clone the Shared Folder.
Example: crypto_docker_scprime_data (only for data usage)
crypto_docker_scprime_metadata (only for meta data of spd service)



create the following sub-directories as follow for data storage

create the following sub-directory as follow for meta data

“Prepare DDNS”
Check you are using a valid DDNS service such as already free synology.me or also free No-Ip.com ( I prefer synology.me via DSM, as this is for free and easy to setup with quick connect by Synology)

“Prepare Docker Network”
creating a separate bride network will help you using future containers easy to connect to scp prime container, such as NodeRed, Grafana and time series databases building own monitoring tools.
sudo docker network create sia-network
“Create SCPrime Docker container”
Validate the folder links to local sub directories is valid. Important use 127.0.0.1 for port 4280 as this is the API port and should only be available locally.
sudo docker run \
--detach \
--restart unless-stopped
\-v /volume1/crypto_docker_scprime_metadata/scprime_meta:/scp-data
\-v volume1/crypto_docker_scprime_data/scprime_data:/sp/scprime_data
\-v /volume1/crypto_docker_scprime_data/scprime_data1:/sp/scprime_data1 \-v /volume1/crypto_docker_scprime_data/scprime_data2:/sp/scprime_data2 \-v \volume1/crypto_docker_scprime_data/scprime_data3:/sp/scprime_data3 \-v /volume1/crypto_docker_scprime_data/scprime_data4:/sp/scprime_data4 \-v /volume1/crypto_docker_scprime_data/scprime_data5:/sp/scprime_data5 \-v /volume1/crypto_docker_scprime_data/scprime_data6:/sp/scprime_data6 \-v /volume1/crypto_docker_scprime_data/scprime_data7:/sp/scprime_data7 \-v /volume1/crypto_docker_scprime_data/scprime_data8:/sp/scprime_data8 \-v /volume1/crypto_docker_scprime_data/scprime_data9:/sp/scprime_data9 \
--publish 127.0.0.1:4280:4280 \
--publish 4281:4281 \
--publish 4282:4282 \
--publish 4283:4283 \
--publish 4285:4285 \
--label=com.centurylinklabs.watchtower.enable=false \
--env SCPRIME_WALLET_PASSWORD="wallet password or seed, if you did not change your password" \
--env SCPRIME_API_PASSWORD="Something simple but still secure enough" \
--env TZ="Europe/Berlin" \
--name scprime \
--network="sia-network"\
scprime/scprime
validate docker container starts
docker ps -f name=scprime
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3268dfbf4965 scprime/scprime "spd --disable-api-s…" 2 hours ago Up 2 hours 0.0.0.0:4281-4283->4281-4283/tcp, 0.0.0.0:4285->4285/tcp, 127.0.0.1:4280->4280/tcp, 0.0.0.0:8884->8884/tcp scprime
Only if you use WatchTower:
Setting label label=com.centurylinklabs.watchtower.enable=false is only needed, when using WatchTower Docker Container, preventing for auto updates.
“Fast Track: Sync for consensus db”
Okay now SCPrime Container is running but it will take quit a long time to sync.
But hey we go for the fast track for this.
stop the container again:
sudo docker stop scprime
upload the zip bootstrap file to the meta shared folder and extract it.
you should have a new consensus.db file, replace this new file consensus.db with the orig file in consensus folder and start docker image again

sudo docker start scprime
validate:
sudo docker logs scprime
“use the docker image commands”
Jump into the docker container to perform the next actions
sudo docker exec -it scprime sh
or use command
sudo docker exec -it scprime spc wallet balance
“Create Wallet ”
spc wallet init
<seed> (store your seed to somewhere highly secure)
<password> (normally the same as seed, which is not nice)
spc wallet addresses
c814425cf0bc32c007b268de2d3ded50782dc363b437c1734543844e666.....
“Change Wallet Password”
/ # spc wallet change-password
Current Password: (seed phrase)
New Password: (new easy to remember password, but still complex enough to secure things)
Confirm: (repeat password)
Password changed successfully.
after password has been changed, stop container again and change the password in the environment variable
sudo docker restart scprime
/ # spc wallet
Wallet status:
Encrypted, Unlocked
Height: 169108
Confirmed Balance: 238.1 SCP
Unconfirmed Delta: +0 H
Exact: 238094984787442171672643406053 H
Scprimefunds: 0 SPF
Scprimefund Claims: 0 H
Estimated Fee: 30 uS / KB
“Create SCP folders”
We have an up and running docker spd deamon, an unlocked wallet and everything prepared within the Synology. What's next? Right we need to provide storage using new Folders within the docker pointing to the mounted folders. Important: Validate, you are using the exact names which you provided during docker creation.
spc host folder add /sp/scprime_data 1190GB
spc host folder add /sp/scprime_data1 1190GB
spc host folder add /sp/scprime_data2 1190GB
spc host folder add /sp/scprime_data3 1190GB
spc host folder add /sp/scprime_data4 1190GB
spc host folder add /sp/scprime_data5 1190GB
spc host folder add /sp/scprime_data6 1190GB
spc host folder add /sp/scprime_data7 1190GB
spc host folder add /sp/scprime_data8 1190GB
spc host folder add /sp/scprime_data9 1190GB

“one last step”
use SouthXchange.com to move your SCP/BTC - > SCPs to your wallet Check you current wallet address with:
/ # spc wallet addresses
c814425cf0bc32c007b268de2d3ded50782dc363b437c1734543844e666.....
it will take a while until you SCP balance will be shown, as you need to have the same Block Height
/ # spc wallet balance
Wallet status:
Encrypted, Unlocked
Height: 169110
Confirmed Balance: 238.1 SCP
Unconfirmed Delta: +0 H
Exact: 238094984787442171672643406053 H
Scprimefunds: 0 SPF
Scprimefund Claims: 0
Estimated Fee: 30 uS / KB
“announce your host to the network”
this is not working, until SCP tokens are committed to your wallet
spc host announce hostname-something-xxx.synology.me:4282
now you should change you settings what every you want
verify your host will be shown in SCP network (takes a while)
spc host config minstorageprice 15SCP
spc host config collateral 15SCP
spc host config maxcollateral 236SCP
spc host config collateralbudget 2KS
spc host config maxduration 9w
spc host config minuploadbandwidthprice 2SCP
spc host config mindownloadbandwidthprice 2SCP
“Limit Download/Upload for SCPrime Gateway”
Check current settings
/ # spc gateway | grep -I load
Max download speed: 37500000
Max upload speed: 2500000
set new settings for example: 400Mbit download and 22Mbit upload
/ # spc gateway ratelimit 400Mbps 22Mbps
Set gateway maxdownloadspeed to 50000000 and maxuploadspeed to 2750000
validate new settings:
/ # spc gateway | grep -i load
Max download speed: 50000000
Max upload speed: 2750000
check your conversion:
reset to unlimited if wanted
/ # spc gateway ratelimit 0 0
Set gateway maxdownloadspeed to 0 and maxuploadspeed to 0
/ # spc gateway | grep -i load
Max download speed: 0
Max upload speed: 0
“Validate docker is performing fine”
checking logs for spd service via docker logs command
# sudo docker logs scprime -f
ScPrime Daemon v1.6.0
Git Revision ce9a97f89
Loading spd...
Starting modules:
(1/6) Loading gateway... done in 0.004811059 seconds.
(2/6) Loading consensus... done in 1.211772316 seconds.
(3/6) Loading transaction pool... done in 0.253830402 seconds.
(4/6) Loading wallet... done in 0.331518183 seconds.
(5/6) Loading host... done in 23.152724005 seconds.
(6/6) Loading renter... done in 2.7121782850000002 seconds.
API is now available, module loading completed in 27.685 seconds
ScPrime Wallet Password found, attempting to auto-unlock wallet
Auto-unlock successful.
Finished full startup in 27.964 seconds
“Create daily Backup using Hybrid Backup of Synology saving the MetaData”
Perform periodic backup of meta data


“Useful links and tools”
https://scprimewallet.com (check your wallet balance, if you have multiple add all)
https://scprime.info (check your wallet balance, if you have multiple add all) also you can check all you contracts
spc host contracts
“Port Forward most important”
Allow port forward of following TCP/IP (not UDP) ports:
4282 -> 4282
4283 -> 4283
4285 -> 4285
“Give me something for living, a coffee is not enough :-)

my SCP address
spc wallet send scprimecoins 1SCP c814425cf0bc32c007b268de2d3ded50782dc363b437c1734543844e666073c2e3c041de4aee
“open for discussion and hints”
bride vs host network performance (but I would stick to bridge mode)
If containers are running on same physical machine, network bandwidth under Host mode is15% bigger than Bridge mode, but 5% slower than just physical machine. Regarding of latency, it is 14% faster than Bridge mode but 17% slower than physical machine.
If containers are running on two different physical machine, network bandwidth under Hostmode is 0.3% bigger than Bridge mode, but 2.2% slower than just physical machine. Regarding of latency, it is 14% faster than Bridge mode but 2.3% slower than physical machine.
using API for data fetch
curl -A "ScPrime-Agent" localhost:4280/wallet | jq
curl -A "ScPrime-Agent" localhost:4280/host | jq
or
curl -A "ScPrime-Agent" --user "":API_PASSWORD localhost:4280/host | jq
Now that versio 1.6.2 is available, do you know what is the best approach to update? Spin up a new container recover walllet, attach disks and anounce?