More Related Content Similar to Dockerizing Symfony Applications - Symfony Live Berlin 2014 Similar to Dockerizing Symfony Applications - Symfony Live Berlin 2014 (20) Dockerizing Symfony Applications - Symfony Live Berlin 20142. Set out to make service orchestration
simple for developers.
Based in Cologne, Germany.
Ten terrific folks, and hiring!
http://giantswarm.io/
6. It will help you to ...
● run your environment everywhere
● try out infrastructure changes easier
● deploy new releases faster
● run PHP without installing it locally!
16. Virtual Machines
Machine
Kernel
Init
Hypervisor
VM
Kernel
Init
Process
VM
Kernel
Init
VM
Kernel
Init
Process
Process
Process
Process
Process
19. Linux Containers ...
● run in their own Kernel namespace
● are standalone processes
● only see processes inside them
● cannot see outside processes
● share the kernel instance
● can have their own filesystem
● can be isolated using CGroups
36. 2. Create a Dockerfile
FROM php
ADD index.php /var/www
EXPOSE 8080
WORKDIR /var/www
Every line
becomes a layer
ENTRYPOINT ["php", "-S", "0.0.0.0:8080"]
37. 3. Build your Container
$ docker build -t denderello/phptest .
38. 4. Run your Container
$ docker run -d -p 8080:8080 denderello/phptest
$ curl 127.0.0.1:8080
Hello from PHP
Binds local port
to exposed port
40. The Dockerhub saves your Containers
D
push run
Dev Prod
Docker daemon Docker daemon
Docker client Docker client
57. Symfony Container
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y
git curl php5-cli php5-json php5-intl
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
ADD entrypoint.sh /entrypoint.sh
ADD ./code /var/www
VOLUME /var/www
WORKDIR /var/www
ENTRYPOINT ["/entrypoint.sh"]
CMD ["echo", "hello"]
59. Run the Symfony Container
$ docker run denderello/symfony composer install
$ docker run denderello/symfony
app/console cache:clear
63. php-fpm Container
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y
php5-fpm php5-json php5-intl
ADD entrypoint.sh /entrypoint.sh
EXPOSE 9000
WORKDIR /var/www
ENTRYPOINT ["/entrypoint.sh"]
65. Entrypoint Bash Script
#!/bin/bash
echo "env[SYMFONY__REDIS_PORT] = ${REDIS_PORT_6379_TCP_PORT}"
>> /etc/php5/fpm/pool.d/www.conf
echo "env[SYMFONY__REDIS_ADDRESS] = ${REDIS_PORT_6379_TCP_ADDR}"
>> /etc/php5/fpm/pool.d/www.conf
exec /usr/sbin/php5-fpm --nodaemonize
Docker will set
these for links
71. Run the fpm Container
$ docker run -d denderello/fpm
--link redis:redis
--volumes-from symfony
--name fpm
74. nginx Container
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y
nginx
RUN echo "ndaemon off;" >> /etc/nginx/nginx.conf
ADD vhost.conf /etc/nginx/sites-enabled/default
ADD entrypoint.sh /entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]
75. Run the nginx Container
$ docker run -d denderello/nginx
--link fpm:fpm
--volumes-from symfony
--name nginx
82. fig.yml (excerpt)
…
nginx:
build: nginx/
ports:
- 8080:80
links:
- fpm
volumes_from:
- symfony
…
83. fig.yml (excerpt)
…
symfony:
build: symfony/
links:
- redis
volumes:
- ./symfony/code:/var/www
…
Overrides the the
folder when running
the container
87. Using fig
$ fig run symfony composer install
$ fig run symfony app/console cache:clear
90. Sign up for our
private Beta
Request Invite
http://giantswarm.io/