简体   繁体   中英

Laravel Elastic Beanstalk running migrations

I have setup elastic beanstalk for my laravel application. I use environment properties:

在此处输入图像描述

The application works fine, but when I run migrations this fails as the creds for the db have not been added to.env file (I wanted to run the migrations using ebextensions). Is there a way to run migrations where it uses environment properties?

The migrations run as part of the deployment.

I also ran into this problem. The proper solution is to not use environment properties within the EB console. I put my.env on a S3 bucket and copy it in on deploy. This also helps with maintaining ENV variables between for ex. green/blue deployments and if you ever need to upgrade EB environment platforms (for ex. when a new PHP/Python/NodeJS version is released or Amazon Linux version)

This an example for an ebextension which copies over.env variables from S3: https://github.com/rennokki/laravel-aws-eb/blob/master/.ebextensions/00_copy_env_file.config

You could also copy your.env file from the deployment folder to where your project is located with this script

sudo cp /opt/elasticbeanstalk/deployment/env /var/www/html/.env && sudo chown ec2-user:webapp .env && sudo chmod 644 .env
  • copy over env file from deployment folder with cp
  • change user and group of file with chown
  • change file rights with chmod

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