При развертывании приложения 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 Мне не пришлось ничего этого делать.
Буду признателен за любую помощь!
Отредактировано, добавлено:
Результат команды curl -v команда:
curl -v https://dev-xxxxxxxxxxxx.us-central1.run.app
* Host dev-xxxxxxxxxxxx.us-central1.run.app:443 was resolved.
* IPv6: (none)
* IPv4: 216.xxxxxxxx, 216.xxxxxxxx, 216.xxxxxxxx, 216.xxxxxxxx
* Trying 216.xxxxxxxx...
* Connected to dev-xxxxxxxxxxxx.us-central1.run.app (216.xxxxxxxx) port 443
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server accepted h2
* Server certificate:
* subject: CN=*.a.run.app
* start date: Nov 4 08:37:29 2024 GMT
* expire date: Jan 27 08:37:28 2025 GMT
* subjectAltName: host "dev-xxxxxxxxxxxx.us-central1.run.app" matched cert's "*.us-central1.run.app"
* issuer: C=US; O=Google Trust Services; CN=WR2
* SSL certificate verify ok.
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://dev-xxxxxxxxxxxx.us-central1.run.app/
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: dev-xxxxxxxxxxxx.us-central1.run.app]
* [HTTP/2] [1] [:path: /]
* [HTTP/2] [1] [user-agent: curl/8.7.1]
* [HTTP/2] [1] [accept: */*]
> GET / HTTP/2
> Host: dev-xxxxxxxxxxxx.us-central1.run.app
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/2 200
< content-type: text/html; charset=UTF-8
< x-powered-by: PHP/8.2.26
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
< date: Tue, 17 Dec 2024 15:18:12 GMT
< server: Google Frontend
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
console.log('Debug Objects: XXXXXXXXXXXXXXXXXXXXXXXX:test_string' );
SST
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-by-cloud
Пустая страница в приложении Laravel/PHP + Nginx, настроенном в Dockerfile, развернутом Cloud Run. ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение