nguonchhay/dockerlumen

Dockerlumen is for enhance local development

dev-master 2017-03-13 04:01 UTC

README

Dockerlumen creates the necessary Docker containers (webserver, database, php, mail, redis, couchdb) to run your Lumen Framework project. The package provides a wrapper script in bin/Dockerlumen which simplifies the handling of docker and does all the configuration necessary.

We created this package to make development on Lumen Framework projects easier and to create a simple reusable package which can easily be maintained and serves well for the standard project.

Development will continue further as the package is already reused in several projects. Contributions and feedback are very welcome.

Install docker

https://docs.docker.com/installation/ (tested with docker v1.9 - v1.12)

Install docker-compose

We use docker-compose to do all the automatic configuration:

http://docs.docker.com/compose/install/ (tested with docker-compose v1.5 - v1.6)

The repository contains a Dockerfile which will automatically be built in the docker hub after each change and used by docker-compose to build the necessary containers.

On a Mac or Windows

It has been tested working with docker for Mac but not yet with docker for Windows. Feel free to try out and let us know if you cannot wait.

Add these configuration to your `composer.json

"config": {
	"vendor-dir": "vendor",
	"bin-dir": "bin"
}

Install dockerlumen into your distribution

Add nguonchhay/dockerlumen as dev dependency in your composer, using the latest stable release is highly recommended.

composer require --dev nguonchhay/dockerlumen dev-master

Point db to your host

0.0.0.0 db

NOTE: this step require when you are using docker for the first time. You can skip this step for next setup.

Starting the docker services

bin/dockerlumen up -d

Point domain to your host

0.0.0.0 your-domain-name # port does not need here

After starting the docker services, you will get the domain name exactly the same as your root directory.

Example:

root directory is `lumen` then your domain name is `lumen:8080`

Open your website

http://domain-name:8080

Check the status

bin/dockerlumen ps

Configure .env

APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=dockerlumen
DB_USERNAME=root
DB_PASSWORD=root

CACHE_DRIVER=memcached
QUEUE_DRIVER=sync

Starting app service

bin/dockerlumen run app /bin/bash

app container is the place where you run your commands that have connection to database.

Starting db service

bin/dockerlumen run db /bin/bash

db container is the place where you can check your MySQL database information. The default two databases were created: dockerlumen and dockerlumen_test

NOTE: Services can currently be app, web, data, db, redis, or couchdb.

Accessing to CouchDB

From your host machine, you can access couchdb from web interface or command line:

Web: http://hostname-couchdb:5984/_utils/ -> replace hostname with project name

Cli: curl -X GET http://hostname-couchdb:5984/_all_dbs

From inside your app container, you can also access couchdb through the command line:

bin/dockerlumen run app /bin/bash
curl -X GET http://couchdb:5984/_all_dbs

Attach to a running service

Run bin/dockerlumen ps and copy the container's name that you want to attach to.

Run docker exec -it <containername> /bin/bash with the name you just copied. With this you can work in a running container instead of creating a new one.

Check open ports in a container

bin/dockerlumen run SERVICE netstat --listen

Credit to Sebastian Helzle