why an Opensea Clone Script might be your perfect match.pdf
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour Luxembourg 2015
1. Deploy and Scale your PHP App using
Docker containers and AWS Beanstalk
Walter Dal Mut
@walterdalmut - github.com/wdalmut
2. I'm co-founder of @CorleyCloud
application development
infrastructure and application migration on cloud
I'm also a co-founder of @UpCloo
U.K. based startup: powering related content across the web
walter.dalmut@gmail.com
3. First of all we have to agree on
what scaling is for this talk
4. scalability is not high availability
Scalability is the ability of a system to handle a growing amount of work in capable manner or the ability to be
enlarged to accomodate that growth (from wikipedia)
14. with (auto)scalable infrastructures
How to manage application upgrades
How to monitor servers
How to handle servers configurations
How to handle instances logs
...
ElasticBeanstalk help us with this things
16. Mainly Beanstalk takes a ZIP artifact
(the PHP application)
and unpack it into the environment
Uses YML definitions in order to setup the environment
17. The deploy cycle take care of:
1. Packages
2. Users & Groups
3. Files
4. Commands
before the application and web server are set up
5. Services
6. Container_commands
just before the application version is deployed
19. extract your application logs
commands:
21_application_logs:
command: echo "/var/app/current/app/logs/*.log" > app.conf
cwd: /opt/elasticbeanstalk/tasks/bundlelogs.d
22_application_logs:
command: echo "/var/app/current/app/logs/*.log" > app.conf
cwd: /opt/elasticbeanstalk/tasks/systemtaillogs.d
23_application_logs:
command: echo "/var/app/current/app/logs/*.log" > app.conf
cwd: /opt/elasticbeanstalk/tasks/taillogs.d
24_application_logs:
command: echo "/var/app/current/app/logs/*.log" > app.conf
cwd: /opt/elasticbeanstalk/tasks/publishlogs.d
And check them directly from the web console
20. Beanstalk works with different
application containers
PHP, Node.js, Tomcat, Python, Ruby
and...
Docker & Multicontainer Docker
Multicontainer Docker is connected to ElasticContainer Service
21. Why docker is interesting for
ElasticBeanstalk?
When there is a default PHP container with
different available versions: 5.3, 5.4, 5.5, 5.6
22. Instances are Amazon Linux
Difficult to configure a different distro: ubuntu, debian ...
Even packages: supervisors, agents etc.
Difficult to replicate the env locally (dev).
24. The application path change
after the deploy cycle
/var/app/ondeck->/var/app/current
Symfony2 cache warmup problems...
25. With Docker we can create a more
dedicated setup
{{ Nginx - PHP-FPM }}
26. The docker environment is more stable
and testable than the default one
Thanks to the docker isolation nature
File are uncompressed into: /var/app/current
27. Prepare a web server
FROM ubuntu:14.04
RUN aptget update && aptget install y php5 apache2 libapache2modphp5
php5apcu php5curl php5mongo php5xsl && rm rf /var/lib/apt/lists/*
RUN a2enmod rewrite deflate expires headers
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "D", "FOREGROUND"]
prepare your Dockerfile
28. You can build the container during the
deploy cycle
Just let the `Dockerfile` in the root folder of your project
30. Docker containers are engaged with:
https://registry.hub.docker.com/
+ automated builds! (keep container up to date automatically)
Already provisioned containers
31. You can use it
for your development
dockerpullwdalmut/webserver
dockerrun
-p8080:80
-v`pwd`:/var/www/html
-dwdalmut/webserver
Use Vagrant docker provisioner for your dev environments
38. You cannot use PHP from the host
(it is in the docker container)...
You have to pass commands via docker containers
dockerrun
--rm-i-t
-v/var/app/current:/var/www/html
wdalmut/webserver
app/consoleca:cl-e=prod