Closed aknosis closed 3 years ago
Are you sure that the .env
or environment variables are not different? Because it seems that Laravel tries to log to file (stack
driver), which should not happen on Lambda (it doesn't work).
That's why we define the driver to stderr
(https://github.com/brefphp/laravel-bridge/blob/master/src/BrefServiceProvider.php#L43-L47).
I figured it out! We were both very close with our initial thoughts, the missing bootstrap/cache
I noticed was the problem.
In GitLab CI I'm doing a multi stage build where my project is built in a PHP 7.4 image (composer steps listed above) and then it rolls into a node:alpine image that does the serverless deploy. Turns out that when it switches to that node image it re-fetches the code from git and the package discovery is never done so it doesn't know about any of the services (BrefServerProvider is never loaded).
I plan to add my example CI build to the examples repo. I will have this Laravel requirement listed in the notes somewhere.
For posterity, here's a simple example of what I'm using:
stages:
- test
- build
- deploy
cache:
paths:
- vendor/
- bootstrap/cache/
test:
stage: test
image: php:7.4
artifacts:
reports:
junit: junit.xml
script:
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-progress --prefer-dist
- vendor/bin/phpunit --coverage-text --colors=never --log-junit=junit.xml
build:
stage: build
image: php:7.4
script:
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-dev --no-progress --prefer-dist
deploy:
stage: deploy
image: node:alpine
script:
- npm install -g serverless
- stage=$([ "$CI_COMMIT_REF_NAME" == "master" ] && echo "prod" || echo "staging")
- cp .env.$stage .env
- serverless deploy -v -s $stage
I've got a barebones Laravel 8 project, setup per instructions at https://bref.sh/docs/frameworks/laravel.html. (The only difference is I'm using HTTP API).
When I deploy from my local machine the default welcome view renders without issue. When I deploy via CI I get this error with the welcome view:
There is no existing directory at "/var/task/storage/logs" and it could not be created: Read-only file system
.I don't believe there is any issue with the serverless portion of this as comparing the debug output (with SLS_DEPLOY=1) didn't show many differences.
I compared the output of my
.serverless/project.zip
that was created on my machine vs in CI and the only noticeable differences I saw was my CI version was missing:My ci config is as such:
Any thoughts on what I might be doing wrong?