In this tutorial we will go over setting up a standard LEMP stack for development use and learn how to modify it to mimic your production/pre-production environments as closely as possible. We will go over how to switch from Nginx to Apache, upgrade PHP versions and introduce additional storage engines such as Redis to the equation. We’ll also step through how to run both unit and acceptance suites using headless Selenium images in the stack. Leave here fully confident in knowing that whatever environment you get thrown into, you can replicate it and work in it comfortably.
2. @danaluther
What are we going to do today, Brain?
Set up standard LAMP and LEMP stacks using Docker stack
Modify the stack to mimic production
Run codeception test suites against our application
Learn how to swap out php versions
Add and remove additional services
3. @danaluther
Where are you on your Docker
journey?
Brand new to this
rodeo…
Docker containers are
my jam!
I am Docker.
4. @danaluther
Everyone set up and ready?
Docker Desktop installed and running
Checked out the GIT repo
Pulled the docker images
Anyone using Windows? Set to use LCOW?
21. @danaluther
Creating our custom PHP image
Add the mysqli and PDO_mysql
extensions
Use build args in the Dockerfile
ARG PHP_TARGET=7.4-apache
FROM php:$PHP_TARGET
RUN docker-php-ext-install
-j$(nproc) mysqli pdo_mysql
02_LAMP
47. @danaluther
The stack is standard, but are we?
Customized config files:
php.ini and php.conf
my.conf
nginx.conf
48. @danaluther
The stack is standard, but are we?
Customized config files:
php.ini and php.conf
my.conf
nginx.conf
Customized images:
my/php
my/mysql
my/nginx
55. @danaluther
What might you need to customize?
Timezone setting
Error reporting
Output caching and buffering
Listen directives
Ping/Status directives
Timeouts and extension limitations
90. @danaluther
Enable headless browsers for testing
Update docker-compose.yml with Chrome and Firefox images
Default to 0 containers - scale the service up/down as needed
91. @danaluther
Enable headless browsers for testing
Update docker-compose.yml with Chrome and Firefox images
Default to 0 containers - scale the service up/down as needed
Take advantage of x-defaults in the .yml to keep the compose file dry
92. @danaluther
Setting up x-defaults
x-defaults:
network: &network
networks:
- net
selenium-services: &selenium-svc
environment:
# Required to avoid container startup hanging sometimes in
# some environments
JAVA_OPTS: -Djava.security.egd=file:/dev/./urandom
ports:
- "4444:4444"
deploy:
replicas: 0
restart_policy:
condition: on-failure
<<: *network
10_LEMP