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
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 $@
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
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 .
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
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"
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
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).