Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Cloud development Gitbook eBook deployment


May 27, 2021 Web Cloud Development and Web Hosting Learning Guide


Table of contents


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

GitBook is an open source e-book generation tool that can easily help you build simple and generous e-books, and of course, cloud development now supports the deployment of GitBooks

System dependency

Before you go on, make sure you have Node installed in your PC .js the environment. If it is not installed, you can nodejs.org download the installation.

Install cloud development cli tools and Gitbooks

Follow these commands to install the cloud development cli tool and Gitbook

  1. npm i -g @cloudbase/cli gitbook-cli

Initialize a gitbook eBook project locally

First, let's create a gitbook e-book project and execute the following commands to create an e-book

  1. gitbook init book

In this way, we create a new e-book in the book directory.

Cloud development Gitbook eBook deployment

You can execute the command to preview him

  1. cd book
  2. gitbook serve

Cloud development Gitbook eBook deployment

After successful launch, open the browser's localhost:4000 and you can see the eBook we just created

Cloud development Gitbook eBook deployment

This means that we have completed the initialization of the project.

Create a cloud development environment

Now that we've created your on-premises Gitbook, let's create a cloud development environment to deploy your Gitbook. Open the Tencent Cloud Console and find cloud development in the product

Cloud development Gitbook eBook deployment

Go to the cloud development management console, click New Environment, Create New Environment for deployment

Cloud development Gitbook eBook deployment

Create a new environment, called docs, and choose to bill by volume to open the environment

Cloud development Gitbook eBook deployment

After you open your environment, remember your environment ID, which we'll use later.

Once the creation is complete, click on the environment and go to the environment management page. Click on the "static site" in the menu bar on the left

Cloud development Gitbook eBook deployment

And in the static website page opening function

Cloud development Gitbook eBook deployment

When you see an interface like this, it's already open.

Cloud development Gitbook eBook deployment

You can now manually upload a file test by uploading a file, and later we'll use cloud development Cli to complete the upload.

Initialize the cloud development Cli

Once we've configured our cloud development environment, we need to initialize the cloud development cli so that we can upload pages with cli (of course, you can upload them directly from the web side, but Gitbook is easier to upload with Cli if you have more document pages).

Enter the following code on the command line

  1. tcb login

will remind you that you need to authorize on the web page

Cloud development Gitbook eBook deployment

Confirm authorization on the pop-up page

Cloud development Gitbook eBook deployment

After confirming the authorization, you will see the console output the appropriate command

Deployment

That way, your cloud development cli is initialized. Next, you're ready to move on to the last step and upload the deployment Gitbook.

Deploy Gitbooks

Next, let's build the HTML for the Gitbook, which by default generates HTML in the _book directory. We can upload and deploy the files in this directory and execute the following commands (remember to replace envId with your own environment ID)

  1. gitbook build
  2. cd _book
  3. tcb hosting:deploy ./ -e envId

Cloud development Gitbook eBook deployment

Access

Click settings, go to the settings page, you can find the default domain name, click on the domain name, you can see the environment you just deployed.

Cloud development Gitbook eBook deployment

For example, this is what happened after my deployment

Cloud development Gitbook eBook deployment

In this way, your deployment is complete

One More Thing

Deploy your Gitbook to cloud development in just a few simple steps, eliminating the need to endure the speed of Github Pages! Not moving fast yet?

Not only that, but if you're an automation enthusiast, try configuring the Cloud Development Cli into your CI environment for automatic deployment