Cloud Run imposes the listening port: it injects the PORT variable (8080 by default) and its TCP
startup probe expects something listening on that port. Salma's rewrite replaced process.env.PORT with
app.listen(3000): the process does start (“port 3000” in the logs), but nothing listens on 8080, the
probe fails and the revision never becomes ready.
The image exists (Artifact Registry), a permissions problem on the image would give a download error, and lengthening the timeout would change nothing: the probe waits 240 s for a port that nobody will open. Meanwhile, the old revision keeps serving: Cloud Run only shifts traffic to a revision that is ready.
Incident resolved
Analysis and fix
Fix: read the port from the environment in server.js
(const port = Number(process.env.PORT) || 8080; app.listen(port)), then redeploy
(gcloud run deploy api-commandes --source .). As a quick workaround, --port=3000 also works:
Cloud Run then injects PORT=3000.
To prevent it from happening again:
- team rule: the port always comes from
$PORT(12-factor), never hard-coded; - test the image the way Cloud Run starts it:
docker run -e PORT=8080 -p 8080:8080 …thencurl; - a CI step that starts the container on a random port and checks
/sante; - read the revision logs before touching timeouts or resources.