Skip to content

Docker based local development environment

Notifications You must be signed in to change notification settings

talevskiigor/dev

 
 

Repository files navigation

Development base

Docker based local development environment. Php and Npm users are synced with the current user, so we will have all the rights to modify and access the content generated by using container commands.

What we have here

For the start:

  • Apache 2.4 (based on original httpd:2.4-alpine container)
  • PHP 7.4 / 8.0 / 8.1 / 8.2 fpm (based on original php:x.x-fpm containers) with:
    • composer 2
    • xDebug 3 with remote debug and profiler preconfigured
    • error reporting enabled
  • MySQL 5.7(any other version can be easily used) with adminer (original mysql container used)
  • Mailhog preconfigured to catch outgoing emails
  • SPX preconfigured (PHP Simple Profiler - https://github.com/NoiseByNorthwest/php-spx)
  • Npm container preconfigured (based on node:latest)
  • Chrome based selenium service available, for running your selenium tests (based on selenium/standalone-chrome-debug)

Requirements

Quick start

Create a directory (currently myProjectName) and clone this development base

echo myProjectName && git clone https://github.com/Sieg/development.git $_ && cd $_

Run example script which prepares several example files for you to see this environment functionality

./recipes/default/example/run.sh

Access the website through the http://localhost.local

  • phpinfo shown on index page
  • example with database connection
  • example with email sending and catching it with mailhog
    • run the composer install on php container first.

Adminer is available via http://localhost.local:8080

  • Server: mysql
  • Credentials: root/root

Mailhog is available via http://localhost.local:8025/

SPX preconfigured and UI accessible via http://localhost.local?SPX_KEY=dev&SPX_UI_URI=/

Longer start

This example shows more precise configuration which can be used for your project. It is real usage flow:

# clone the development environment to myProjectName directory
echo myProjectName && git clone https://github.com/Sieg/development.git $_ && cd $_

# setup rights and basic configuration files
make setup

# add php, mysql and apache services (they are grouped in one command, but can be added separately if needed)
make addbasicservices

# add selenium container to the docker-compose
make file=services/selenium-chrome.yml addservice

# ensure you have source directory available, as its configured as webroot by default
mkdir source

# start everything
make up

# stop everything when its enough :)
make down

Running php stuff

We can connect to the php container and do the stuff in there:

make php
php -v

Note: make php is just an alias for docker-compose exec php bash

We can call commands directly without connecting to the container:

docker-compose run php php -v

Running npm commands

Direct call

docker-compose run node npm install bootstrap

Connect to node container

make node

Configurations

Apache

Custom configuration file: containers/httpd/project.conf.

PHP

Select PHP version to be used in docker-compose php container configuration. Custom configuration file for php settings: containers/php-fpm/custom.ini.

Remote debugging with PHPSTORM

  • Configure the CLI Interpreter
  • Create a Server configuration and set mapping as source:/var/www/

Inspired by OXID :)

Contributing

You like to contribute? 🙌 AWESOME 🙌 Throw a pull request, with the description why you/we need it and instructions how to test it out :)

About

Docker based local development environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Dockerfile 63.9%
  • Makefile 19.0%
  • PHP 14.2%
  • Shell 2.9%