Press 'c' to toggle code style
Press 's' for speaker notes
Developer time is expensive
Not using docker already
Adding files to containers
Other languages: default to no file, then add
PHP: default to all file, then exclude
Docker too slow for npm/yarn/webpack on OSX
Dockerfile tips
# Use repos, not the 'official' php image
FROM debian:9-slim
# root is technically bad
USER root
# This thing is going to change more often:
RUN apt-get install imagick_version_3.2.1
# Than this thing.
RUN apt-get install php_and_everything_else
WORKDIR /var/app
# Running commands through bash scripts is
# far easier to maintain
CMD sh /var/app/php_fpm/entrypoint.sh
Dockerfile tips
# Use repos, not the 'official' php image
FROM debian:9-slim
# root is technically bad
USER root
# Having them this way round
RUN apt-get install php_and_everything_else
# means the previous step can be cached
RUN apt-get install imagick_version_3.2.2
WORKDIR /var/app
# Running commands through bash scripts is
# far easier to maintain
CMD sh /var/app/php_fpm/entrypoint.sh
Bootstrap container
php composer.phar install
# Waits for DB to be available
php cli.php misc:wait_for_db
php vendor/bin/phinx migrate
sh buildSassToCss.sh
php cli.php seed:initial
echo "Bootstrap is finished"
Forget Docker networking
Setup loopback address on host machine
Available both from the host and the docker boxes.
FROM php_backend:latest
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
--no-install-recommends php7.2-xdebug
COPY xdebug.ini /etc/php/7.2/fpm/conf.d/20-xdebug.ini
xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
; Remote connect back doesn't work in docker
; as the incoming request IP doesn't map back
; to the host properly.
xdebug.remote_connect_back=0
; Loopback ftw
xdebug.remote_host=10.254.254.254
Xdebug always available locally
80
Varnish ➔ Nginx ➔ PHP
8000
Nginx ➔ PHP
8001
Nginx ➔ PHP with Xdebug
One process per container?
This is a case of failing to tell what is good, from what is convenient in a new tech.
Script Two things at the same time
https://gist.github.com/Danack/15e88f28e2b3504223c06582d5650bcc