Google App Engine and Laravel, some bug? - php

I am trying to deploy my laravel app into the GCS (Google Cloud Storage).
While doing a deployment:
gcloud preview app deploy ./app.yaml --project="cuisinedegeek-151614"
I got these errors:
WARNING: The gcloud preview app command group is deprecated; please use the gcloud app commands instead.
ERROR: The [application] field is specified in file [/home/epistolshow/CuisineDeGeek/app.yaml]. This field is not used by gcloud and must be removed. Project name should instead be specified either by gcloud config set project MY_PROJECT or by setting the --project flag on individual command executions.
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration.
epistolshow#cuisinedegeek-151614:~/CuisineDeGeek$ gcloud app deploy ./app.yaml --project="cuisinedegeek-151614"
ERROR: The [application] field is specified in file [/home/epistolshow/CuisineDeGeek/app.yaml]. This field is not used by gcloud and must be removed. Project name should instead be specified either by gcloud config set project MY_PROJECT or by setting the --project flag on individual command executions.
ERROR: (gcloud.app.deploy) Errors occurred while parsing the App Engine app configuration.
epistolshow#cuisinedegeek-151614:~/CuisineDeGeek$ gcloud app deploy ./app.yaml --project="cuisinedegeek-151614"
ERROR: The [application] field is specified in file [/home/epistolshow/CuisineDeGeek/app.yaml]. This field is not used by gcloud and must be removed. Project name should instead be specified either by gcloud config set project MY_PROJECT or by setting the --project flag on individual command executions.
ERROR: (gcloud.app.deploy) Errors occurred while parsing the App Engine app configuration.
epistolshow#cuisinedegeek-151614:~/CuisineDeGeek$
Which doesn't make sense because app.yaml:
runtime: php55
handlers:
- url: /favicon\.ico
static_files: public/favicon.ico
upload: public/favicon\.ico
- url: /assets/(.*\.(htm$|html$|css$|js$|png$))
static_files: public/assets/\1
upload: public/assets/(.*\.(htm$|html$|css$|js$|png$))
application_readable: true
- url: /.*
script: public/index.php
EDIT : Thank's to Jarmod, I've got this now :
x#x:~/CuisineDeGeek$ gcloud app deploy ./app.yaml
Please help me.

Related

Google AppEngine Deploy Error (cloud-error-reporting)

I have an App (PHP 7.4) running on Google AppEngine Standard. Now i have created
a new Project inside CloudConsole wih same settings and want to deploy
this App to the new generated Project for testreason.
gcloud app deploy app.yaml --project=testapp-2022-08-14
But i am getting this error:
Fatal error: Unknown: Failed opening required '/srv/vendor/google/cloud-error-reporting/src/prepend.php' (include_path='.:/layers/google.php.runtime/php/lib/php') in Unknown on line 0
To activate the Cloud-Error-Reporting i followed this Documentation:
CloudErrorrEPORTING
my php.ini
auto_prepend_file = '/srv/vendor/google/cloud-error-reporting/src/prepend.php'
session.gc_maxlifetime = 259200
opcache.memory_consumption = 128
my app.yaml
runtime: php74
instance_class: F1
entrypoint: serve bootstrap.php
handlers:
...
env_variables:
...
runtime_config:
document_root: .
automatic_scaling:
max_instances: 20
any help is welcome
Using AppEngine's standard configuration with PHP 7.4 runtime, we encountered the same issue recently, and the value set for auto_prepend_file
registering the library in php.ini in the standard setting no longer works. As we checked the sample repository, we discovered that they suggested registering error handlers manually as a workaround if php.ini cannot be accessed.
In our case, registering the error handler manually, resolved the issue.
# This works for files in the root of your project. Adjust __DIR__ accordingly.
require_once __DIR__ . '/vendor/google/cloud-error-reporting/src/prepend.php';
Take a look at the sample repository and verify that your configuration is set up correctly as well.
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/6609166f71b1049f45360480963c2327b00b7959/appengine/standard
Hope this helps!

The current deployment branch is ''main'', but nothing has been pushed to it

When following the Azure App Service PHP quick start guide you receive the below error;
remote: The current deployment branch is ''main'', but nothing has been pushed to it
remote: Error - Changes committed to remote repository but deployment to website failed.
remote: Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
remote: at Kudu.Console.Program.PerformDeploy(String appRoot, String wapTargets, String deployer, String lockPath, IEnvironment env, IDeploymentSettingsManager settingsManager, TraceLevel level, ITracer tracer, ITraceFactory traceFactory, IOperationLock deploymentLock)
remote: at Kudu.Console.Program.Main(String[] args)
remote: Aborted (core dumped)
The target deployment branch was set to 'main' instead of main despite following the instructions.
Change
az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings DEPLOYMENT_BRANCH='main'
To
az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings DEPLOYMENT_BRANCH=main
Note: I was using azure cli via cmd.exe except for the line setting php version as the Pipe character caused issues. It would be interesting know if using Cloud Cli would have avoided the issue entirely.

Deploying using ansible resets symfony cache file permissions on production environment

