Giter Site home page Giter Site logo

dns's Introduction

oss 阿里云静态资源 OSS 组件 ⎯⎯⎯ 通过使用 Serverless-Devs,基于云上 Serverless 的对象存储服务,实现“0”配置,便捷开发,极速上传您的静态资源托管到阿里云对象存储OSS(Object Storage Service)。 静态资源OSS组件支持丰富的配置扩展,提供了目前最易用、低成本并且弹性伸缩的静态站点开发和托管能力。

特性介绍:

  • 按需付费 - 按照请求的使用量进行收费,没有请求时无需付费
  • "0"配置 - 只需要关心项目代码,之后部署即可,Serverless-Devs 会搞定所有配置。
  • 极速部署 - 仅需几秒,部署你的静态网站。

快速开始:

  1. 安装
  2. 创建资源
  3. 部署
  4. 配置
  5. 账号配置

 

1. 安装

通过 npm 安装最新版本的 Serverless Devs

$ npm install @serverless-devs/s -g

2. 创建资源

新建文件,如下:

├── src
│   ├── index.js
│   └── index.html
└── s.yml

src 目录中既可以托管简单的 html 文件,也可以托管完整的 React/Vue 的应用。

3. 部署

s.yml 文件下的目录中运行如下命令进行部署。部署完毕后,你可以在命令行的输出中查看到你静态资源的 OSS URL 地址,点击地址即可访问网站托管的链接。

$ s deploy

如果希望查看更多部署过程的信息,可以通过s deploy --debug 命令查看部署过程中的实时日志信息


4. 配置

静态网站组件支持 0 配置部署,也就是可以直接通过配置文件中的默认值进行部署。但你依然可以修改更多可选配置来进一步开发该静态网站项目。

以下是 OSS 组件的 s.yml部分配置说明:

# s.yml
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
name: oss-demo # (必填) 项目名称
access: 'hfs-access'

services:
  oss-demo:
    component: oss # (必填) 引用 component 的名称
    access: default
    props:
      bucket: my-bucket
      src:
        codeUri: './src'
        publishDir: './build'
        index: index.html
        error: index.html
      region: cn-hangzhou

当你根据该配置文件更新配置字段后,再次运行 s deploy

账号配置

通过serverless Devs工具添加密钥信息

$ s config add

注意:本组件只支持阿里云,需要选择阿里云密钥信息

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.