简体   繁体   English

GCP 中的 Cloud Run 服务显示“Container failed to start and then listen on the port defined by 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

I am trying continuous deployment of codeigniter 4 application from github repo using cloud build in GCP, but it shows failed to listen port but I used port environment variable, Help me with this error我正在尝试使用 GCP 中的云构建从 github repo 持续部署 codeigniter 4 应用程序,但它显示无法监听端口,但我使用了端口环境变量,帮我解决这个错误

My Docker File我的 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}

My composer.json file我的 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"]

I used apache instead of fpm and it works but I still don't know why fpm is not working我使用 apache 而不是 fpm 并且它工作但我仍然不知道为什么 fpm 不工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Cloud Run 错误:容器无法启动。 无法启动然后侦听 PORT 环境变量定义的端口。 - Django - Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. - Django Cloud Run:部署 spring docker 映像导致错误; 无法启动并监听 PORT 环境变量定义的端口 - Cloud Run: deploying spring docker image causing error; Failed to start and then listen on the port defined by the PORT environment variable 我无法解决“无法启动并侦听 PORT 环境变量定义的端口”。 带有 Docker 图像的 Google Cloud Run 错误 - I cannot resolve "Failed to start and then listen on the port defined by the PORT environment variable." error in Google Cloud Run with a Docker image Cloud Run 错误:容器无法启动。 启动失败,然后监听端口 - Cloud Run error: Container failed to start. Failed to start and then listen on the port 赛普拉斯:容器无法启动。 无法启动并监听 PORT 定义的端口 - Cypress: Container failed to start. Failed to start and then listen on the port defined by the PORT 即使将端口更改为 8080,Google Cloud Run 也无法侦听 - Google Cloud Run fails to listen even after changing port to 8080 GCP 云运行容器服务:[pool www] 无法写入套接字 '/run/php-fpm/www.sock' 的 ACL - GCP Cloud run container service : [pool www] failed to write the ACL of the socket '/run/php-fpm/www.sock' Azure 应用服务容器无法在端口 443 上启动 - Azure app service container failing to start on port 443 在环境变量中指定的端口而不是 9000 上启动 sonarqube - Start sonarqube on port specified in environment variable instead of 9000 Google Cloud Run 错误:容器无法启动(DSS - 数字签名服务) - Google Cloud Run error: Container failed to start (DSS - Digital Signature Service)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM