Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues when deploying via CI vs locally #20

Closed
aknosis opened this issue Nov 17, 2020 · 2 comments
Closed

issues when deploying via CI vs locally #20

aknosis opened this issue Nov 17, 2020 · 2 comments
Labels
support Someone needs help

Comments

@aknosis
Copy link

aknosis commented Nov 17, 2020

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:

bootstrap/cache/packages.php
bootstrap/cache/services.php

My ci config is as such:

curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --no-progress --prefer-dist
serverless deploy -v -s staging

Any thoughts on what I might be doing wrong?

@mnapoli mnapoli added the support Someone needs help label Nov 17, 2020
@mnapoli
Copy link
Member

mnapoli commented Nov 17, 2020

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).

@aknosis
Copy link
Author

aknosis commented Nov 17, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Someone needs help
Projects
None yet
Development

No branches or pull requests

2 participants