<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          使用 Serverless Devs 插件快速部署前端應(yīng)用

          共 3185字,需瀏覽 7分鐘

           ·

          2022-04-25 18:22

          后臺(tái)回復(fù)?手冊(cè)?即刻免費(fèi)下載 2022 Serverless 工具書

          作者 |?鄧超 ?Serverless Devs 開源貢獻(xiàn)者


          背景


          上周,我們?cè)?a target="_blank" textvalue="《如何使用 Serverless Devs 部署靜態(tài)網(wǎng)站到函數(shù)計(jì)算》" linktype="text" imgurl="" imgdata="null" data-itemshowtype="0" tab="innerlink" data-linktype="2">《如何使用 Serverless Devs 部署靜態(tài)網(wǎng)站到函數(shù)計(jì)算》中,詳細(xì)地介紹了如何通過?@serverless-devs/s?將已經(jīng)開發(fā)好了的靜態(tài)網(wǎng)站部署到阿里云函數(shù)計(jì)算(FC)上。


          但是近期函數(shù)計(jì)算和?@serverless-devs/s?都更新了一系列的功能, 目前部署靜態(tài)網(wǎng)站的步驟可以更簡(jiǎn)潔了!下面我們就一起看一下具體的操作步驟吧。


          項(xiàng)目實(shí)操分享


          使用 Serverless Devs 插件部署靜態(tài)網(wǎng)站到 Custom Runtime 函數(shù):


          假設(shè)我們現(xiàn)在已有如下結(jié)構(gòu)的前端工程;


          /├ dist/ 待部署的構(gòu)建產(chǎn)物│  └ index.html ├ src/package.json


          step 3.安裝?@serverless-devs/s?并編寫 s.yaml

          你問我步驟 1 和 2 去哪兒了? 當(dāng)然是省掉了!?

          然后我們添加 @serverless-devs/s 命令行工具到工程:

          yarn add @serverless-devs/s -D

          然后在根目錄下創(chuàng)建一個(gè)基礎(chǔ)的 s.yaml 配置文件:


          # https://github.com/devsapp/fc/blob/main/docs/zh/yaml/edition: 1.0.0name: my-awesome-website-projectservices:  my-service: # 任意的名稱    actions:      pre-deploy:        # 在 pre-deploy 插槽中安裝 website-fc 插件        - plugin: website-fc         # 使用 fc 組件    component: devsapp/fc           props:      # 部署到任意的可用區(qū), 例如深圳.      region: cn-shenzhen             service:        # 深圳可用區(qū)的 my-awesome-websites 服務(wù)        name: my-awesome-websites         function:        # my-awesome-websites 服務(wù)下的一個(gè)函數(shù)        name: website-fc-plugin            # 使用 custom 運(yùn)行環(huán)境        runtime: custom                # 由于使用了 custom 運(yùn)行環(huán)境, 所以這里可以隨便填        handler: dummy-handler             # 部署 dist 文件夾下的全部?jī)?nèi)容        codeUri: ./dist              triggers:        - name: http          # 創(chuàng)建一個(gè) HTTP 類型的觸發(fā)器, 以便客戶端可以通過 HTTP 協(xié)議進(jìn)行訪問          type: http                  config:            # 允許匿名訪問            authType: anonymous                # 靜態(tài)網(wǎng)站只需要處理 HEAD 和 GET 請(qǐng)求就夠了            methods: [ HEAD, GET ]


          與上文中不同的地方在于:


          actions:      pre-deploy:        - plugin: website-fc     # 在 pre-deploy 插槽中安裝 website-fc 插件


          pre-deploy 插槽中安裝的 website-fc 插件能代替上文中的步驟 1 和步驟 2;


          以及:


           # 部署 dist 文件夾下的全部?jī)?nèi)容        codeUri: ./dist


          現(xiàn)在不必將整個(gè)工程部署到函數(shù)中, 只需要部署構(gòu)建好的靜態(tài)文件了。
          step 4.部署到函數(shù)計(jì)算

          配置好 AccessKey?和?AccessSecret[6]?,執(zhí)行命令:

          s deploy

          你的網(wǎng)站就部署上去啦。

          接下來就是配置自定義域名了, 配置好以后就可以通過你自己的域名訪問到這個(gè)網(wǎng)站了。

          step?5.?配置自定義域名


          以自定義域名 deploy-static-website-with-website-fc-plugin.example.dengchao.fun 為例。

          首先添加 CNAME 記錄, 解析值填寫 ${UID}.${REGION}.fc.aliyuncs.com。因?yàn)槲覀兊?s.yaml 中設(shè)置的 regioncn-shenzhen, 所以對(duì)應(yīng)的值就是 xxxxxx.cn-shenzhen.fc.aliyuncs.com?。



          接下來設(shè)置函數(shù)計(jì)算控制臺(tái)上的自定義域名:



          訪問一下試試看:

          http://deploy-static-website-with-website-fc-plugin.example.dengchao.fun

          樣本工程


          本文中的樣本工程已經(jīng)上傳到 GitHub:

          https://github.com/DevDengChao/deploy-static-website-with-website-fc-plugin-example


          參考鏈接:


          [1]?阿里云函數(shù)計(jì)算-產(chǎn)品簡(jiǎn)介

          https://help.aliyun.com/document_detail/52895.html


          [2]?資源使用限制

          https://help.aliyun.com/document_detail/51907.html


          [3]?自定義運(yùn)行環(huán)境

          https://help.aliyun.com/document_detail/132044.html


          [4]?配置自定義域名

          https://help.aliyun.com/document_detail/90763.html


          [5]?Serverless devs 官網(wǎng)

          https://www.serverless-devs.com/


          [6]?配置 AccessKey 和 AccessSecret

          https://www.serverless-devs.com/serverless-devs/command/config


          [7]?website-fc 插件

          https://github.com/devsapp/website-fc









          RECRUITMENT


          RECRUITMENT

          極速上手?Serverless



          為了讓開發(fā)者快速定位 Serverless 開發(fā)問題,找到對(duì)應(yīng)解決辦法,阿里云云原生 Serverless 團(tuán)隊(duì),全新發(fā)布 2022 版本《Serverless開發(fā)速查手冊(cè)》目前已開放下載,我們希望給 Serverless 開發(fā)者提供一本能夠速查、速懂的工具書,實(shí)實(shí)在在幫助開發(fā)者快速解決 Serverless 開發(fā)遇到的實(shí)際問題,讓大家能夠踏踏實(shí)實(shí)享受 Serverless 帶來的技術(shù)紅利!后臺(tái)回復(fù)?手冊(cè)?即可下載閱讀。


          RECRUITMENT


          READ?MORE?



          基于 Serverless 架構(gòu)的頭像漫畫風(fēng)處理小程序


          人人都是 Serverless 架構(gòu)師系列項(xiàng)目私藏分享?| “盲盒抽獎(jiǎng)”創(chuàng)意營(yíng)銷活動(dòng)


          若您對(duì)產(chǎn)品使用或者技術(shù)學(xué)習(xí)有任何疑問 & 建議,歡迎后臺(tái)回復(fù)?“進(jìn)群”?加入阿里云 Serverless 開發(fā)者技術(shù)學(xué)習(xí)群交流。


          戳下方,詳細(xì)了解 Serverless Devs!
          瀏覽 63
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  jzzijzzij亚洲成熟少妇在线播放 | 欧美亚洲黄色电影免费收看 | 五月青春操 | 亚洲 日韩 中文字 | 久久无人区 |