May 27, 2021 Web Cloud Development and Web Hosting Learning Guide
Cloud development static hosting is the ability to host static websites provided by cloud development, and the distribution of static resources (HTML, CSS, JavaScript, fonts, etc.) is supported by Tencent Cloud Object Storage COS and Tencent Cloud CDN with multiple edge outlets.
Using cloud development static hosting can help the game easily carry the traffic peak, so that the business runs smoothly, at the same time, you can access the SDK of cloud development in Egret, database, function, storage and other links also moved to cloud development, so that the entire business does not collapse.
First, you need to initialize a project with Egret Launcher, which is no longer covered by the installation of Egret Launcher.
Open Egret Launcher to create a new Egret game project
Once the project is created, you can edit the project by clicking Egret Wing
Here, we no longer edit, directly perform the publication
Click the publish button to go to the publishing page
Select HTML5 and click OK to publish
Once the publication is complete, click Open folder to see the build product
Next, we just need to upload these build products to a static hosting of cloud development to deploy Egret games to a static site hosting for cloud development.
After we've developed the game, let's create a cloud development environment for subsequent deployments. Visit the cloud development console, click New Environment, and create a new environment
On the pop-up environment creation page, enter the name of the environment you want to create. In addition, the billing method here requires a pay-as-you-go option.
Once set up, click Open Now to open a new cloud development environment.
You'll see that your environment name becomes the character you enter plus a randomly generated string, and this is your environment ID, which you can record and use later. After a few moments of initialization of the cloud environment, click to go to the details page, click on the static site hosting on the left,
You'll go to the static hosting details page, click Get Started, and open a static hosting service
Wait for the static hosting service to open, wait a moment, it's ready to open. You can see your domain name information in your settings
For example, my domain
https://egret-14cdf2.tcloudbaseapp.com
domain name is a test domain name assigned to me by cloud development, allowing me to complete product testing without migrating to production.
We can upload these files manually through the cloud development console or using the cloud development cli tool.
Given that most of the scenes we do at work are uploaded using Cli, here we'll use Cli to upload.
Regarding the installation of CLi tools is not repeated here, you can go directly to the official documentation of
http://docs.cloudbase.net/cli/intro.html
be installed according to the official documentation.
After the installation of the cli tool is complete, perform the following command to log in
tcb login
Once the login is complete, you can see the interface.
Now that we've configured the cloud development Cli, we can upload files to the cloud development, use the command line, go into the project folder we just built, like I'm in this directory, and then execute commands in this directory for deployment
tcb hosting:deploy -e egret-14cdf2
After a moment, our file was uploaded.
Visit the URL of the test environment we just got, you can see this interface, it shows that we successfully deployed the game to the cloud development static site hosting, and then we just need to bind the domain name, we can put the game online