0

我还没有在我的 M1 Macbook 上安装 Rosetta。安装了 Docker 和所有的 deps,这甚至工作了几次,但不确定是什么突然导致了这个错误:

Starting to run the app using configuration 'Cloud Run: Run/Debug Locally' from .vscode/launch.json...
To view more detailed logs, go to Output channel : "Cloud Run: Run/Debug Locally - Detailed"
Dependency check started
Dependency check succeeded
Starting minikube, this may take a while.............
minikube successfully started
The minikube profile 'cloud-run-dev-internal' has been scheduled to stop automatically after exiting Cloud Code. To disable this on future deployments, set autoStop to false in your launch configuration /Users/myname/Code/myprojectAPI/.vscode/launch.json
Configuring minikube gcp-auth addon
Using GCP project 'myproject-com' with minikube gcp-auth


Update initiated
Build started for artifact myprojectapi
Build completed for artifact myprojectapi

Deploy started
Deploy completed

Status check started
Resource pod/myprojectapi-8695998b94-9lk7d status updated to In Progress
Resource pod/myprojectapi-8695998b94-9lk7d status updated to In Progress
Resource deployment/myprojectapi status failed with waiting for rollout to finish: 0 of 1 updated replicas are available...
Status check failed

The image was built but failed to start on the cluster. Because you are on an ARM64 machine, it is likely that you built an ARM64 image for an x86_64 cluster.
Update failed with error code STATUSCHECK_CONTAINER_TERMINATED
1/1 deployment(s) failed
Skaffold exited with code 1.
Cleaning up...
Finished clean up.

Dockerfile

FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim

RUN set -ex; \
  apt-get -y update; \
  curl -fsSL https://deb.nodesource.com/setup_17.x | bash -; \
  apt-get -y install nodejs; \
  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" ]

我正在使用 Cloud Code 扩展在 VS Code 中部署“Cloud Run Emulator”。

我究竟做错了什么?

4

1 回答 1

1

我可以确认gcr.io/google.com/cloudsdktool/cloud-sdk:slim您使用的图像Dockerfile是 x86_64 图像,它与基于 ARM64 的 M1 Mac 不兼容。由于 CloudSDK 目前没有任何基于 ARM64 的映像,因此需要使用 CloudSDK 创建您自己的基础映像。这样做的步骤是:

  1. Dockerfile将您指向的行更新gcr.io/google.com/cloudsdktool/cloud-sdk:slim为新的基础图像(debian:buster-slim例如)
  2. 将 CloudSDK 工具安装到映像上。它在您的 中应该看起来像这样Dockerfile
# Downloads the gCloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz

# Installs the package
RUN mkdir -p /usr/local/gcloud \
  && tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
  && /usr/local/gcloud/google-cloud-sdk/install.sh --quiet

# Adds the package path to local
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin

运行这些步骤后,您应该会得到一个安装了 CloudSDK 的新基础映像!如果您对某些上下文或其他配置选项感到好奇,请查看有关多架构支持的 Docker 文档页面

于 2022-02-10T21:05:31.503 回答