(gcloud.run.deploy) Ошибка запуска облака: не удалось запустить контейнер. Не удалось запустить, а затем прослушать порт - PullRequest
0 голосов
/ 31 января 2020

После успешного развертывания контейнера с использованием gcloud builds submit --tag gcr.io/projectname/testserver и последующей попытки запустить gcloud run deploy --image gcr.io/projectname/testserver --platform managed я вижу эту ошибку:

$ gcloud run deploy --image gcr.io/projectname/testserver --platform managed
Please specify a region:
 // options removed

Service name (testserver):  
Allow unauthenticated invocations to [testserver] (y/N)?  y

Deploying container to Cloud Run service [testserver] in project [projectname] region [us-central1]
X Deploying new service... Cloud Run error:
 Container failed to start. Failed to start
 and then listen on the port defined by the
 PORT environment variable. Logs for this r
evision might contain more information.    
  X Creating Revision... Cloud Run error: C
  ontainer failed to start. Failed to start
   and then listen on the port defined by t
  he PORT environment variable. Logs for th
  is revision might contain more informatio
  n.                                       
  . Routing traffic...                     
  ✓ Setting IAM Policy...                  
Deployment failed                          
ERROR: (gcloud.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.

У меня очень простой проект, все в папке root:

// Dockerfile
FROM node:12-slim

# Create app folder
WORKDIR /usr/src/app

# Install app deps. Copy the lock file
COPY package*.json ./
RUN npm install

COPY . ./
CMD ["node", "testServer.js"]
// testServer.js
const Koa = require("koa");
const koa = new Koa();

koa.get('/', async ctx => {
  ctx.body = "Koa server running"
});

const port = process.env.PORT || 8080;

koa.listen(port);

Кто-нибудь знает, что это вызывает? Со вчерашнего дня пытались решить эту проблему, и теперь даже с этим минимальным проектом, похоже, возникают проблемы.

1 Ответ

2 голосов
/ 31 января 2020

Я получил TypeError: app.get is not a function с вашим кодом. Похоже, этот синтаксис устарел. Переписал с koa-router и работал просто отлично.

В любом случае попробуйте проверить локально ваш код с помощью docker, запустите перед развертыванием. А также вы можете найти более точные сообщения об ошибках во время развертывания в console-> logging-> cloud run revision-> revision_id

...