Last active
July 31, 2021 21:00
-
-
Save pauly4it/f33f5b1cd4446e5b0a94 to your computer and use it in GitHub Desktop.
Laravel on Elastic Beanstalk Blog Post Code Snippets: http://blog.goforyt.com/laravel-5-aws-elastic-beanstalk-production-guide/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set composer folder for this command and update | |
commands: | |
01updateComposer: | |
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update | |
option_settings: | |
# Add environment variable to set composer home folder | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: COMPOSER_HOME | |
value: /root | |
# update php.ini file with new document root and specific composer --no-dev | |
- namespace: aws:elasticbeanstalk:container:php:phpini | |
option_name: document_root | |
value: /public | |
- namespace: aws:elasticbeanstalk:container:php:phpini | |
option_name: composer_options | |
value: --no-dev --no-interaction --prefer-dist --optimize-autoloader | |
container_commands: | |
00optimize: | |
command: "/usr/bin/composer.phar dump-autoload --optimize" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resources: | |
AWSEBAutoScalingGroup: | |
Type: "AWS::AutoScaling::AutoScalingGroup" | |
Metadata: | |
AWS::CloudFormation::Authentication: | |
S3AccessCred: | |
type: "S3" | |
roleName: "aws-elasticbeanstalk-ec2-role" | |
buckets: "app-env" | |
files: | |
"/tmp/.env" : | |
mode: "000777" | |
owner: root | |
group: root | |
source: https://s3.amazonaws.com/app-env/.env | |
authentication: S3AccessCred | |
container_commands: | |
move_env: | |
command: "mv /tmp/.env /var/app/ondeck/.env" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
container_commands: | |
10_migrate: | |
command: "php artisan migrate --force" | |
cwd: "/var/app/ondeck" | |
leader_only: true | |
11_seed: | |
command: "php artisan db:seed --force" | |
cwd: "/var/app/ondeck" | |
leader_only: true | |
12_cache: | |
command: "php artisan cache:clear" | |
cwd: "/var/app/ondeck" | |
13_optimize: | |
command: "php artisan optimize --force" | |
cwd: "/var/app/ondeck" | |
14_permissions: | |
# fix permissions on the Laravel app folder | |
command: "chmod 777 -R /var/app/ondeck" | |
cwd: "/var/app/ondeck" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/tmp/new_supervisord_conf": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
; Sample supervisor config file. | |
; | |
; For more information on the config file, please see: | |
; http://supervisord.org/configuration.html | |
[unix_http_server] | |
file=/tmp/supervisor.sock ; (the path to the socket file) | |
[supervisord] | |
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) | |
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) | |
logfile_backups=10 ; (num of main logfile rotation backups;default 10) | |
loglevel=info ; (log level;default info; others: debug,warn,trace) | |
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | |
nodaemon=false ; (start in foreground if true;default false) | |
minfds=1024 ; (min. avail startup file descriptors;default 1024) | |
minprocs=200 ; (min. avail process descriptors;default 200) | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket | |
[program:queue] | |
command=php artisan queue:listen --sleep=10 | |
directory=/var/app/current | |
stdout_logfile=/var/app/current/storage/logs/supervisor.log | |
redirect_stderr=true | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_supervisor": | |
mode: "000777" | |
owner: root | |
group: root | |
content: | | |
#!/usr/bin/env bash | |
#sudo easy_install supervisor==3.1.3 | |
#supervisord -c /tmp/new_supervisord_conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/tmp/artisan_scheduler": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
* * * * * root /usr/bin/php /var/app/current/artisan schedule:run 1>> /dev/null 2>&1 | |
encoding: plain | |
container_commands: | |
move_cron: | |
command: "mv /tmp/artisan_scheduler /etc/cron.d/artisan_scheduler" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSConfigurationTemplateVersion: 1.1.0.0 | |
SolutionStack: 64bit Amazon Linux 2015.09 v2.0.6 running PHP 5.6 | |
OptionSettings: | |
aws:elasticbeanstalk:command: | |
BatchSize: '30' | |
BatchSizeType: Percentage | |
aws:elasticbeanstalk:container:php:phpini: | |
document_root: /public | |
composer_options: --no-dev | |
aws:elb:policies: | |
ConnectionDrainingEnabled: true | |
aws:elb:loadbalancer: | |
CrossZone: true | |
aws:elasticbeanstalk:environment: | |
ServiceRole: aws-elasticbeanstalk-service-role | |
aws:elasticbeanstalk:healthreporting:system: | |
AWSEBHealthdGroupId: 26f9d700-23b7-4222-a3f2-ac9a7a46e571 | |
SystemType: basic | |
aws:elasticbeanstalk:healthreporting:system: | |
SystemType: basic | |
aws:autoscaling:launchconfiguration: | |
IamInstanceProfile: aws-elasticbeanstalk-ec2-role | |
InstanceType: t2.micro | |
EC2KeyName: aws-eb | |
aws:autoscaling:asg: | |
Availability Zones: Any 1 | |
MaxSize: '1' | |
Custom Availability Zones: us-east-1a | |
aws:autoscaling:updatepolicy:rollingupdate: | |
RollingUpdateType: Health | |
RollingUpdateEnabled: true | |
EnvironmentTier: | |
Type: Standard | |
Name: WebServer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AddPerm", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::555555555555:role/aws-elasticbeanstalk-ec2-role" | |
}, | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::app-env/*" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment