简体   繁体   中英

Unable to deploy October/Laravel to Google cloud platform

I have literally been banging my head for hours on end trying to figure out where my code is faulty. Trying to deploy a fresh install of October/Laravel to a App engine instance on Google cloud.

Error message is a typical fatal 500

This page isn’t working 
xx.appspot.com is currently unable to handle this request. 
HTTP ERROR 500

Looking at the logs in Google cloud platform ir seems that the initial GET request with the 500 response happens before any of the fatal errors regarding logging.

在此处输入图片说明

The codebase works fine on my local environment connected to the Google SQL engine via the SQL proxy. It seems to be either one of these two things:

  1. Permission issue with the logging (unlikely because there is a 500 error before that.
  2. Issue with the configuration? Went over the app.yaml file a hundred times and the SQL configs seems to be alright because it is working on local with the same DB.
  3. Something else related to how October is configured? What?

app.yaml file:

runtime: php
env: flex

runtime_config:
  document_root: .

# Ensure we skip ".env", which is only for local development
  skip_files:
    - .env

env_variables:
# Put production environment variables here.
APP_LOG: errorlog
APP_KEY: xxxx
STORAGE_DIR: /tmp
CACHE_DRIVER: database
SESSION_DRIVER: database

## Set these environment variables according to your CloudSQL configuration.
MYSQL_DSN: mysql:unix_socket=/cloudsql/xxx;dbname=yyy
MYSQL_USER: xx
MYSQL_PASSWORD: xx

beta_settings:
  # for Cloud SQL, set this value to the Cloud SQL connection name,
  # e.g. "project:region:cloudsql-instance"
  cloud_sql_instances: "xx"

Any help on this would be greatly appreciated <3

About question 1: Permissions issue can be resolved by setting "runtime: custom" in app.yaml and creating a Dockerfile.

FROM gcr.io/google-appengine/php73
 
ARG COMPOSER_FLAGS='--prefer-dist'
ENV COMPOSER_FLAGS=${COMPOSER_FLAGS}
ENV SWOOLE_VERSION=4.3.4
ENV DOCUMENT_ROOT=/app
 
COPY . $APP_DIR
 
RUN apt-get update -y \
&& apt-get install -y \
unzip \
autoconf \
build-essential \
libmpdec-dev \
libpq-dev \
&& pecl install decimal \
&& curl -o /tmp/swoole.tar.gz https://github.com/swoole/swoole-src/archive/v$SWOOLE_VERSION.tar.gz -L \
&& tar zxvf /tmp/swoole.tar.gz \
&& cd swoole-src* \
&& phpize \
&& ./configure \
--enable-async-redis \
&& make \
&& make install \
&& chown -R www-data.www-data $APP_DIR \
&& /build-scripts/composer.sh \
&& mv $APP_DIR/storage $APP_DIR/storagestatic \
&& ln -s /tmp $APP_DIR/storage \
&& cp -TRv $APP_DIR/storagestatic/ $APP_DIR/storage/ \
&& chown -R www-data.www-data $APP_DIR/storage \
&& chmod -R 777 $APP_DIR/storage ;
 
ENTRYPOINT ["/build-scripts/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
 
EXPOSE 8080

About questions 2 and 3: You need to configure multiple env_variables and modify Laravel configuration accordingly. Below is a sample of app.yaml:

env_variables:
APP_STORAGE_PATH: gs://inset-bucket-name/storage/app
APP_STORAGE_URL: https://storage.googleapis.com/inset-bucket-name/storage/app
APP_DEBUG: false
APP_ENV: production
SESSION_DRIVER: cookie
DATABASE_HOST: insert-database-ip
DATABASE: insert-database-name
DATABASE_USERNAME: insert-database-user
DATABASE_PASSWORD: insert-database-password
DATABASE_PORT: 3306
URL: insert-app-engine-url
KEY: insert-laravel-key
CIPHER: AES-256-CBC

Full tutorial: https://webmotion.medium.com/how-to-install-octobercms-laravel-application-on-google-app-engine-c77a9185f420

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM