This commit is contained in:
Mik-TF 2024-06-13 14:12:22 -04:00
parent eaabadc364
commit 4e7fee80ce
15 changed files with 673 additions and 4 deletions

View File

@ -255,8 +255,13 @@
- [IPFS on a Full VM](system_administrators/advanced/ipfs/ipfs_fullvm.md)
- [IPFS on a Micro VM](system_administrators/advanced/ipfs/ipfs_microvm.md)
- [MinIO Operator with Helm3](system_administrators/advanced/minio_helm3.md)
- [AI & ML Workloads](system_administrators/advanced/ai_ml_workloads.md)
- [Hummingbot](system_administrators/advanced/hummingbot.md)
- [AI & ML Workloads](system_administrators/advanced/ai_ml_workloads.md)
- [Ecommerce](system_administrators/advanced/ecommerce/ecommerce.md)
- [WooCommerce](system_administrators/advanced/ecommerce/woocommerce.md)
- [nopCommerce](system_administrators/advanced/ecommerce/nopcommerce.md)
- [HTTPS with Caddy](system_administrators/advanced/https_caddy.md)
- [Node Status Bot](system_administrators/advanced/node_status_bot.md)
- [ThreeFold Token](threefold_token/threefold_token.md)
- [TFT Bridges](threefold_token/tft_bridges/tft_bridges.md)
- [TFChain-Stellar Bridge](threefold_token/tft_bridges/tfchain_stellar_bridge.md)

View File

