头图

During the development and creation period, more and more developers choose to build their own picture bed and manage pictures by themselves for diversified needs, which is safe and convenient. So, how to deploy an image bed application gracefully? This article takes an open source multifunctional image bed as an example to explain how to easily deploy a image bed application in a cloud development environment with the help of CloudBase Run.

Lsky Pro has obtained 1.3K+ Stars on Github. It has many advantages such as easy operation, beautiful UI, visual management, and support for access to third-party storage platforms. It also supports one-click deployment to cloud development.

Project homepage: https://github.com/wisp-x/lsky-pro

Cloud hosting CloudBase Run is a new generation of cloud native application engine (App Engine 2.0) provided by cloud development, which supports hosting containerized applications written in any language and framework.

deployment tutorial

For the layer configuration, see the project homepage, and the following mainly introduces the related configuration operations of cloud hosting.

Preparation

Open CloudBase cloud development environment

Note:

  • Cloud hosting cannot be activated in a yearly and monthly subscription environment.
  • Currently, the environment whose source is "WeChat Mini Program" does not support cloud hosting for the time being.

Step 1:

Log in to the cloud development CloudBase console, select an environment, enter the cloud hosting management page, and click "Activate Now".

Step 2: Configure cloud hosting

location

Currently, cloud hosting has opened the Shanghai and Guangzhou regions, and more regions will be opened one after another.

cloud hosting network

Network settings include private network VPC and subnet. Taking the environment as the dimension, all services created in the cloud hosting will be deployed in the same VPC, and the network settings cannot be changed after the cloud hosting is successfully activated.

The network settings are divided into the following two modes:

1. The system default configuration

Cloud hosting will automatically create a VPC and subnet for you, and bind it to your current cloud development environment.

All subsequent services created in the cloud hosting in the current environment will be deployed to this VPC and subnet.

This process does not require you to manually set any settings. Later, you can view and manage this VPC and subnet automatically created by cloud hosting in the private network console, or you can deploy more cloud resources in this VPC so that these cloud resources can interact.

2. Custom configuration

If you have created a private network VPC and subnet before, and have deployed other cloud resources in it, and need your cloud hosting application to interact with these existing cloud resources, you can select "Custom Configuration" and then Select a specific VPC and subnet.

Only one VPC can be selected, and multiple subnets can be selected.

successfully opened

Click "Submit", the status will change to active, please wait a few seconds.

After successful activation, you will automatically be redirected to the cloud hosting service list page.

At this point, you have successfully activated the cloud hosting service, you can click "New Service" to start deploying our image bed.

project initialization

Go to the project root directory and type

touch cloudbaserc.json

Configure Cloudbaserc.json

After creating the cloudbaserc.json file, edit the file

{
    "version": "2.0",
    "envId": "{{env.ENV_ID}}",
    "framework":{
        "name":"lsky-pro",
        "plugins":{
            "client": {
                "use": "@cloudbase/framework-plugin-container",
                "inputs": {
                "cpu": 0.5,
                "mem": 1,    
                "serviceName": "lsky-pro",
                "servicePath": "/",
                "localPath": "/",
                "mode":"high-availability",
                "uploadType": "package",
                "containerPort": 80,
                "volumeMounts": {
                    "/var/www/html": "lsky-cfs"
                  }
                }
            }
        },
        "requirement": {
            "addons": [
              {
                "type": "CFS",
                "name": "lsky-cfs"
              },
              {
                "type": "CynosDB",
                "name": "lsky"
              }
            ]
          }
    }
}

For more parameter descriptions, please refer to the cloud hosting container plugin.

Create Dockerfile

According to the demand, edited Dockerfile documents and related files in the project, not one where we explain in detail the matter, specifically refer to within an exemplary warehouse Dockerfile

deployed to cloud hosting

After completing the above series of tasks, we can proceed to the most critical step [ deployment to cloud hosting ].

Upload the project to a code hosting platform such as Github or Gitee, enter the cloud development console, and click "New":

After filling in the relevant information, click Next:

After selecting the region and entering the database administrator password we want to create, click Next:

After the above work is completed, click "Activate Now":

After waiting for a while (deployment may take 5-10 minutes), our project is deployed to cloud development and cloud hosting, and we can see the applications we created in the cloud environment.

Note: The application needs to rely on CFS and Mysql database, so related resources will be created.

Most people, I will not tell him, you can also make a one-click deployment button CloudBase Framework document

Configure related services

After completing the above steps, we have deployed our application to cloud hosting, but there is still the last step to create a database for our image bed (some applications can be created automatically). We click on the Tencent Cloud console menu and click on "TDSQL-C".

Click "Login"

After entering the password, create the database

After the creation is complete, we can go back to the cloud hosting application interface just now. Click "Visit" to jump to the app installation page

Enter the database address of our intranet address!


After the installation is complete, you're done! !

Add domain name (optional)

Click "Access Service" to add domain name information

Finally, configure it according to the requirements and complete the addition.

Precautions

  1. In this example, the copy mode of cloud hosting is highly available, and one copy number is reserved for connection use;
  2. The TDSQL-C database will be suspended in a non-connected state (10 minutes by default). At that time, the database cannot be connected when accessing the application, and the database will be restarted when it is refreshed and accessed again;
  3. After the domain name is configured, CDN acceleration can be performed to ensure the speed of image access.

This example warehouse address Github: https://github.com/Handsomedoggy/lsky-pro

Cloud hosting CloudBase Run official website: https://cloud.tencent.com/product/tcbr

CloudBase Framework 1.5K ✨:https://github.com/Tencent/cloudbase-framework

Author: Cloud Development Evangelist Doggy Xiong Erha

product description

Cloud Development (Tencent CloudBase, TCB) is a cloud-native integrated development environment and tool platform provided by Tencent Cloud. It provides developers with highly available, automatically and elastically scalable back-end cloud services, including serverless capabilities such as computing, storage, and hosting. , Can be used for cloud integration to develop a variety of end applications (small programs, official accounts, web applications, Flutter clients, etc.) to help developers build and manage back-end services and cloud resources in a unified manner, avoiding cumbersome servers in the application development process With construction and operation and maintenance, developers can focus on the realization of business logic, with lower development thresholds and higher efficiency.
Open cloud development: https://console.cloud.tencent.com/tcb?tdl_anchor=techsite
Product documentation: https://cloud.tencent.com/product/tcb?from=12763
Technical document: https://cloudbase.net?from=10004
Technical exchange group, latest information, follow WeChat public account [Tencent Cloud Development CloudBase]


CloudBase云开发
425 声望438 粉丝

云开发(Tencent CloudBase,TCB)是云端一体化的后端云服务 ,采用 serverless 架构,免去了移动应用构建中繁琐的服务器搭建和运维。同时云开发提供的静态托管、命令行工具(CLI)、Flutter SDK 等能力极大的降...