NKN GUI Mining on Dokku/Docker containers

#1

NKN GUI Mining on Dokku/Docker containers

If you’re anything like me, you already run container servers for web projects. Personally, I’m a big fan of dokku as a docker container manager. I had a few dokku servers lying around and I tought it wouldn’t be much of a stretch to run the NKN Mining GUI on a dokku container.

Really, it enables you to run all kinds of applications on a single server, including our friend the NKN Mining GUI. So for the interested, here’s a step by step:

Step 1: Install Dokku

DigitalOcean has a one-click for Dokku: https://www.digitalocean.com/docs/marketplace/dokku/
Or if you’re looking to install it yourself: http://dokku.viewdocs.io/dokku/getting-started/installation/

Step 2: Download the NKN Mining GUI

Download the NKN Mining GUI for Linux (NKNMining-linux.zip): https://github.com/nknorg/nkn-mining/releases

Step 3: Write the Dockerfile

A Dockerfile tells docker what to do before building your container. Insert a file named Dockerfile in the root of the NKNMining-linux folder and write the following:

FROM ubuntu:latest
FROM node:10

COPY . /app
WORKDIR /app

CMD ./NKNMining --remote

Step 4: Git push to our Dokku server

Dokku builds app containers via git. So let’s start by initializing git in our NKNMining-linux folder:

cd /path/to/NKNMining-linux
git init

Next, let’s commit everything to master:

git add .
git commit -m "FIRST"

And now, add your dokku server as a remote destination:

git remote add dokku [email protected][IP_ADDRESS]:nkn

The :nkn tells Dokku to create your app container with the name nkn. And now, you’re ready for a push! :

git push dokku master

Your application is now building. After it’s done, you should be able to run dokku logs nkn on your dokku server and see your serial number. It would look like:

dokku logs nkn
app[web.1]: serial number(sn): NKN-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

But you’ll see that the mining gui is not accessible quite yet. On to the final steps!

Step 5: Open the NKN ports

If you’ve enabled virtual hosts for your dokku server, disable them for the nkn app:

dokku domains:disable nkn

And dokku makes it easy to open ports for each specific apps:

dokku proxy:ports-add nkn http:8181:8181 http:30001:30001 http:30002:30002 http:30003:30003

Also, you might have to open the ports on the ufw:

ufw allow 22,80,443,8181,30001,30002,30003/tcp

Now, head to http://[IP_ADDRESS]:8181/web and the NKN Minuig GUI should be running smoothly.

Step 6: Follow the instructions to generate/load a wallet

All that’s left is generate/load an NKN wallet and you’re all set! :

Remember that you can always access your serial number by running dokku logs nkn on your server.

Please let me know if you’ve hit any walls,
Phil

3 Likes