Coder Social home page Coder Social logo

choiz / docker-symfony Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maxpou/docker-symfony

0.0 2.0 0.0 1.6 MB

:whale: A docker multicontainer with NGINX, PHP7-FPM, MySQL, Redis and ELK (Elasticsearch Logstash and Kibana)

Home Page: http://www.maxpou.fr/docker-pour-symfony/

License: MIT License

Nginx 100.00%

docker-symfony's Introduction

Docker Symfony (PHP7-FPM - NGINX - MySQL - ELK - REDIS)

Build Status

Docker-symfony gives you everything you need for developing Symfony application. This complete stack run with docker and docker-compose (1.7 or higher).

Installation

  1. Create a .env from the .env.dist file. Adapt it according to your symfony application

    cp .env.dist .env
  2. Build/run containers with (with and without detached mode)

    $ docker-compose build
    $ docker-compose up
    $ docker-compose up -d
  3. Update your system host file (add symfony.dev)

    # get containers IP address and update host (replace IP according to your configuration)
    $ docker inspect --format '{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}' $(docker ps -f name=nginx -q)
    # unix only (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
    $ sudo echo "171.17.0.1 symfony.dev" >> /etc/hosts

    Note: If it's empty, run docker inspect $(docker ps -f name=nginx -q) | grep IPAddress instead.

  4. Prepare Symfony app

    1. Update app/config/parameters.yml

      # path/to/your/symfony-project/app/config/parameters.yml
      parameters:
          database_host: mysqldb
          #...
          redis_host: redis
    2. Composer install & create database

      $ docker-compose exec php bash
      $ composer install
      # Symfony2
      $ sf doctrine:database:create
      $ sf doctrine:schema:update --force
      $ sf doctrine:fixtures:load --no-interaction
      # Symfony3
      $ sf3 doctrine:database:create
      $ sf3 doctrine:schema:update --force
      $ sf3 doctrine:fixtures:load --no-interaction
  5. Enjoy :-)

Usage

Just run docker-compose -d, then:

How it works?

Have a look at the docker-compose.yml file, here are the docker-compose built images:

  • db: This is the MySQL database container,
  • php: This is the PHP-FPM container in which the application volume is mounted,
  • nginx: This is the Nginx webserver container in which application volume is mounted too,
  • elk: This is a ELK stack container which uses Logstash to collect logs, send them into Elasticsearch and visualize them with Kibana,
  • redis: This is a redis database container.

This results in the following running containers:

$ docker-compose ps
           Name                          Command               State              Ports            
--------------------------------------------------------------------------------------------------
dockersymfony_db_1            /entrypoint.sh mysqld            Up      0.0.0.0:3306->3306/tcp      
dockersymfony_elk_1           /usr/bin/supervisord -n -c ...   Up      0.0.0.0:81->80/tcp          
dockersymfony_nginx_1         nginx                            Up      443/tcp, 0.0.0.0:80->80/tcp
dockersymfony_php_1           php-fpm                          Up      0.0.0.0:9000->9000/tcp      
dockersymfony_redis_1         /entrypoint.sh redis-server      Up      0.0.0.0:6379->6379/tcp      

Useful commands

# bash commands
$ docker-compose exec php bash

# Composer (e.g. composer update)
$ docker-compose exec php composer update

# SF commands (Tips: there is an alias inside php container)
$ docker-compose exec php php /var/www/symfony/app/console cache:clear # Symfony2
$ docker-compose exec php php /var/www/symfony/bin/console cache:clear # Symfony3
# Same command by using alias
$ docker-compose exec php bash
$ sf cache:clear

# MySQL commands
$ docker-compose exec db mysql -uroot -p"root"

# Redis commands
$ docker-compose exec redis redis-cli

# F***ing cache/logs folder
$ sudo chmod -R 777 app/cache app/logs # Symfony2
$ sudo chmod -R 777 var/cache var/logs # Symfony3

# Check CPU consumption
$ docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -q))

# Delete all containers
$ docker rm $(docker ps -aq)

# Delete all images
$ docker rmi $(docker images -q)

FAQ

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
        - "8080:80"
    links:
        - db
  • Got this error: ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. ?
    Run docker-compose up -d instead.

  • Permission problem? See this doc (Setting up Permission)

Contributing

First of all, thank you for contributing โ™ฅ
If you find any typo/misconfiguration/... please send me a PR or open an issue. You can also ping me on twitter.
Also, while creating your Pull Request on GitHub, please write a description which gives the context and/or explains why you are creating it.

docker-symfony's People

Contributors

maxpou avatar n1c01a5 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.