阅读(419) (0)

Micronaut Google Cloud Run

2023-02-23 13:44:25 更新

要部署到 Google Cloud Run,我们建议使用 JIB 来容器化您的应用程序。

使用 CLI

使用 JIB 创建应用程序:

$ mn create-app my-app --features jib

或者使用 Micronaut Launch

$ curl https://launch.micronaut.io/example.zip\?features\=jib -o example.zip
$ unzip example.zip -d example

使用 JIB 设置将您的应用程序部署到 Google Container Registry,运行:

$ ./gradlew jib

您现在已准备好部署您的应用程序:

$ gcloud run deploy --image gcr.io/[PROJECT ID]/example --platform=managed --allow-unauthenticated

其中 ​[PROJECT ID]​ 是您的项目 ID。系统会要求您指定区域,并会看到如下输出:

Service name: (example):
Deploying container to Cloud Run service [example] in project [PROJECT_ID] region [us-central1]

✓ Deploying... Done.
  ✓ Creating Revision...
  ✓ Routing traffic...
  ✓ Setting IAM Policy...
Done.
Service [example] revision [example-00004] has been deployed and is serving 100 percent of traffic at https://example-9487r97234-uc.a.run.app

URL 是您的 Cloud Run 应用程序的 URL。