@ -92,7 +92,7 @@ Note that any argument containing spaces needs to be wrapped in quotes (e.g. mne
- `start`: to start (power on) a node
```bash
farmerbot start --node <node ID> -m "<mnemonic>" -n dev -d
farmerbot start --node <node ID> -m "<mnemonic>" -n <network> -d
```
Where:
@ -112,7 +112,7 @@ Global Flags:
- `start all`: to start (power on) all nodes in a farm
```bash
farmerbot start all --farm <farm ID> -m "<mnemonic>" -n dev -d
farmerbot start all --farm <farm ID> -m "<mnemonic>" -n <network> -d
```
Where:

View File

@ -0,0 +1,8 @@
<h1>Ecommerce</h1>
You can easily deploy a free and open-source ecommerce on the TFGrid. We present here two of the most popular options.
<h2>Table of Contents</h2>
- [WooCommerce](./woocommerce.md)
- [nopCommerce](./nopcommerce.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@ -0,0 +1,270 @@
<h1>Ecommerce on the TFGrid</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Deploy a Full VM](#deploy-a-full-vm)
- [Create an SSH Tunnel](#create-an-ssh-tunnel)
- [Preparing the VM](#preparing-the-vm)
- [Set a Firewall](#set-a-firewall)
- [Download nopCommerce](#download-nopcommerce)
- [Access nopCommerce](#access-nopcommerce)
- [Install nopCommerce](#install-nopcommerce)
- [Access the Ecommerce from the Public Internet](#access-the-ecommerce-from-the-public-internet)
- [Set a DNS Record](#set-a-dns-record)
- [Access the Ecommerce](#access-the-ecommerce)
- [HTTPS with Caddy](#https-with-caddy)
- [Manage with Systemd](#manage-with-systemd)
- [Access Admin Panel](#access-admin-panel)
- [Manage nopCommerce with Systemd](#manage-nopcommerce-with-systemd)
- [References](#references)
- [Questions and Feedback](#questions-and-feedback)
---
## Introduction
We show how to deploy a free and open-source ecommerce on the ThreeFold Grid. We will be deploying on a full VM with an IPv4 address.
[nopCommerce](https://www.nopcommerce.com/en) is an open-source ecommerce platform based on Microsoft's ASP.NET Core framework and MS SQL Server 2012 (or higher) backend Database.
## Prerequisites
- [A TFChain account](../../../dashboard/wallet_connector.md)
- TFT in your TFChain account
- [Buy TFT](../../../threefold_token/buy_sell_tft/buy_sell_tft.md)
- [Send TFT to TFChain](../../../threefold_token/tft_bridges/tfchain_stellar_bridge.md)
## Deploy a Full VM
We start by deploying a full VM on the ThreeFold Dashboard.
* On the [Threefold Dashboard](https://dashboard.grid.tf/#/), go to the [full virtual machine deployment page](https://dashboard.grid.tf/#/deploy/virtual-machines/full-virtual-machine/)
* Deploy a full VM (Ubuntu 22.04) with an IPv4 address and at least the minimum specs shown below
* IPv4 Address
* Minimum vcores: 2 vcores
* Minimum GB of RAM: 4 GB
* Minimum storage: 50 GB
* After deployment, note the VM IPv4 address
## Create an SSH Tunnel
We create an SSH tunnel with port 5432:80, as it is this combination that we will set for nopCommerce on the docker-compose file.
- Open a terminal and create an SSH tunnel
```
ssh -4 -L 5432:127.0.0.1:80 root@VM_IPv4_address>
```
Simply leave this window open and follow the next steps.
## Preparing the VM
We prepare the full to run nopCommerce.
* Connect to the VM via SSH
```
ssh root@VM_IPv4_address
```
* Update the VM
```
apt update
```
* [Install Docker](../../computer_it_basics/docker_basics.html#install-docker-desktop-and-docker-engine)
* Install docker-compose
```
apt install docker-compose -y
```
## Set a Firewall
You can set a firewall to your VM for further security. This should be used in production mode.
* Add the permissions
```
ufw allow 80
ufw allow 443
ufw allow 22
```
* Enable the firewall
```
ufw enable
```
* Verify the fire wall status
```
ufw status verbose
```
## Download nopCommerce
* Clone the repository
```
git clone https://github.com/nopSolutions/nopCommerce.git
cd nopCommerce
```
* Build the image
```
cd nopCommerce
docker-compose -f ./postgresql-docker-compose.yml build
```
* Run the image
```
docker-compose -f ./postgresql-docker-compose.yml up
```
## Access nopCommerce
You can access the nopCommerce interface on a browser with port 5432 via the SSH tunnel:
```
localhost:5432
```
![](./img/nopcommerce_1.png)
For more information on how to use nopCommerce, refer to the [nopCommerce docs](https://docs.nopcommerce.com/en/index.html).
## Install nopCommerce
You will need to set your ecommerce store and database information.
- Enter an email for your website (e.g. `admin@example.com`)
- For the database, choose PostgreSQL and check both options `Create a database` and `Enter raw connection`. Enter the following information (as per the docker-compose information)
```
Server=nopcommerce_database;Port=5432;Database=nop;User Id=postgres;Password=nopCommerce_db_password;
```
- Note: For production, you will need to set your own username and password.
## Access the Ecommerce from the Public Internet
### Set a DNS Record
* Go to your domain name registrar
* In the section **Advanced DNS**, add a **DNS A Record** to your domain and link it to the IP address of the VM you deployed on:
* Type: A Record
* Host: @
* Value: <IPv4_Address>
* TTL: Automatic
* It might take up to 30 minutes to set the DNS properly.
* To check if the A record has been registered, you can use a common DNS checker:
```
https://dnschecker.org/#A/example.com
```
### Access the Ecommerce
You can now go on a web browser and access your website via your domain, e.g. `example.com`.
![](./img/nopcommerce_2.png)
### HTTPS with Caddy
We set HTTPS with Caddy.
- Install Caddy
```
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' > /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
```
- Set a reverse proxy on port 80 with your own domain
```
caddy reverse-proxy -r --from example.com --to :80
```
You should see in the logs that it successfully obtains an SSL certificate, and after that you can try navigating to your site's domain again to verify it's working. Using a private window or adding `https://` specifically might be necessary until your browser drops its cache.
![](./img/nopcommerce_3.png)
When you're satisfied that everything looks good, hit `ctl-c` to exit Caddy and we'll proceed to making this persistent.
#### Manage with Systemd
We create a systemd service to always run the reverse proxy for port 80.
- Create a caddy service
```bash
nano /etc/systemd/system/caddy.service
```
- Set the service with your own domain
```
[Unit]
Description=Caddy Service
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=5
ExecStart=caddy reverse-proxy -r --from example.com --to :80
[Install]
WantedBy=multi-user.target
```
- Enable the service
```
systemctl daemon-reload
systemctl enable caddy
systemctl start caddy
```
- Verify that the Caddy service is properly running
```
systemctl status caddy
```
Systemd will start up Caddy immediately, restart it if it ever crashes, and start it up automatically after any reboots.
## Access Admin Panel
You can access the admin panel by clicking on `Log in` and providing the admin username and password set during the nopCommerce installation.
![](./img/nopcommerce_4.png)
In `Add your store info`, you can set the HTTPS address of your domain and enable SSL.
You will need to properly configure your ecommerce instance for your own needs and products. Read the nopCommerce docs for more information.
## Manage nopCommerce with Systemd
We create a systemd service to always run the nopCommerce docker-compose file.
- Create a nopcommerce service
```bash
nano /etc/systemd/system/nopcommerce.service
```
- Set the service with your own domain
```
[Unit]
Description=nopCommerce Service
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=5
StandardOutput=append:/root/nopcommerce.log
StandardError=append:/root/nopcommerce.log
ExecStart=docker-compose -f /root/nopCommerce/postgresql-docker-compose.yml up
[Install]
WantedBy=multi-user.target
```
- Enable the service
```
systemctl daemon-reload
systemctl enable nopcommerce
systemctl start nopcommerce
```
- Verify that the Caddy service is properly running
```
systemctl status nopcommerce
```
Systemd will start up the nopCommerce docker-compose file, restart it if it ever crashes, and start it up automatically after any reboots.
## References
For further information on how to set nopCommerce, read the [nopCommerce documentation](https://docs.nopcommerce.com/en/index.html?showChildren=false).
## Questions and Feedback
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.

View File

@ -0,0 +1,157 @@
<h1>WooCommerce on the TFGrid</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Deploy Wordpress](#deploy-wordpress)
- [Set a DNS Record](#set-a-dns-record)
- [HTTPS with Caddy](#https-with-caddy)
- [Adjust the Firewall](#adjust-the-firewall)
- [Manage with zinit](#manage-with-zinit)
- [Access Admin Panel](#access-admin-panel)
- [Install WooCommerce](#install-woocommerce)
- [Troubleshooting](#troubleshooting)
- [References](#references)
- [Questions and Feedback](#questions-and-feedback)
---
## Introduction
We show how to deploy a free and open-source ecommerce on the ThreeFold Grid. We will be deploying on a micro VM with an IPv4 address.
[WooCommerce](https://woocommerce.com/) is the open-source ecommerce platform for [WordPress](https://wordpress.com/). The platform is free, flexible, and amplified by a global community. The freedom of open-source means you retain full ownership of your stores content and data forever.
## Prerequisites
- [A TFChain account](../../../dashboard/wallet_connector.md)
- TFT in your TFChain account
- [Buy TFT](../../../threefold_token/buy_sell_tft/buy_sell_tft.md)
- [Send TFT to TFChain](../../../threefold_token/tft_bridges/tfchain_stellar_bridge.md)
## Deploy Wordpress
We start by deploying Wordpress on the ThreeFold Dashboard.
* On the [Threefold Dashboard](https://dashboard.grid.tf/#/), go to the [Wordpress deloyment page](https://dashboard.test.grid.tf/#/deploy/applications/wordpress/)
* Deploy a Wordpress with an IPv4 address and sufficient resources to run Wordpress
* IPv4 Address
* Minimum vcores: 2vcore
* Minimum MB of RAM: 4GB
* Minimum storage: 50GB
* After deployment, note the VM IPv4 address
## Set a DNS Record
* Go to your domain name registrar
* In the section **Advanced DNS**, add a **DNS A Record** to your domain and link it to the IP address of the VM you deployed on:
* Type: A Record
* Host: @
* Value: <IPv4_Address>
* TTL: Automatic
* It might take up to 30 minutes to set the DNS properly.
* To check if the A record has been registered, you can use a common DNS checker:
* ```
https://dnschecker.org/#A/example.com
```
## HTTPS with Caddy
We set HTTPS with Caddy.
- Install Caddy
```
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' > /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
```
- Set a reverse proxy on port 80 with your own domain
```
caddy reverse-proxy -r --from example.com --to :80
```
You should see in the logs that it successfully obtains an SSL certificate, and after that you can try navigating to your site's domain again to verify it's working. Using a private window or adding `https://` specifically might be necessary until your browser drops its cache.
When you're satisfied that everything looks good, hit `ctl-c` to exit Caddy and we'll proceed to making this persistent.
### Adjust the Firewall
By default, ufw is set on Wordpress application from the Dashboard. To use Caddy and set HTTPS, we want to allow port 443.
* Add the permissions
* ```
ufw allow 443
```
### Manage with zinit
We manage Caddy with zinit.
- Open the file for editing
```bash
nano /etc/zinit/caddy.yaml
```
- Insert the following line with your own domain and save the file
```
exec: caddy reverse-proxy -r --from example.com --to :80
```
- Add the new Caddy file to zinit
```bash
zinit monitor caddy
```
Zinit will start up Caddy immediately, restart it if it ever crashes, and start it up automatically after any reboots. Assuming you tested the Caddy invocation above and used the same form here, that should be all there is to it.
Here are some other Zinit commands that could be helpful to troubleshoot issues:
- See status of all services (same as "zinit list")
```
zinit
```
- Get logs for a service
```
zinit log caddy
```
- Restart a service (to test configuration changes, for example)
```
zinit stop caddy
zinit start caddy
```
## Access Admin Panel
You can access the admin panel by clicking on `Admin panel` under `Actions` on the Dashboard. You can also use the following template on a browser with your own domain:
```
example.com/wp-admin
```
If you've forgotten your credentials, just open the Wordpress info window on the Dashboard.
## Install WooCommerce
On the Wordpress admin panel, go to `Plugins` and search for WooCommerce.
![](./img/woocommerce_1.png)
Once this is done, you can open WooCommerce on the left-side menu.
![](./img/woocommerce_2.png)
You can then set your store and start your online business!
![](./img/woocommerce_3.png)
## Troubleshooting
You might need to deactivate some plugins that aren't compatible with WooCommerce, such as `MailPoet`.
## References
Make sure to read the [Wordpress and Woocommerce documentation](https://woocommerce.com/document/woocommerce-self-service-guide) to set your ecommerce.
## Questions and Feedback
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.

View File

@ -0,0 +1,91 @@
<h1>HTTPS with Caddy</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Set HTTPS](#set-https)
- [Adjust the Firewall](#adjust-the-firewall)
- [Manage with zinit](#manage-with-zinit)
---
## Introduction
We show how to set HTTPS with Caddy for any deployment on the grid.
## Prerequisites
- A deployment on the TFGrid and SSH access
## Set HTTPS
We set HTTPS with Caddy.
- Install Caddy
```
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' > /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
```
- Set a reverse proxy on port 80 with your own domain
```
caddy reverse-proxy -r --from example.com --to :80
```
You should see in the logs that it successfully obtains an SSL certificate, and after that you can try navigating to your site's domain again to verify it's working. Using a private window or adding `https://` specifically might be necessary until your browser drops its cache.
When you're satisfied that everything looks good, hit `ctl-c` to exit Caddy and we'll proceed to making this persistent.
### Adjust the Firewall
To use Caddy and set HTTPS, we want to allow port 443. If you are using `ufw`, add the permission for HTTPS:
- Add the permissions
```
ufw allow 443
```
### Manage with zinit
We manage Caddy with zinit.
- Open the file for editing
```bash
nano /etc/zinit/caddy.yaml
```
- Insert the following line with your own domain and save the file
```
exec: caddy reverse-proxy -r --from example.com --to :80
```
- Add the new Caddy file to zinit
```bash
zinit monitor caddy
```
Zinit will start up Caddy immediately, restart it if it ever crashes, and start it up automatically after any reboots. Assuming you tested the Caddy invocation above and used the same form here, that should be all there is to it.
Here are some other Zinit commands that could be helpful to troubleshoot issues:
- See status of all services (same as "zinit list")
```
zinit
```
- Get logs for a service
```
zinit log caddy
```
- Restart a service (to test configuration changes, for example)
```
zinit stop caddy
zinit start caddy
```

View File

@ -0,0 +1,132 @@
<h1> Node Status Bot </h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Deploy a Micro VM](#deploy-a-micro-vm)
- [Network Choice](#network-choice)
- [Create a Telegram Bot](#create-a-telegram-bot)
- [Prepare the VM](#prepare-the-vm)
- [Set the Bot](#set-the-bot)
- [Start the Bot](#start-the-bot)
- [Set Zinit](#set-zinit)
- [Questions and Feedback](#questions-and-feedback)
---
## Introduction
We show how to deploy the [Telegram Node Status bot](https://github.com/threefoldfoundation/node-status-bot) on a micro VM running on the ThreeFold Grid.
The Node Status bot provides realtime status updates and alerts on status changes for nodes on the ThreeFold Grid. You can find an [instance live on Telegram](https://t.me/tfnodestatusbot).
## Prerequisites
To run the bot, you need to have a TFChain account activated with a twin. For this, you can simply create an account on the ThreeFold Dashboard.
- [A TFChain account](../../dashboard/wallet_connector.md)
- TFT in your TFChain account
- [Buy TFT](../../threefold_token/buy_sell_tft/buy_sell_tft.md)
- [Send TFT to TFChain](../../threefold_token/tft_bridges/tft_bridges.md)
## Deploy a Micro VM
We start by deploying a micro VM on the ThreeFold Dashboard.
* On the [Threefold Dashboard](https://dashboard.grid.tf/#/), go to the [micro virtual machine deployment page](https://dashboard.test.grid.tf/#/deploy/virtual-machines/micro-virtual-machine/)
* Deploy a micro VM (Ubuntu 22.04) with the network connection of your choice
* Minimum vcores: 1vcore
* Minimum MB of RAM: 2048GB
* Minimum storage: 25GB
* After deployment, note the VM IP address
* Connect to the VM via SSH
```
ssh root@VM_IP_Address
```
### Network Choice
Since the bot works via an outbound connection to the Telegram servers, you do not need any public IP for it. It's thus cheaper to use either WireGuard, Planetary Network or Mycelium.
## Create a Telegram Bot
We create a Telegram bot using the [BotFather](https://t.me/BotFather).
Simply go to this link and follow the steps (`/newbot` ...). Make sure to take note of the bot token for the next steps.
## Prepare the VM
We prepare the micro VM to run the Node Status bot.
* Update the VM and install redis-server, git, nano, pip and python3-venv
```
apt update && apt install redis-server && apt install git && apt install nano && apt install pip && apt install python3.10-venv
```
## Set the Bot
Now that the VM is prepared, you can quickly set the bot.
```
git clone https://github.com/threefoldfoundation/node-status-bot.git
cd node-status-bot
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
wget https://github.com/threefoldtech/rmb-rs/releases/download/v1.0.7/rmb-peer
chmod u+x rmb-peer
```
## Start the Bot
Once the bot is set, you can start it with the following line.
```
python3 node-status-bot.py <bot_token> -s "<mnemonic>"
```
You can now go on Telegram and test the bot!
## Set Zinit
We can make sure the bot will start at any VM reboot by setting a zinit process. We set this using a simple script.
- Create a .yaml file in the zinit folder
```
nano /etc/zinit/node-status-bot.yaml
```
- The content should be the following
```
exec: /root/node-status-bot/start.sh
```
- Create a script to run the bot
```
nano start.sh
```
- The script should contain the following
```
#!/bin/bash
cd /root/node-status-bot
source venv/bin/activate
python3 node-status-bot.py <bot_token> -s "<mnemonic>" &>> /root/node-status-bot-logs
```
- Set permissions to the script
```
chmod +x start.sh
```
- Start the bot with the zinit command
```
zinit monitor node-status-bot
```
- Check if the bot is running
```
zinit status node-status-bot
```
You can then use the bot on Telegram and the Python program will restart every time the VM starts.
## Questions and Feedback
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.

View File

@ -85,5 +85,11 @@ For complementary information on ThreeFold grid and its cloud component, refer t
- [IPFS on a Full VM](ipfs_fullvm.md)
- [IPFS on a Micro VM](ipfs_microvm.md)
- [MinIO Operator with Helm3](minio_helm3.md)
- [AI & ML Workloads](ai_ml_workloads.md)
- [Hummingbot](hummingbot.md)
- [AI & ML Workloads](ai_ml_workloads.md)
- [Ecommerce](ecommerce.md)
- [WooCommerce](woocommerce.md)
- [nopCommerce](nopcommerce.md)
- [Hummingbot](hummingbot.md)
- [HTTPS with Caddy](https_caddy.md)
- [Node Status Bot](node_status_bot.md)