Let's Get Something Showing

Post your evernode tutorials and ideas here!

Moderator: EvrSteward

Post Reply
CoderGeeK
Posts: 8
Joined: Sat Aug 24, 2024 6:31 pm

Let's Get Something Showing

Post by CoderGeeK »

This post will explain how you can get something showing on an evernode instance, as a tenant. Originally the idea of Evernode isn't to run webpages like this, but I believe that decentralized hosting with various front-end usecases are the right path forward for decentralized applications.

Most decentralized applications are on centralized servers, which is quite contradictive. Evernode solves this problem.

To get something showing on the front end, follow these steps:

1. Get started with NodeJS by following the 1-3 minute long tutorial below:
https://www.youtube.com/watch?v=SkeyY_fysxE (macintosh)
https://www.youtube.com/watch?v=Xit4miSByOw (windows)

2. Create a developer wallet and save your secret seed in a text file.
https://www.youtube.com/watch?v=tkt7fnoPMbI

3. Install Docker and create a user account at the docker hub (if you don't want to use your email, you can use any temporare email provider)
https://www.docker.com/
https://hub.docker.com/

4.
Create a project folder named project in vscode.

5.
Create a folder into the project folder and name it longrunning.

6.
Create the three files you see below into the longrunning folder

index.js

Code: Select all

const { readFile } = require('fs');
const express = require('express');

const app = express();

const path = require('path');

app.get('/', (request, response) => {
  const filePath = path.join(__dirname, 'web.html');
  readFile(filePath, 'utf8', (err, html) => {
    if (err) {
      return response.status(500).send('error');
    }
    response.send(html);
  });
});


const ports = Array.from({ length: 11 }, (_, i) =>36525 + i);

ports.forEach(port => {
  app.listen(port, () =>console.log(`Online at port ${port}`));
});

package.json

Code: Select all

{
    "name": "website",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
      "express": "^4.19.2"
    }
  }


web.html

Code: Select all

<html>Hello Evernode</html>

7.
Create the two files you see below into the project folder.

Dockerfile

Code: Select all

FROM evernode/sashimono:hp.latest-ubt.20.04-njs.20

RUN mkdir -p /usr/local/bin/hotpocket/website
RUN mkdir -p /usr/local/bin/hotpocket/website/node_modules

COPY longrunning/ /usr/local/bin/hotpocket/website
copy longrunning/node_modules /usr/local/bin/hotpocket/website/node_modules

COPY start.sh /start.sh
RUN chmod +x /start.sh

ENTRYPOINT ["/start.sh"]
EXPOSE 36525-36535
start.sh

Code: Select all

#!/bin/sh

# Run website
/usr/bin/node /usr/local/bin/hotpocket/website &

# Set the HotPocket binary as the entry point.
# $@ is used to pass all the commandline arguments fed to this script into hpcore.
/usr/local/bin/hotpocket/hpcore $@
8.
Open up the terminal in vs code and go to the longrunning folder (you might need to write cd longrunning to get there if you start in the project folder).

9.
Write

Code: Select all

npm i
to install all dependencies.

10.
Go back to the project folder by writing cd ..

11.
Log into docker by writing docker login (the info you use are the ones that you used when signing up to the docker hub)

12.
Now its time to build your docker container, the command below need you to replace YourUserName with your dockerhub username. When running this command, docker needs to be running on your computer.

Code: Select all

docker build -t YourUserName/website -f ./Dockerfile .
13.
Once it's built, we need to upload it to your docker hub, we do that with the command below.

Code: Select all

docker image push --all-tags YourUserName/website
14. A
Go to your startmenu, write powershell, rightclick on it and open it as admin, then write "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine" and hit enter. This will allow your computer to work with scripts, in this case the evernode development kit.

14. B
Install the evernode developer kit by typing npm i evdevkit -g.

