Skip to content

A local Docker Environment for building PHP applications 🔨

Notifications You must be signed in to change notification settings

dominikmiskovec/docker-dev

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A LAMP Local Development Environment on Docker

An everyday local development environment for PHP Developers. At Pivotal Agency, we've done a buuunnnch of R&D to find the best local dev tools for our team. This is the result of our hard work. This tool has been put to its paces everyday by our team, we hope it can also help yours.


Intro 👋

This is a set of Docker images to spin up a LAMP stack (Linux, Apache, MySQL and PHP) for developing locally. It's perfect for local development because you can very simply add new sites to specified directory and they're magically accessible as a subdomain of your chosen hostname (eg. eg. ~/Sites/info maps to http://info.localhost/).

It includes all the required dependencies for everyday PHP development with common tools like Laravel, Wordpress and Magento (1 & 2).

Specifically, it has the following tech available:

  • PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 and 8.0
  • MariaDB 10.2
  • Redis 6.x
  • Memcached 1.x
  • Composer (latest)
  • Mailhog (latest)
  • Node.js (13.x) & NPM (latest) (PHP74 container only)
  • Yarn (latest) (PHP74 container only)
  • PHPCS (with Wordpress code standards added) (PHP74 container only)
  • Wordpress CLI (PHP74 container only)
  • HTTPS (SSL for localhost (not enabled - see FAQs)
  • Blackfire (latest) (not enabled - see FAQs)

We have some clever domain mapping available to allow you to run code for various platforms. Sites are accessible from the following URLs (by default it's http://<website>.localhost, however APACHE_HOSTNAME can modified in .env to point to a different hostname):


Prerequisites ⚠️

  • Your machine must be running MacOS, Windows 10 Pro or Linux
  • Your CPU must support virtualisation (Intel VT-x or AMD-V)
  • You must have Docker Compose (version 1.25.0+) and Docker installed & running

Installation 🚀

# Clone the repo
git clone https://github.com/pvtl/docker-dev && cd docker-dev

# Create & update relevant config (eg. point sites to your sites directory)
cp .env.example .env

# Start the environment and go get a ☕️ (it'll take a while to install e'ry-thing)
docker-compose up -d

Then, for each website, simply point the URL to localhost (127.0.0.1):

# Open your hosts files (with admin rights)
sudo nano /etc/hosts

# Append each site you need to access - eg.
127.0.0.1 info.localhost

Updating 🔄

Open a terminal window, browse to this project's folder and run:

git pull                                           # 1. Pull from Git
docker-compose down --remove-orphans               # 2. Erase previous containers
docker-compose pull                                # 3. Get latest docker images
docker-compose build --pull --no-cache --parallel  # 4. Rebuild Dockerfiles from scratch (inc. pull parent images)
docker-compose up -d                               # 5. Start the new env
docker system prune --volumes                      # 6. Erase any unused containers, images, volumes etc. to free disk space.

This will install the latest versions of all tools (eg. PHP, Redis, Node.js etc.)


Common Commands 🔥

The Docker Engine must be running and commands must be run within this repo's root.

Command Description
docker-compose start Start all containers
docker-compose stop Stop all containers (keeps any config changes you've made to the containers)
docker-compose up -d --build --no-cache Recreate all containers from scratch
docker-compose down Tear down all containers (MySQL data and Project files are kept)
docker-compose exec php74-fpm bash Open a bash terminal in the PHP 7.4 container
docker-compose logs php74-fpm View all logs for PHP-FPM 7.4
docker-compose ps Show which containers are running

Further Reading

About

A local Docker Environment for building PHP applications 🔨

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 93.4%
  • Shell 6.6%