A docker-compose-powered stack to get your PHP project running in no time.
- PHP-FPM 7.1
- nginx
- MariaDB
- Node w/ Yarn
Dockerv17.03.1-ce or higherdocker-composev1.11.2 or higher
To start the stack, run:
docker-compose up -d --build --remove-orphans
- The
-dflag daemonises the stack. - The
--buildbuilds services (e.g.php-fpm,nginx) that comprise the stack. - The
--remove-orphansstack ensures that services that aren't being used are deleted (to save disk space).
Provided that no errors were emitted during the start, you should be able to visit your browser on http://localhost:8080.
To stop the stack, run:
docker-compose stop
To connect to the MariaDB service, run:
docker-compose exec mariadb mysql -uapp -p
- This command uses the
appuser. There is also arootuser. - Use the password defined on the
docker-compose.ymlfile.
To install composer dependencies, run:
docker-compose run --rm composer install
- The
--rmflag ensures that that intermediate (temporary) containers are deleted once you install packages (to save disk space). - The service's data is mounted on the
./mariadbhost folder, which means that data will persist betweendocker-composeups andstops.
To install npm packages, run:
docker-compose run --rm yarn add [name-of-package]
yarnis faster thannpmand contains a lockfile (yarn.lock), for deterministic dependency resolution.
If you want to extend the functionality of a service (e.g. php-fpm), you have to re-build it.
To accomplish this, modify the Dockerfile, then run:
docker-compose build --no-cache --force-rm [name-of-service]
... followed by a docker-compose up [arguments...]
- This stack was built on
macOS Sierrav10.12.5. Experience may vary on other operating systems.