Skip to main content

Static hosting

In this quick tutorial, you'll learn how to create and deploy static assets you can access from HTTPS. We will take an example of a basic index.html file.

1. Prepare the directory and create a basic html file

Create working directory

Let's start from our ready-to-use project, and go directly to the step 3

git clone https://github.com/ScaleDynamics/hosting my-hosting
cd my-hosting/
npm install

or,

Let's create manually your own my-hosting working directory, and follow the next steps

mkdir my-hosting
mkdir my-hosting/public
cd my-hosting/

Create a package.json file

npm init -y

Create html file to deploy

Create a new public/index.html file, and copy-paste the following code into it:

<!doctype html>
<html>
<head>
<title>Test web page!</title>
</head>
<body>
<p>Chapeau! your assets are available online.</p>
</body>
</html>

2. Install the ScaleDynamics SDK

To install the SDK you need Node.js installed on your computer.
Look at https://nodejs.org/en/download/ to install it.

Install the SDK to access all CLI commands:

npm install warp --save-dev

To access our CLI, use npx warp. You can have the list of available commands and help with

npx warp help

3. Create the project and the environment

The deployment of a static assets requires to indicate in which project and which environment you want to deploy them.

A project is a name that identifies a website, a web app, a microservice or an API.

An environment is a name that identifies a cloud execution configuration to serve your assets. For example you can have 'pre-prod', 'demo', 'staging' or 'production' environments. Each one will have it's own cloud resource configuration.

Login to your account

To access projects and deployment resources you need a ScaleDynamics account. You can sign up here to create your account. Subscription is FREE, no credit card required.

Once your account is created, you can login to your account with your email and password:

npx warp login

Create a project

A project identifies a website, a web app, a microservice or an API.

Let's create a hosting project, and let's indicate the SDK we are working in it.

npx warp project create hosting
npx warp project select hosting

Create an environment

Let's create a demo environment, and let's indicate the SDK we are working in it.

npx warp env create demo
npx warp env select demo

4. Setup services for the environment

Before deploying you need to enable the Static asset hosting service and assign cloud resources to run it. To do that, open the console, select the organization, the hosting project and the demo environment. Then enable the Static asset hosting service and assign a Shared Free cloud resource on the provider and the region you choose.

After subscribing resources, you will see in the console your services configurations.

5. Deploy the server

Now you can deploy the assets. By default all files/directories in public will be deployed and make accessible on HTTPS.

npx warp deploy

During the deployment, you will have to indicate the url you want to access your server after deployment.

✔ Enter a hostname for 'hosting' (fully qualified or not), leave blank for random: … 

You can enter a name or press return to get a random one.

After deployment the url to serve your assets is dumped on the terminal.

if you want to know the deployment url, you can access the console or use the following command to get it:

npx warp env info

6. Access

Now assets are deployed, let's access them on https:

https://DEPLOYMENT_URL

Next