Spheron Network
What is Spheron?β
Spheron is a platform-as-a-service (PaaS) designed for dapps looking to launch their applications on decentralized infrastructure with optimal performance, and provides compute capabilities, decentralized storage, CDN and web hosting out of the box. With its comprehensive set of tools and services rooted in web3 infrastructure provision, Spheron empowers developers to meet the dynamic demands of the digital landscape. Its exceptional performance not only rivals web2 counterparts but also showcases the potential of web3 technology for the next generation of applications.
Learn more about Spheron through our documentation.
How to deploy a static site on Spheronβ
Deploying static apps on Spheron is straightforward. Follow these steps:
-
Connect your Git provider:
Connecting your Git provider allows Spheron to sync your repositories and trigger deployments whenever new updates are made. Spheron supports the following Git providers: Github, Gitlab, and Bitbucket. -
Set up your project:
Create a new project on Spheron and choose your desired app repository for deployment. -
Select deployment protocol:
Select the desired protocol for hosting your static app. Spheron supports Arweave, Filecoin, and IPFS. -
Configure deployment settings:
Spheron will automatically detect and configure most of these settings for you, though you have to add environment variables in the dedicated section. If needed, modify the remaining parameters according to your requirements. That includes selecting the framework, branch, root directory, build and output settings, and the node engine. -
Trigger deployment:
After configuring all the required settings, initiate the deployment process. Spheron will fetch your code, build the static files, and deploy them to your specified protocol. -
Access your app:
Once the deployment is complete, you can access your app through the domain generated by Spheron. You also have the option to set up a custom domain for your app.
Checkout our Framework Guide for more info.
How to deploy dynamic apps/servers on Spheronβ
Whether you're using a Docker image from Docker Hub or deploying a marketplace app, deploying compute instances on Spheron is simple and effortless. Follow these steps to deploy your compute instance on Spheron:
-
Set up your cluster:
Create a new cluster on Spheron by selecting Import from Docker Hub or Start from Marketplace App. -
For Docker Hub:
- Click "New Cluster" in the top-right corner.
- Select Import from Docker Hub.
- Enter the names for your cluster and docker image.
- Then, add the tag and click "Next."
- Choose your compute type option under Compute Type.
- Select your preferred Region, if any. If you do not add a region, the container will be deployed in any region for Spot, or in the eu-east region for On Demand. Click here to learn more.
- Spheron will automatically select the recommended plan for the specific template. If you intend to move forward with the recommended plan, click "Deploy" to initiate deployment.
- Select the instance plan that suits your needs. Use the "Create Custom Plan" toggle to create custom plans for your instance.
- Configure the storage (SSD) plan for your instance. Use the "Add Persistent Storage" toggle to add persistent storage for your instance.
- Create new Port Policy Mapping. Add the container port and select the exposed port you want to map it to. Refer to our docs for more information.
- Add Environment Variable, if any.
- Add Secret Environment Variable if the value is a secret key. It will not be saved in the database. Click here to learn more.
- You can add advanced configuration if required. Click here to read more.
- You can add a health checkup if required. Click here to learn more.
- Click "Deploy" to initiate deployment.
Checkout our Server Guide for more info.
-
For a Marketplace App:
- Click "New Cluster" in the top right corner.
- Select Start from Marketplace App.
- Pick your desired template from the marketplace.
- Choose your desired compute type option under Compute Type.
- Select your preferred Region, if any. If you do not add a region, the container will be deployed in any region for Spot, or in the eu-east region for On Demand. Click here to learn more.
- Spheron will automatically select the recommended plan for the specific template. If you intend to move forward with the recommended plan, just click "Deploy" to initiate deployment.
- Select the instance plan that suits your needs. Use the "Create Custom Plan" toggle to create custom plans for your instance.
- Configure the storage (SSD) plan for your instance. Use the "Add Persistent Storage" toggle to add persistent storage for your instance.
- You can add advanced configuration if required. Click here to know more.
- Click "Deploy" to initiate deployment.
Checkout our Marketplace Guide for more info.
How to upload to IPFS using Spheron SDKβ
1. Spheron Storage SDK (for Nodejs environments)β
Installationβ
npm i @spheron/storage
Usageβ
import { SpheronClient, ProtocolEnum } from "@spheron/storage";
const client = new SpheronClient({ token });
let currentlyUploaded = 0;
const { uploadId, bucketId, protocolLink, dynamicLinks } = await client.upload(
filePath,
{
protocol: ProtocolEnum.IPFS,
name,
onUploadInitiated: (uploadId) => {
console.log(`Upload with id ${uploadId} started...`);
},
onChunkUploaded: (uploadedSize, totalSize) => {
currentlyUploaded += uploadedSize;
console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);
},
},
);
Checkout our Storage SDK Documentation for more info.
2. Spheron Browser Upload SDK (for Browser environments)β
Installationβ
npm i @spheron/browser-upload
Usageβ
Server
You have to set up a web server with an endpoint that will be used by the frontend to fetch the token for upload.
import { SpheronClient, ProtocolEnum } from "@spheron/storage";
...
app.get("/initiate-upload", async (req, res, next) => {
try {
const bucketName = "example-browser-upload"; // use your preferred name
const protocol = ProtocolEnum.IPFS; // use your preferred protocol
const token = process.env.SPHERON_TOKEN; // add your access token in .env or paste it here
const client = new SpheronClient({ token });
const { uploadToken } = await client.createSingleUploadToken({
name: bucketName,
protocol,
});
res.status(200).json({
uploadToken,
});
} catch (error) {
console.error(error);
next(error);
}
});
Client
You have to send a request to your server to create the uploadToken that will be used to upload files from the browser.
import { upload } from "@spheron/browser-upload";
...
const response = await fetch(`<BACKEND_URL>/initiate-upload`); // get the temporary access token from server
const resJson = await response.json();
const token = resJson.uploadToken;
let currentlyUploaded = 0;
const { uploadId, bucketId, protocolLink, dynamicLinks } = await upload(files, {
token,
onChunkUploaded: (uploadedSize, totalSize) => {
currentlyUploaded += uploadedSize;
console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);
},
});
...
Checkout our Browser Upload SDK for more info.
Checkout all other SDKs for more in-depth information.
How to create and deploy apps using Spheron CLIβ
Installationβ
For Mac and Linuxβ
To install the Spheron CLI, run the following command in your terminal:
sudo npm install -g @spheron/cli
For Windowsβ
To install the Spheron CLI, open your terminal in administrator mode and run the following command:
npm install -g @spheron/cli
Usageβ
spheron init
β
The spheron init
command allows you to initialize a new Spheron project. A spheron.json
file is created in your current path that describes your project. It will be utilized by the spheron publish
command.
Usageβ
spheron init
Upon running this command, a prompter will appear that will allow you to select protocol, add project name, add path, and select framework. Here is how it will look:
? Project name: (Code)
? Upload protocol: (Use arrow keys)
Arweave
Filecoin
β― IPFS
spheron publish
β
The spheron publish
command allows you to upload your project using the configuration that is described in the spheron.json
file of your project.
Usageβ
spheron publish
Make sure that you create a production build before running the spheron publish
command.
Here is an example of how the result will look:
Spheron CLI 1.0.7
Publishing your dapp to IPFS π
Uploading directory build
Upload started, ID of deployment: 643fce207c3c7a0012df33a7
β Uploading to IPFS
β Success! Upload finished !
Here are upload details:
Upload ID: 643fce207c3c7a0012df33a7
Bucket ID: 643fce207c3c7a0012df33a5
Protocol Link: https://bafybeicrjwhn6nifl7tcuhkcitquvpumj426qa7r7ppcya5skmqly5n2la.ipfs.sphn.link
Dynamic Links: https://testapp-edab50.spheron.app
Checkout our CLI Documentation for more info.
How to view and retrieve content from IPFS using Spheronβ
Dedicated IPFS Gatewaysβ
Dedicated gateways are IPFS gateways specifically designed to enhance access to pinned content across the network by offering faster speeds and increased rate limits.
Using dedicated gateways offers several benefits:
- Improved speed
- Increased rate limits
- White-labeling gateway
- Serve content from any IPFS node
Create a Dedicated Gatewayβ
Follow these steps to create a dedicated gateway:
- Log in to Spheron and navigate to the Gateways section in the navbar.
- Click Generate to create a new gateway.
- Enter a name for your gateway and click Create.
How to Use Your Gatewayβ
To access content through your dedicated gateway, simply follow these steps:
- Obtain the CID (content identifier) of the file you wish to view.
- Append the CID to your gateway URL in the following format:
https://{gateway-name}.spheron.link/ipfs/{cid}
Checkout our gateway documentation for more information.
Further Resourcesβ
- Visit our platform to learn more.
- Access our comprehensive documentation for detailed information.
- Follow us on Twitter for the latest updates and news.
- Join our Community for dedicated support and assistance.