Lightweight LEMP dev-setup
Containerized environment consisting of the following containers: ( All versions can be easily adapted! )
- NGinX v1
- PHP-FPM v8.1
- MariaDB v10
- MySQL v8
- Postgres v14
- Composer v2
- PhpMyAdmin v5
For simplicity's sake, we have added a small wrapper around Make. This allows us to pass arguments and flags to the
respective commands the idiomatic way. If you don't like using ./make instead of just make, you can add this
one-liner to your .bashrc or .bash_profile:
function make(){ if [ -f ./make ]; then ./make $@; else `which make` $@; fi }- Ensure Docker is installed on your machine
- Run
./make up - The first installation can take about a minute or two (ymmv depending on network and CPU power)
- During the first run, the
.env.examplewill be copied to.env. - After the DBs have spun up, you will find the root-passwords in your
.envfile (in case you need them). - During the first run, the database will also be seeded with the base-structure as well as some sample data.
If you don't want this to happen, feel free to simply delete the respective *.sql files in:
.docker/mysql/docker-entrypoint-initdb.d.docker/mariadb/docker-entrypoint-initdb.d.docker/postgres/docker-entrypoint-initdb.d
To change the PHP version, update the image tag in the .docker/php-fpm/Dockerfile as well the one for composer
in the .docker/docker-compose.yml. Both need to match the same version, otherwise composer could behave quite
oddly at times! After changing the version, you need to run ./make dc up --build to ensure the php-fpm container
is updated.
- update line 1 of file
.docker/php-fpm/Dockerfile, e.g.FROM php:8.0-fpm-->FROM php:8.1-fpm - update composer image-tag in file
.docker/docker-compose.yml, e.g.prooph/composer:8.0-->prooph/composer:8.1 - stop containers if not already done:
./make dc stop - rebuild php-fpm container
./make dc up --build
- If you need to run composer commands, you can run them through the composer-container to ensure not to run
into php-version-conflicts in case you have a different PHP version on your host machine
(avoiding "But it works on my machine!" problems). This can be done like so:
./make composer update./make composer install./make composer require nyholm/psr7-server- etc.
- If you need to execute PHP scripts, you can run them through a copy of the php-fpm container for the same reasons
as mentioned above like this (the environment variables are already injected):
./make php -a./make php artisan tinker- etc.
- The same works for
docker-compose, e.g.:./make docker-compose ps --allor for short:./make dc ps --all - To run all containers in the background, run
./make dc up -dand to look into the logs run./make dc logs. To stop the running containers, run./make dc stop. - To stop and delete all containers related to this project, just run
./make dc down. If you also want to wipe the images from your disk, you can use the wrecking-ball method and rundocker system prune -abut be aware that this will remove all stopped containers, networks, images, etc from your system, even the ones not related to this project! - If you stop and/or delete the containers of this project,
you don't lose anything as long as you keep
*_presistencevolumes intact (see volumes indocker-compose.yml). To wipe the DBs, use the command./make wipe_db. - For a really fresh install, stop and remove all containers, db persistence, composer dependencies and env variables
using the
./make cleancommand followed by a fresh./make up.
By default, the following ports/URIs are assigned to the respective services:
- NginX: 55001 (http://localhost:55001)
- PhpMyAdmin: 55002 (for both MariaDB and MySQL: http://localhost:55002)
- MySQL: 55003
- MariaDB: 55004
- Postgres: 55005
- Postgres CLI: run
make pg - PHP-FPM: 9000
