I've got a Laravel 5.1 PHP application that uses composer as PHP dependency manager and npm as JavaScript dependency manger, so far so good.
I want to have a live version of this application and I want automatic deployment with ElasticBeanstalk, I've created a confi file that looks like the following:
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/11_build.sh:
group: root
mode: "000755"
owner: root
content: |
#!/usr/bin/env bash
set -xe
. /opt/elasticbeanstalk/support/envvars
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
cd $EB_APP_STAGING_DIR
php artisan migrate --env="local"
yum -y --enablerepo=epel install nodejs npm
npm install -g gulp
npm install
gulp --production
option_settings:
-
namespace: "aws:elasticbeanstalk:command"
option_name: Timeout
value: 1600
this set sometime works and sometime it will take more than 30 mins to complete and elasticbeanstalk triggers a timeout error
Now the reason the following block is there
yum -y --enablerepo=epel install nodejs npm
npm install -g gulp
is because if the app needs to scale to multiple servers node can potentially be not installed and that will install node for me
Now my question is: Am I doing it right? Is that the correct way to tackle automatic deployment? sometime the deployment will take more than 30 minutes to execute, is it normal? can I improve my deployment? I very like to type "eb deploy" and everything will go live!
You should be able to use the environment configuration options for this rather than writing a bash file yourself:
Customising software on linux servers
This will allow you do something like this:
packages:
yum:
nodejs: []
npm: []
However:
Elastic Beanstalk currently supports the following package managers: yum, rubygems, python, and rpm
So you'll still need to do the npm install gulp
, ... manually
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.