GCP 中的云 运行 服务显示 "Container failed to start and then listen on the port defined by the PORT environment variable" Codeigniter 4

Cloud Run service in GCP shows "Container failed to start and then listen on the port defined by the PORT environment variable" Codeigniter 4

我正在尝试使用 GCP 中的云构建从 github 存储库持续部署 codeigniter 4 应用程序,但它显示无法侦听端口但我使用了端口环境变量,帮我解决这个错误

我的Docker文件

FROM php:fpm

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "libzip-dev"]
RUN ["apt-get", "install", "-y", "zip"]
RUN ["apt-get", "install", "-y", "unzip"]
RUN ["apt-get", "install", "-y", "libxml2-dev"]
RUN ["docker-php-ext-install", "soap"]
RUN ["docker-php-ext-configure", "zip"]
RUN ["docker-php-ext-install", "mysqli", "pdo", "pdo_mysql", "zip"]

RUN touch /usr/local/etc/php/conf.d/uploads.ini \
    && echo "upload_max_filesize=64M;\r\n post_max_size=128M;\r\nmemory_limit = 512M" >> /usr/local/etc/php/conf.d/uploads.ini

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY ./writable /var/www/html/writable

## Install codeIgniter Dependecies
COPY ./composer.json /var/www/html/composer.json
RUN cd /var/www/html/ && composer update /var/www/html/ --no-dev --ignore-platform-reqs "vendor/*"

RUN cd /var/www/html/
#RUN ["chmod", "-R", "777", "writable/"]
RUN ["chown", "-R", "www-data:www-data", "/var/www/html/"]
########################################

EXPOSE ${PORT}

我的 composer.json 文件

{
  "name": "codeigniter4/appstarter",
  "type": "project",
  "description": "CodeIgniter4 starter app",
  "homepage": "https://codeigniter.com",
  "license": "MIT",
  "require": {
    "php": ">=7.2",
    "codeigniter4/framework": "^4"
  },
  "require-dev": {
    "mikey179/vfsstream": "1.6.*",
    "phpunit/phpunit": "8.5.*"
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\Support\": "tests/_support"
    }
  },
  "scripts": {
    "test": "phpunit",
    "post-update-cmd": [
      "@composer dump-autoload"
    ]
  },
  "support": {
    "forum": "http://forum.codeigniter.com/",
    "source": "https://github.com/codeigniter4/CodeIgniter4",
    "slack": "https://codeigniterchat.slack.com"
  }
}
FROM php:7.3-apache

RUN apt-get update
RUN apt-get upgrade -y

RUN apt-get install --fix-missing -y libpq-dev
RUN apt-get install --no-install-recommends -y libpq-dev
RUN apt-get install -y libxml2-dev libbz2-dev zlib1g-dev
RUN apt-get -y install libsqlite3-dev libsqlite3-0 mariadb-client curl exif ftp
RUN docker-php-ext-install intl
RUN apt-get -y install --fix-missing zip unzip

RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer self-update

RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

ADD conf/apache.conf /etc/apache2/sites-available/000-default.conf

RUN a2enmod rewrite

RUN printf "#!/bin/bash\n/usr/sbin/apache2ctl -D FOREGROUND" > /startScript.sh
RUN chmod +x /startScript.sh

RUN cd /var/www/html
COPY . /var/www/html/
COPY ./.env.example /var/www/html/.env
COPY ./composer.json /var/www/html/composer.json

RUN composer update /var/www/html/ --no-dev --ignore-platform-reqs "vendor/*"
RUN chmod -R 0777 /var/www/html/writable

RUN apt-get clean \
    && rm -r /var/lib/apt/lists/*

EXPOSE ${PORT}
VOLUME ["/var/www/html", "/var/log/apache2", "/etc/apache2"]

CMD ["bash", "/startScript.sh"]

我使用 apache 而不是 fpm,它可以工作,但我仍然不知道为什么 fpm 不工作