Start DLEMP server with prebuilt docker images. This is much faster than building images from dockerfiles.
- Provide disposable PHP development environment.
- Provide isolated PHP development environment for each of your projects.
- Allow developers to manage and version control PHP environment on per project basis.(Developers can easily install additional PHP extensions)
- Provide quick way to run PHP project in single server production setup and clear path to scale app in production.
We support PHP 5.6 and 7.0
- If you don't have an existing project, then create a new project
docker-machine ssh default
(Only if you are not on Linux machine)
cd <project-dir>
docker run --rm -it --user=$(id -u):$(id -g) -v $(pwd):/usr/share/nginx/WEBAPP rasodu/cmdlaravel:7.0.1 /bin/bash
laravel new [new-project-dir]
orcomposer create-project laravel/laravel=5.1.<*|33> <.|new-project-dir>
- Add DLEMPFast to your project
docker run --rm -it --user=$(id -u):$(id -g) -v $(pwd):/usr/share/nginx/WEBAPP rasodu/cmdlaravel:7.0.1 /bin/bash
composer require rasodu/services:dev-master
mkdir public
If it doesn't existmkdir -p services/docker-config
- Copy
.dockerignore
file formrasodu/DLEMP
to your project's root folder - In you project's '.env'(and also to '.env.example' if it exist) file create following variables list :
COMPOSE_PROJECT_NAME=<your_project_name> DLEMPFAST_CONTEXT=../../../../../ DLEMPFAST_BASE_DIR=vendor/rasodu/services/ DLEMPFAST_CONFIG_DIR=vendor/rasodu/services/ DLEMPFAST_PROJECT_DIR= DLEMPFAST_RASODU_MYSQL_VERSION=5.6.28 DLEMPFAST_RASODU_PHPFPMLARAVEL_VERSION=7.0 DLEMPFAST_RASODU_PHPFPMLARAVEL_CONFIG_DIR=vendor/rasodu/services/ DLEMPFAST_RASODU_PHPFPMLARAVEL_DOCKERFILE_DIR=vendor/rasodu/services/ COMPOSE_FILE=vendor/rasodu/services/services/composefile/phpfpmlaravel/c.yml;vendor/rasodu/services/services/composefile/phpfpmlaravel/c.override.yml;vendor/rasodu/services/services/composefile/httpbackendlaravelnginx/c.yml;vendor/rasodu/services/services/composefile/httpbackendlaravelnginx/c.override.yml;vendor/rasodu/services/services/composefile/loadbalancernginx/c.yml
chmod 777 -R bootstrap/cache/ && chmod 777 -R storage/
- Try to start server with
docker-compose up -d
command - Once server starts successfully, commit changed files to your project.
- Optional installation steps
- Add
/public/phpunit-coverage
and/public/app-documentation
to your project's '.gitignore' : If you will be generating phpunit code coverage.
- If you want to use browser sync, then add following code to 'gulpfile.js'.
mix.browserSync({ proxy: 'https://https', port: 3002, ui: { port: 3001 } });
cp "vendor/rasodu/services/com/rasodu/zz-other-references/makefiles/Makefile-Laravel" Makefile
and configure Makefile settings for your project : If you want Makefile for your project.mkdir -p com/rasodu/phpfpmlaravel/customization && cp -a vendor/rasodu/services/com/rasodu/phpfpmlaravel/customization/. com/rasodu/phpfpmlaravel/customization/
: If you want to set custom config.- Add 'APP_LOG=errorlog' to .env and .env-example
- Add
docker-compose up -d
: start development serverdocker-compose stop
: stop development serverdocker-compose down --rmi local -v
: remove containers, networks, local images and volumes
docker exec -it --user=$(id -u):$(id -g) <your_project_name>_cmd_1 /bin/bash
- Server
- Server is already configure for Xdebug. No further configuration is needed.
- Host
- Web browser
- Install Chrome.
- Install Xdebug helper extensions in Chrome.
- IDE(We will assume that you are using Eclipse PDT - https://wiki.eclipse.org/Debugging_using_XDebug)
- Global Eclipse PDT settings
- Eclipse PDT has built in support for Xdebug. No additional plugin need to be installed.
- Add server
- Windows->Preferences->PHP->Servers->New
- Server
- Server Name: <project-name>
- Base URL: https://webapp.dev
- Document Root: <project-folder-root-on-host>
- Debugger
- Debugger: XDebug
- Port: 9000
- Path Mapping
- Path on server: /usr/share/nginx/WEBAPP
- Local path(Path in File System): <path-to-project-folder>
- Server
- Windows->Preferences->PHP->Servers->New
- Project specific Eclipse PDT settings
- Set PHP Interpreter
- Project->Properties->PHP->Interpreter
- Check: Enable project specific settings
- PHP Version: <select-correct-version-of-php>
- Project->Properties->PHP->Interpreter
- Select server for project
- Project->Properties->PHP->Debug
- Check: Enable project specific settings
- Server Settings
- PHP Server: <select-php-server>
- Encoding Settings
- Debug Transfer Encoding: UTF-8
- Debug Output Encoding: UTF-8
- Default Base URL
- Base Path: /
- Auto-generated Base URL: https://webapp.dev/
- Uncheck: Break at First Line
- Project->Properties->PHP->Debug
- Set PHP Interpreter
- Global Eclipse PDT settings
- Web browser
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
: to start services on production serverdocker-compose -f docker-compose.yml -f docker-compose.prod.yml build [service-name]
: to build all services or to rebuild single servicedocker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --no-deps <service-name>
: to start single service- Note: Not all services available during development are available in production. 's3mock' and 'cmd' will not be created during production. You should use S3 during production.
composer install --no-dev
composer dump-autoload --optimize
in .env file 'APP_ENV=production' and 'APP_DEBUG=false'
php artisan optimize --force
php artisan route:cache
php artisan config:cache
docker-machine ssh <production-machine-name>
docker run --rm -it -v <project-name>_etc-letsencrypt:/etc/letsencrypt -v <project-name>_acme-challenge:/DLEMP/letsencrypt/public/.well-known/acme-challenge <project-name>_letsencrypt /bin/bash
/DLEMP/letsencrypt/bin/letsencrypt-auto --version
/DLEMP/letsencrypt/bin/letsencrypt-auto certonly --agree-tos
ln -sf /etc/letsencrypt/live/<domain>/privkey.pem /etc/letsencrypt/privkey.pem
ln -sf /etc/letsencrypt/live/<domain>/fullchain.pem /etc/letsencrypt/fullchain.pem
exit
exit
docker-compose -f docker-compose.yml -f docker-compose.prod.yml restart nginxhttps
- Required tools
- Common
- Docker Toolbox
- Environment specific
- AWS
- AWS CLI
- Kubernetes
- kubectl
- kompose
- Kubernetes cluster(An ECS cluster(ECS CLI) : All instance in the cluster should have AmazonEC2ContainerServiceforEC2Role policy)
- AWS
- Common
- Create final combined compose file(Only if you are using kubernetes cluster)
docker-compose config > compose-combined.yml
- Change version number from '2.0' to '2' in compose-combined.yml
- Push images to repository
- AWS EC2 Container Registry
$(aws ecr get-login)
docker-compose build
docker push <tag>:<version>
//Push all custom images for the project: docker images | grep -i <COMPOSE_PROJECT_NAME>- docker logout
- Google Container Registry
- <Needs intructions>
- AWS EC2 Container Registry
- Create cluster
- AWS Elastic Beanstalk
- Create AWS Elastic Beanstalk with Multicontainer Docker Environment with Load Balancer
- Add policy
AmazonEC2ContainerServiceforEC2Role
inaws-elasticbeanstalk-ec2-role
role //this will allow EC2 instances to access EC2 Container Registry - Create app specific
Dockerrun.aws.json
- Create Google Container Cluster
- <Needs intructions>
- AWS Elastic Beanstalk
- Run containers
- AWS Elastic Beanstalk
- Lod your app specific
Dockerrun.aws.json
in your Elastic Beanstalk Environment
- Lod your app specific
- Kubernets cluster(These instructions need improvement.)
- Build images:
eval $(minikube docker-env)
anddocker-compose build
kompose -f compose-combined.yml up
kubectl get deployments,rs,pods,services
kubectl expose deployment <deployment-name> --type=LoadBalancer --port=<port-number> [--target-port=<>]
kubectl edit svc/docker-registry
- Check service is running :
curl http://$(minikube ip):32599/
- Build images:
- AWS Elastic Beanstalk