15.
When that is done, we need to acquire an instance. To do that we need to first generate a public and a private key pair. These are the keypairs you would use to be able to communicate with your instance (it's basically the authentication).

Write evdevkit keygen to generate your keypair, save the public and the private keys in your nodepad. The private keypair should be kept private, because people can use it to communicate with your evernode instance.

16.
Now we need to make sure vscode knows your secret seed and private key for the deployment, use the two commands below and don't remove the " ", it needs to be there.

Code: Select all

$env:EV_TENANT_SECRET="Your Secret Seed Here"
$env:EV_USER_PRIVATE_KEY="Your Private Key Here"
17.
Let's find an eligible node to deploy to.

Go to following site:
https://xahau.xrplwin.com/evernode

Find a node which is up to date and that have a low price per hour and copy it's r-address.

18.
Write following command to acquire your instance for 1 moment (1 hour) and upload your docker container to it

Code: Select all

evdevkit acquire -i YourDockerHubAccountName/website:latest TheR-AddressYouCopied -m 1
19.
Take the domain you're given, take the port, open your webbrowser and write domain:port and hit enter. You're now going to see your website live, and it will remain live for one hour (1 moment).
Last edited by CoderGeeK on Tue Sep 10, 2024 9:58 pm, edited 5 times in total.
NickFields
Posts: 3
Joined: Wed Jul 31, 2024 6:29 pm

Re: Let's Get Something Showing

Post by NickFields »

awesome post man, this is really fun and will get the ball rolling for more devs to come build on this revolutionary technology. The docker deployments are super fun to do anything
tristopitsot
Posts: 4
Joined: Fri Jul 12, 2024 8:52 pm

Re: Let's Get Something Showing

Post by tristopitsot »

OK. Moderator, please develop this thread further. What will it give, where to get traffic to the site then for its operation?
CoderGeeK
Posts: 8
Joined: Sat Aug 24, 2024 6:31 pm

Re: Let's Get Something Showing

Post by CoderGeeK »

I just looked into a solution for SSL certificates, I used freedomain.one to create a free domain (developer purposes) and then zerossl.com to generate certificates for it.

Of the certificates I placed certificate.crt and private.key into my longrunning folder.

After that, I modified my index.js to run a HTTPS server instead of a http server.

Code: Select all

const { readFile } = require('fs');
const express = require('express');
const https = require('https');
const path = require('path');
const fs = require('fs');

const app = express();

const sslOptions = {
  key: fs.readFileSync(path.resolve(__dirname, 'private.key')),
  cert: fs.readFileSync(path.resolve(__dirname, 'certificate.crt')),
};

app.get('/', (request, response) => {
  const filePath = path.join(__dirname, 'web.html');
  readFile(filePath, 'utf8', (err, html) => {
    if (err) {
      return response.status(500).send('error');
    }
    response.send(html);
  });
});

const ports = Array.from({ length: 11 }, (_, i) => 36525 + i);

ports.forEach(port => {
  https.createServer(sslOptions, app).listen(port, () =>
    console.log(`Online at port ${port} (HTTPS)`)
  );
});
Now I can access https://myowndomain.tld:userport , and have an accepted SSL certificate!
Last edited by CoderGeeK on Sat Aug 24, 2024 10:40 pm, edited 3 times in total.
CoderGeeK
Posts: 8
Joined: Sat Aug 24, 2024 6:31 pm

Re: Let's Get Something Showing

Post by CoderGeeK »

tristopitsot wrote: Sat Aug 24, 2024 9:45 pm OK. Moderator, please develop this thread further. What will it give, where to get traffic to the site then for its operation?
You will have a website up and running on an evernode instance.

The magic here is that you can launch several of these anytime and anywhere. That's truly fascinating! :D
tristopitsot
Posts: 4
Joined: Fri Jul 12, 2024 8:52 pm

Re: Let's Get Something Showing

Post by tristopitsot »

👍
CoderGeeK
Posts: 8
Joined: Sat Aug 24, 2024 6:31 pm

Re: Let's Get Something Showing

Post by CoderGeeK »

tristopitsot wrote: Sat Aug 24, 2024 10:24 pm let's say I created a website in the selected country, where to take visitors and traffic to the site, so that it would transfer income?Or what is it for , I can rent a vps and deploy a website .Will it not be considered decentralized?
This is a cool thing for several reasons:

1. You can take advantage of being early...
If you need a lot of resources, for, let's say 1000 nodes... Then you can either purchase 1000 vpses, or utilize the low tenant fee evernode currently has (1000 nodes would cost less than 1 usd per month).

2. You get it on demand...
If you only need resources for a short period, then you can easily deploy your software when you need it, instead of having recurring costs.

3. You get a diverse set of hosting
Instead of hosting your software in one single datacenter, you can host them in diverse locations. You can have your software in evernodes well spread all cross the globe.

4. You can buy it with crypto
A really nice perk is that you can buy your hosting straight on the blockchain with EVR tokens. You don't need to share your creditcard details with any payment gateway and wait for settlement, you can simply pay and deploy.

5. Innovation <- most important
This is an innovative space, what we're witnessing here is innovation. Evernode nodes come with a consensus mechanisms that can read scripts (also called sophisticated smart contracts), this is something that can be used together with the traditional hosting we're looking at here. It's a new technology and brings us tamper-proof solutions to all kinds of futuristic software and projects.

6. Easy to scale
It's easy to scale, if you have a growing project and you start out on a couple instances, then you can easily just boot up more as your traffic increases.


There are a lot of more perks, but I don't want to make my post too long :lol:
tristopitsot
Posts: 4
Joined: Fri Jul 12, 2024 8:52 pm

Re: Let's Get Something Showing

Post by tristopitsot »

thanks .
Post Reply