Google 云 运行 即使构建成功也无法访问

Google Cloud Run inaccessible even on successful build

我的 Google Cloud 运行 映像是使用 Cloud Build 通过 Github 存储库成功构建的。我在构建日志中没有看到任何有关内容。

这是我的 Dockerfile:

# Use the official lightweight Node.js 10 image.
# https://hub.docker.com/_/node
FROM node:17-slim

RUN set -ex; \
  apt-get -y update; \
  apt-get -y install ghostscript; \
  apt-get -y install pngquant; \
  rm -rf /var/lib/apt/lists/*

# Create and change to the app directory.
WORKDIR /usr/src/app

# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./

# Install dependencies.
# If you add a package-lock.json speed your build by switching to 'npm ci'.
RUN npm ci --only=production
# RUN npm install --production


# Copy local code to the container image.
COPY . ./

# Run the web service on container startup.
CMD [ "npm", "start" ]

但是当我尝试通过 public URL 访问云时,我看到:

Oops, something went wrong…
Continuous deployment has been set up, but your repository has failed to build and deploy.
This revision is a placeholder until your code successfully builds and deploys to the Cloud Run service myapi in asia-east1 of the GCP project myproject.

What's next?
From the Cloud Run service page, click "Build History".
Examine your build logs to understand why it failed.
Fix the issue in your code or Dockerfile (if any).
Commit and push the change to your repository.

节点应用似乎没有 运行。我做错了什么?

事实证明 cloudbuild.yaml 并不是真正可选的。添加具有以下内容的文件解决了问题:

steps:
    # Build the container image
    - name: "gcr.io/cloud-builders/docker"
      args: ["build", "-t", "gcr.io/$PROJECT_ID/myapi:$COMMIT_SHA", "."]
    # Push the container image to Container Registry
    - name: "gcr.io/cloud-builders/docker"
      args: ["push", "gcr.io/$PROJECT_ID/myapi:$COMMIT_SHA"]
    # Deploy container image to Cloud Run
    - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
      entrypoint: gcloud
      args:
          - "run"
          - "deploy"
          - "myapi"
          - "--image"
          - "gcr.io/$PROJECT_ID/myapi:$COMMIT_SHA"
          - "--region"
          - "asia-east1"
images:
    - "gcr.io/$PROJECT_ID/myapi:$COMMIT_SHA"