在 Cloud Run 上使用 Docker 部署 Laravel 会在包含 Supervisord 时返回 Container failed to start 错误

问题描述 投票:0回答:1

我正在尝试使用 Docker 将一个带有 apache 的 Laravel 项目部署到 Cloud Run,一切正常,我成功地将我的项目部署到 Cloud Run,没有任何问题,但是当我添加主管并尝试再次部署我的项目时,我收到此错误:

容器启动失败。启动失败然后监听端口 由 PORT 环境变量定义

enter image description here

我已经测试了从本地计算机构建它的 doker 图像,这是可以的。

我的 laravel 项目具有以下结构:

laravel_project
---docker
------.env-pro
------000-default.conf
------php.ini
---supervisord.conf
---Dockerfile

没有supervisord的Docker文件可以正确运行:

FROM php:7.4-apache
ENV PORT 80
ENTRYPOINT []
CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground
RUN a2enmod rewrite

RUN apt-get update && apt-get install -y \
        zlib1g-dev \
        libicu-dev \
        libxml2-dev \
        libpq-dev \
        libzip-dev \
        && docker-php-ext-install pdo pdo_mysql zip intl xmlrpc soap opcache \
        && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd

RUN apt-get update -y

# Add Node 8 LTS
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -- \
    && apt-get install -y nodejs \
    && apt-get autoremove -y

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY  docker/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY  docker/.env-pro /var/www/html/.env
COPY  docker/php.ini /usr/local/etc/php/php.ini

ENV COMPOSER_ALLOW_SUPERUSER 1

COPY  . /var/www/html/
WORKDIR /var/www/html/

RUN chown -R www-data:www-data /var/www/html  \
    && composer install

RUN chmod -R 777 /var/www/html/storage

具有 Supervisord 并生成问题的 Docker 文件:

FROM php:7.4-apache
ENV PORT 80
ENTRYPOINT []
CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground
RUN a2enmod rewrite

RUN apt-get update && apt-get install -y \
        zlib1g-dev \
        libicu-dev \
        libxml2-dev \
        libpq-dev \
        libzip-dev \
        && docker-php-ext-install pdo pdo_mysql zip intl xmlrpc soap opcache \
        && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd

RUN apt-get update -y

# Add Node 8 LTS
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -- \
    && apt-get install -y nodejs \
    && apt-get autoremove -y

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY  docker/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY  docker/.env-pro /var/www/html/.env
COPY  docker/php.ini /usr/local/etc/php/php.ini

ENV COMPOSER_ALLOW_SUPERUSER 1

COPY  . /var/www/html/
WORKDIR /var/www/html/

RUN chown -R www-data:www-data /var/www/html  \
    && composer install

RUN chmod -R 777 /var/www/html/storage

RUN apt-get update && apt-get install -y supervisor

RUN mkdir -p /var/log/supervisor

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

EXPOSE 22 80
CMD ["/usr/bin/supervisord"]

docker/000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname, and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # The value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/public

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

supervisord.conf

[supervisord]
nodaemon=true
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php %(ENV_APP_ROOT)s/artisan queue:work %(ENV_QUEUE_DRIVER)s %(ENV_OPTIONS)s
stdout_logfile=%(ENV_APP_ROOT)s/storage/logs/worker.log
autostart=true
autorestart=true
numprocs=%(ENV_NUM_PROCS)s
redirect_stderr=true
stopwaitsecs=3600

docker/.env-pro

APP_NAME="My project"
APP_ENV=production
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=https://myproject.com


LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxxxxx
DB_USERNAME=xxxxxx
DB_PASSWORD=xxxxxx
DB_SOCKET="xxxxxx"

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=database
SESSION_LIFETIME=120

APP_ROOT=/var/www/html
QUEUE_CONNECTION=database
QUEUE_OPTIONS="--sleep=3 --tries=3"
NUM_PROCS=4

MEMCACHED_HOST=127.0.0.1

MAIL_MAILER=mailjet
MAILJET_APIKEY=xxxxxxxxxxxxxxxxxxx
MAILJET_APISECRET=xxxxxxxxxxxxxxxxxxx
MAIL_FROM_ADDRESS=xxxxxxxxxxxxxxxxxxx
MAIL_FROM_NAME=xxxxxxxxxxxxxxxxxxx

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

SANCTUM_STATEFUL_DOMAINS="aula.estudio-sandbox.app"
SESSION_DOMAIN=".estudio-sandbox.app"

GOOGLE_CLIENT_ID=xxxxxxxxxxxxxxxxxxx
GOOGLE_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxx
GOOGLE_REDIRECT=xxxxxxxxxxxxxxxxxxx
GOOGLE_APP_URL=xxxxxxxxxxxxxxxxxxx
GOOGLE_PUB_SUB_TOPIC=xxxxxxxxxxxxxxxxxxx

LOG_SLACK_WEBHOOK_URL=xxxxxxxxxxxxxxxxxxx

BUGSNAG_API_KEY=xxxxxxxxxxxxxxxxxxx

docker/php.ini
的内容只是一个普通的
php.ini
文件。

laravel docker supervisord google-cloud-run
1个回答
0
投票

querida comunidad,我 podrian indicar como desplegar un proyecto de laravel en cloud run,你想要在本地进行 hacerlo creando el contenedor,por integracion que es como la segunda option y aun asi no me ha sido posible,他访问教程 y Demas pero aun no logro subirlo de manera efectiva alone recibo errores

© www.soinside.com 2019 - 2024. All rights reserved.