Пустая страница в приложении Laravel/PHP + Nginx, настроенном в Dockerfile, развернутом Cloud Run.Php

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Пустая страница в приложении Laravel/PHP + Nginx, настроенном в Dockerfile, развернутом Cloud Run.

Сообщение Anonymous »

При развертывании приложения laravel все выглядит нормально, и докер успешно собирается, но когда я пытаюсь получить доступ к корневой странице, все, что я вижу, это полностью пустой экран, хотя журналы кажутся в порядке?
Dockerfile:

Код: Выделить всё

FROM php:8.2-fpm

# Set env vars
ENV NODE_VERSION=20

RUN apt-get update && apt-get install -y \
zip \
curl \
unzip \
libonig-dev \
libzip-dev \
libpng-dev \
nginx \
git && \
docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

COPY ./nginx.conf /etc/nginx/sites-enabled/default

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

EXPOSE 8080
# Copy the application code
COPY . /var/www/html

# Set the working directory
WORKDIR /var/www/html

# Add vendor binaries to PATH
ENV PATH=/var/www/html/vendor/bin:$PATH

COPY composer.json composer.lock ./

# Install project dependencies
RUN composer install

# Install Node.js and npm
RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - &&  apt-get install -y nodejs

# Set permissions
RUN chown -R www-data:www-data ./
RUN chgrp -R www-data storage bootstrap/cache && \
chmod -R ug+rwx storage bootstrap/cache

RUN npm install

# Build and version Vite assets for production
RUN npm run build

# Make the file executable, or use "chmod 777" instead of "chmod +x"
RUN chmod +x /var/www/html/db-migration.sh

RUN php artisan optimize:clear
RUN php artisan route:clear
RUN php artisan route:cache
RUN php artisan config:clear
RUN php artisan config:cache
RUN php artisan view:clear
RUN php artisan view:cache

# This will run the shell file at the time when container is up-and-running successfully (and NOT at the BUILD time)
ENTRYPOINT ["/var/www/html/db-migration.sh"]
db-migration.sh

Код: Выделить всё

#!/bin/bash
php artisan migrate --force
php artisan optimize
php-fpm -D && nginx -g "daemon off;"
nginx.conf

Код: Выделить всё

server {
listen 8080;

index index.php index.html;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

# the Cloud run service url
server_name dev-xxxxxxxxxx.region-value.run.app;

error_log  /var/log/nginx/error.log;

access_log /var/log/nginx/access.log;

# this should be the path of your public folder in laravel which from our dockerfile
root /var/www/html/public;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffering off;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Журналы Cloud Run:

Код: Выделить всё

> GET 200 9.1 KB 726 ms Chrome 131 https://dev-xxxxxxxxxx.us-central1.run.app/
> 169.xxx.xxx.xxx - - [17/Dec/2024:03:05:39 +0000] "GET / HTTP/1.1" 200 9116 "https://console.cloud.google.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7))"
> 127.0.0.1 -  17/Dec/2024:03:05:39 +0000 "GET /index.php" 200
Что меня озадачивает, так это то, что когда я развертываю это в App Engine, оно правильно обслуживает корневую страницу, что заставляет меня думать, что что-то не так с ручной настройкой Docker и nginx, поскольку в случае с App Engine Мне не пришлось ничего этого делать.
Буду благодарен за любую помощь!

Подробнее здесь: https://stackoverflow.com/questions/792 ... d-by-cloud
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»