Skip to content

Docker-compose stack with php7 (php7-fpm), nginx and postgresql optimised for Symfony3 applications

License

Notifications You must be signed in to change notification settings

Gronan/docker-compose-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-compose-skeleton

Ready to use docker-compose stack with php7 (php7-fpm), nginx and postgresql optimised for Symfony3 applications (with ELK & Redis)

##Disclaimer

  1. Nginx conf & docker-compose.yml assure your project is located in /var/www/ (if not make sure to change the .yml & .conf files)
  2. Redis & ELK are optional

##Step by step configuration ###Step 1 make sure docker and docker-compose are installed

###Step 2

  1. Replace every occurence of {PROJECT_NAME} by the name of you project
  2. Rename .conf/.site-conf/{PROJECT_NAME}.conf to the desired configuration name
  3. Replace {PROJECT_URL} by the desired url of your project.
  4. Edit DB_USER, DB_PASS, DB_NAME in .conf/.env/db.env

##Step 3 update your hosts file with the new url

sudo echo 127.0.0.1 {PROJECT_URL} www.{PROJECT_URL}  >> /etc/hosts

###Step 4 Pull docker images

docker pull redis:alpine && docker pull willdurand/elk && docker pull php:7-fpm && docker pull nginx:latest && docker pull postgres:latest

###Step 5 go to /var/www/project_name & run docker-compose

docker-compose up -d

###Step 6 enjoy ! go to www.project_url (make sure your have something in the directory /var/www/{PROJECT_NAME}/web)

###Step 7 (optional) Add your ip of your host (seen from your php-fpm container) in web/config.php and web/app_dev.php (mine was 172.18.0.1)

if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '172.18.0.1', //ip to add
    '::1',
))) {
    header('HTTP/1.0 403 Forbidden');
    exit('This script is only accessible from localhost.');
}

If you don't know the ip to add :

var_dump($_SERVER['REMOTE_ADDR']); 
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(

###Useful commands

  1. List all active containers
docker ps
  1. List all the images available locally
docker images
  1. Open bash in the given docker container (use docker ps to see docker id):
docker exec -it {docker_id} bash
  1. Clear cache symfony :
docker exec -it $(docker ps -f name=php -q) php /var/www/{PROJECT_NAME}/bin/console cache:clear 
  1. Use psql in postgresql container :
docker exec -it $(docker ps -f name=postgre -q) psql -U postgres

##Todo

  1. Test db container
  2. Use php7-fpm docker images with recommended extensions and Xdebug

##Special thanks User Thomas Letellier for help & support

User Ronan Guilloux for inspiration

About

Docker-compose stack with php7 (php7-fpm), nginx and postgresql optimised for Symfony3 applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published