I'm using Symfony 5.0.7
My live deploy ansible after-symlink-shared.yaml file:
---
- name: Set up infrastructure-related parameters
template:
src: '{{ playbook_dir }}/templates/.env_live.dist'
dest: '{{ ansistrano_release_path.stdout }}/.env'
- name: Install Composer dependencies
composer:
command: install
arguments: --classmap-authoritative
no_dev: no
optimize_autoloader: yes
working_dir: '{{ ansistrano_release_path.stdout }}'
- name: Clear the cache
command: 'php {{ release_console_path }} cache:clear --no-warmup --env=prod'
- name: Warm up the cache
command: 'php {{ release_console_path }} cache:warmup --env=prod'
- name: Create DB if not exists
command: 'php {{ release_console_path }} doctrine:database:create --if-not-exists --env=prod'
register: create_db_output
changed_when: create_db_output.stdout is not search('already exists. Skipped')
- name: Run migrations
command: 'php {{ release_console_path }} doctrine:migrations:migrate --no-interaction --env=prod'
register: run_migrations_output
changed_when: run_migrations_output.stdout is not search('No migrations to execute')
- name: Install bundle assets
command: 'php {{ release_console_path }} assets:install --symlink --env=prod {{ ansistrano_release_path.stdout }}/public'
- name: Copy build directory
command: 'cp -a {{ ansistrano_release_path.stdout }}/public/build /var/www/project/public'
tags:
- deploy
The deployment works perfectly, however every time I deploy to the server, my production environment hits a 500 error.
I take a look at my prod.log file to understand what is causing the error and I get the following:
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"}
This looks like a permissions issue because every time I deploy, this error comes up. Is is possible I can do something from the NGINX perspective to ensure this functions properly? Or is this an ansible solution? I'm trying to avoid manually fixing these errors with each deployment.
The user running the deployment seems to be different than the one that runs php, that's why the user doesn't have permissions to the cache directory after cache:warmup is run.
You have several options:
Change the user the app runs under:
Since you say you are using nginx I guess you are running php-fpm. You can change the user and group parameters in your php-fpm.conf to the one running the deployment. If you are running multiple applications, create a new pool. (Here's slightly outdated guide to fpm and pools to get you going, and the FPM reference).
Adjust primary groups and umask or acls so both users have access.
Run the cache tasks as the php user using become.
Fix permissions as part of the deploy process by running an ansible task. You can use the file module for this. You can either use open permissions or use become.
Keep in mind that using become (the last two options) requires changing the sudoers file so the deploy user can act as the php user.
If you have an uploads directory under public that needs write access by the php process, you need to fix those permissions too.
I figured out the issue.
It was purely a permissions issue that I had to firstly go to the highest level folder of where the var prod folder was and updated the permissions using chown then updated the permissions for all folder below recursively using chmod to ensure everything else moving forward would be written just as the parent was.
Issue happens probably because ansible runs on root user, but PHP server didn't
Try to add the last step for change ownership of directory in the playbook
- name: Fix user rights
command: 'chown -R www-data: /var/www/project/public'
tags:
- deploy
in my example ownership grants to user www-data (default), but in your case it can be different.
For check right user, use command
cd /var/www/project && ls -la

Google Cloud Error (The requested URL / was not found on this server) [duplicate]

I am trying to create a simple web application that says Hello Udacity and upload it to Google App Engine, but I keep on getting a bunch of errors.
Error message from Google App Engine:
11:57 PM Host: appengine.google.com
Error parsing yaml file:
Unable to assign value 'udacityassignment2' to attribute 'url':
Value 'udacityassignment2' for url does not match expression '^(?:(?!\^)/.*|\..*|(\(.).*(?!\$).)$'
in "C:\Users\Wealthy\Desktop\ambhelloworld\udacityassignment2\app.yaml", line 12, column 8
2013-05-27 23:57:00 (Process exited with code 1)
You can close this window now.
app.yaml:
application: udacityassignment2
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: udacityassignment2
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
main.py:
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello Udacity!')
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
Google App Engine console:
Error: Not Found
The requested URL / was not found on this server.
Any assistance on how to correct this issue would be appreciated.
The error is indicating that the url entry in your app.yaml is not valid. Try this
url: /udacityassignment2
And as Tim pointed, the mapping should be
app = webapp2.WSGIApplication([
('/udacityassignment2', MainHandler)
], debug=True)
You can make the URL entry as below to give you more flexibility when creating your url routing table
- url: .*
script: main.app

Symfony and Azure Distribution Bundle - assets in Azure

I am trying to deploy an existing Symfony 2.1 application to Azure. For this I am using the Azure Distribution Bundle, and I am trying to deploy assets to Azure as documented here.
However, I am getting an error when doing windowsazure:package to create the package:
Catchable Fatal Error: Argument 2 passed to WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy::__construct() must be an instance of WindowsAzure\Blob\BlobRestProxy, none given, called in C:\IGPR\igpr\app\cache\azure\appAzureDebugProjectContainer.php on line 2361 and defined in C:\IGPR\igpr\vendor\beberlei\azure-distribution-bundle\WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy.php line 35
Here is the relevant section of my config.yml:
windows_azure_distribution:
...
services:
blob:
default: UseDevelopmentStorage=true
azureprod: DefaultEndpointsProtocol=http;AccountName=myaccountname;AccountKey=MyVeryLongAccOUntKeY==
assets:
type: blob
connection_name: azureprod
Any ideas? Seems that the Blob proxy cannot be created. I get the same error if I try to use the local development storage.
The bundle is installed via Composer.
Looks like this was a bug in the Azure Distribution Bundle, which the maintainer has now fixed.

Categories