https://github.com/jpcaparas/docker-web-stack
A Docker Compose-powered stack to get your PHP project running in no time.
https://github.com/jpcaparas/docker-web-stack
docker docker-compose mysql nginx php
Last synced: about 2 months ago
JSON representation
A Docker Compose-powered stack to get your PHP project running in no time.
- Host: GitHub
- URL: https://github.com/jpcaparas/docker-web-stack
- Owner: jpcaparas
- License: mit
- Created: 2017-05-24T22:05:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T22:09:29.000Z (almost 8 years ago)
- Last Synced: 2025-03-26T15:05:28.324Z (2 months ago)
- Topics: docker, docker-compose, mysql, nginx, php
- Language: Nginx
- Homepage:
- Size: 18.6 KB
- Stars: 48
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Web Stack
[](https://travis-ci.org/jpcaparas/docker-webapp)
# Overview
Docker Compose makes it easy to interconnect various Docker images. What better way to showcase its features than by
creating (yet another) LEMP stack. This is one is much more bleeding edge than others, though :wink:.# What's inside
A `docker-compose`-powered stack to get your PHP project running in no time.
- PHP-FPM 7.1
- nginx
- MariaDB
- Node w/ Yarn# Requirements
- `Docker` v17.03.1-ce or higher
- `docker-compose` v1.12 or higher# How-to (simple)
To start the stack, run:
docker-compose up -d --build --remove-orphans
- The `-d` flag daemonises the stack.
- The `--build` builds services (e.g. `php-fpm`, `nginx`) that comprise the stack.
- The `--remove-orphans` stack 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 ensure that all services have stopped, run:
docker-compose ps
There should be no more services running.
---
To connect to the MariaDB service, run:
docker-compose exec mariadb mysql -uapp -p
- This command uses the `app` user. There is also a `root` user.
- Use the password defined on the `docker-compose.yml` file.---
To install composer dependencies, run:
docker-compose run --rm composer install
- The `--rm` flag ensures that that intermediate (temporary) containers are deleted once you install packages (to save disk space).
- The service's data is mounted on the `./mariadb` host folder, which means that data will persist between `docker-compose` `up`s and `stop`s.---
To install npm packages, run:
docker-compose run --rm yarn add [name-of-package]
- `yarn` is faster than `npm` and contains a lockfile (`yarn.lock`), for deterministic dependency resolution.
# How-to (advanced)
To enable the Xdebug module:
1. Copy the `.env.example` to an `.env` file and:
1. Change the value of `XDEBUG_ON` to `true`
1. Change the value of `XDEBUG_REMOTE_HOST` to your host machine's IP address.
1. Run `docker-compose up -d --build --remove-orphans` to re-build the service.---
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...]`
---
If you want to use a different web server port (e.g. 80), modify the port on the `docker-compose.yml` file
and start the stack again.# Gotchas
Ensure that the host machine ports `8080` (web server) and `3306` (database) are open on your host machine.
---
Your version of Docker for Mac might ship with v1.11 (an older release) of Docker Compose. You need to upgrade
to at least v1.12 in order to make this stack work.For Linux/macOS users, you can run:
curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-composeTo check that you are using v1.12 or higher, run:
docker-compose --version
# Warranties
- This stack was built on `macOS Sierra` v10.12.5. Experience may vary on other operating systems.
# Attributions
- This wouldn't be possible without being granted a role as Software Developer at [Pixel Fusion](https://pixelfusion.co.nz/),
an award-winning product development company at Parnell, Auckland.
- This project was greatly inspired by the [Laradock project](https://github.com/laradock/laradock).