用Aliyun服务搭了个Serverless小Demo,希望对大家有所启发
发布于 5 年前 作者 yort-feng 4113 次浏览 来自 分享

Github地址, React + Nodejs

How it works

how-it-works.png

  1. OSS - Object Storage Service An encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world
  2. API-Gateway API Gateway provides you with high-performance and highly available API hosting services to deploy and release your APIs on Alibaba Cloud products.
  3. Function Compute A fully hosted and serverless running environment that takes away the need to manage infrastructure such as servers and enables developers to focus on writing and uploading code.
  4. OTS - Table Store A fully managed NoSQL cloud database service that enables storage of a massive amount of structured and semi-structured data.

Quick Start

  1. Registe for an Aliyun account

  2. Install Fun

    • npm install @alicloud/fun -g
  3. Configuration, there are two ways, choose one of the following

    • fun config, just execute this command
    • add .env file and remember add it to .gitignore
  4. Create a Table Store Instance and Table, the table store address of Aliyun

    • Create Instance, the default name is serverless, if you’d like to change it, you need to replace the EnvironmentVariables.InstanceName of the template.yml with yours.
    • Create Table, the defualt name is reflection, if you’d like to change it, you need to replace the EnvironmentVariables.InstanceName of the template.yml with yours.
    • Add primary keys, id’s type is autoIncrement company Type: INTEGER Name: id Type: INTEGER
  5. Fun Deploy

  6. Build and Deploy frontend application

    • npm build
      npm install
      npm run build
      
    • create OSS buket, make it Public to allow erveryone can visit it.
    • import static files to the OSS buket
    • Basic Settings -> Static Pages
    • Bind Self-Hosted Domain Name(Not necessary)
回到顶部