# 專案一秒起飛Cloud Run ![](https://i.imgur.com/kFIgQ4E.png) --- ## 功能 ![](https://i.imgur.com/ySB9S0N.png) [Cloud Run Doc](https://cloud.google.com/run?hl=zh-tw#section-1) > 圖片來源 Google Cloud Platform官網 ---- ![](https://i.imgur.com/onoZV5U.png) > 也就是說你可以去讓你的 **網站,後端,應用程式** 去自動部屬 ---- ## 使用GCP前 建議裝個Goolge Cloud SDK > 當然不裝的話也可以 在Web上點選也可以 [Link](https://ithelp.ithome.com.tw/articles/10217683) --- ## Okay 開搞 Step 1. 建立GCP專案 > 朋朋們在此初體驗搞個免費方案就好啦,別亂刷卡喔 前面帳戶設置就不提供範例,想必大家都是順ㄅ 辦理完之後進到GCP Console 且點選GCP的專案下拉式選單 ![](https://i.imgur.com/JPbPFol.png) 點選建立專案 Complete !! ---- ## Step 2. 找一個現有專案 > 當然你沒有專案也沒關係,我們著重在Cloud Run的教學。 如果你有裝 git ,clone下來吧 ```shell= git clone https://github.com/CATaiwan/cloud-run-api-demo ``` 我們感謝CATaiwan ---- ## Step 3. 專案環境 這個專案使用Python FastAPI進行後端開發 進到專案目錄 且確保你是有裝Google Cloud SDK的 ```shell= cd cloud-run-api-demo gcloud init #GCP專案初始化 ``` 在GCP的Console 請開啟Artifact Registry API ![](https://i.imgur.com/a6HFRCr.png) Enable 就對了 當然你在 Terminal 使用 Google Cloud SDK他也會問你要不要啟用此API ---- ## Step 4. 專案起飛 **翻譯蒟蒻: gcloud run deploy $應用名稱 --source(來源) .(來源專案directory) --region(選擇區域) $區域** **需在Terminal 安裝 Google Clould SDK** ```shell= gcloud run deploy hello --source . --region asia-east1 ``` 猛吧 一條指令立即生成部屬 ---- ## 當然如果你習慣使用Docker 部屬的也可以 請參考這裡 [Click Me](https://blog.cloud-ace.tw/application-modernization/serverless/cloud-run-api-server/)
{"metaMigratedAt":"2023-06-17T13:06:40.839Z","metaMigratedFrom":"YAML","title":"專案一秒起飛Cloud Run","breaks":true,"contributors":"[{\"id\":\"4c8f8799-9dcd-430b-b7bc-8a5156d39d0b\",\"add\":1540,\"del\":130}]"}
    319 views