From 4eb5f5a0c1d071a8fbf1f0bb06410b9382d68bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 11 Jul 2017 22:40:56 +0200 Subject: [PATCH] improve installation with docker and move static to _static --- .../access_control_model.png | Bin .../bundles/group/group_classes_uml.png | Bin .../bundles/group/group_classes_uml.pu | 0 .../code/installation/docker-compose.yml | 35 ++++++ source/_static/code/installation/nginx.conf | 71 +++++++++++ .../puml/pagination-sequence.png | Bin .../puml/pagination-sequence.puml | 0 source/bundles/group.rst | 2 +- source/development/access_control_model.rst | 2 +- source/development/pagination.rst | 4 +- source/installation/index.rst | 23 ++-- source/installation/install_with_docker.rst | 80 ++++++++++++ ...on.rst => installation_without_docker.rst} | 40 ++---- .../very_quick_start_with_docker.rst | 114 ------------------ 14 files changed, 212 insertions(+), 159 deletions(-) rename source/{static => _static}/access_control_model.png (100%) rename source/{static => _static}/bundles/group/group_classes_uml.png (100%) rename source/{static => _static}/bundles/group/group_classes_uml.pu (100%) create mode 100644 source/_static/code/installation/docker-compose.yml create mode 100644 source/_static/code/installation/nginx.conf rename source/{static => _static}/puml/pagination-sequence.png (100%) rename source/{static => _static}/puml/pagination-sequence.puml (100%) create mode 100644 source/installation/install_with_docker.rst rename source/installation/{installation.rst => installation_without_docker.rst} (90%) delete mode 100644 source/installation/very_quick_start_with_docker.rst diff --git a/source/static/access_control_model.png b/source/_static/access_control_model.png similarity index 100% rename from source/static/access_control_model.png rename to source/_static/access_control_model.png diff --git a/source/static/bundles/group/group_classes_uml.png b/source/_static/bundles/group/group_classes_uml.png similarity index 100% rename from source/static/bundles/group/group_classes_uml.png rename to source/_static/bundles/group/group_classes_uml.png diff --git a/source/static/bundles/group/group_classes_uml.pu b/source/_static/bundles/group/group_classes_uml.pu similarity index 100% rename from source/static/bundles/group/group_classes_uml.pu rename to source/_static/bundles/group/group_classes_uml.pu diff --git a/source/_static/code/installation/docker-compose.yml b/source/_static/code/installation/docker-compose.yml new file mode 100644 index 000000000..8048c190d --- /dev/null +++ b/source/_static/code/installation/docker-compose.yml @@ -0,0 +1,35 @@ +version: '2' +services: + fpm: + image: dev-activity-person-report + links: + - db + - redis + - logstash:gelf + environment: + - ADMIN_PASSWORD=admin +# add a link to custom.yml if needed +# volumes: +# - /tmp/custom.yml:/var/www/chill/app/config/custom.yml + redis: + image: redis + db: + image: chill/database + logstash: + image: logstash + command: logstash -e 'input { gelf { } } output { stdout{ } }' + expose: + - "12201/udp" + volumes: + - /var/log/logstash + nginx: + image: nginx + links: + - fpm + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + volumes_from: + - fpm:ro + ports: + - 8080:80 + diff --git a/source/_static/code/installation/nginx.conf b/source/_static/code/installation/nginx.conf new file mode 100644 index 000000000..bdc99fca0 --- /dev/null +++ b/source/_static/code/installation/nginx.conf @@ -0,0 +1,71 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + error_log /var/log/nginx/error.log; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + gzip off; + + #include /etc/nginx/conf.d/*.conf; + +upstream phpfcgi { + server fpm:9000; + # server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket +} + +server { + listen 80; + + #server_name symfony2; + root /var/www/chill/web; + + error_log /var/log/nginx/symfony2.error.log; + access_log /var/log/nginx/symfony2.access.log; + + # strip app.php/ prefix if it is present + rewrite ^/app\.php/?(.*)$ /$1 permanent; + + location / { + index app.php; + try_files $uri @rewriteapp; + } + + location @rewriteapp { + rewrite ^(.*)$ /app.php/$1 last; + } + + # pass the PHP scripts to FastCGI server from upstream phpfcgi + location ~ ^/(app|app_dev|config)\.php(/|$) { + fastcgi_pass phpfcgi; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS off; + } +} +} + diff --git a/source/static/puml/pagination-sequence.png b/source/_static/puml/pagination-sequence.png similarity index 100% rename from source/static/puml/pagination-sequence.png rename to source/_static/puml/pagination-sequence.png diff --git a/source/static/puml/pagination-sequence.puml b/source/_static/puml/pagination-sequence.puml similarity index 100% rename from source/static/puml/pagination-sequence.puml rename to source/_static/puml/pagination-sequence.puml diff --git a/source/bundles/group.rst b/source/bundles/group.rst index 37ac8db39..5d601084d 100644 --- a/source/bundles/group.rst +++ b/source/bundles/group.rst @@ -19,7 +19,7 @@ Allow to group people in a group. This group may be a family, an activity group, Entities ******** -.. figure:: /static/bundles/group/group_classes_uml.png +.. figure:: /_static/bundles/group/group_classes_uml.png .. _group-bundle-macros: diff --git a/source/development/access_control_model.rst b/source/development/access_control_model.rst index 8e31527de..58fe44319 100644 --- a/source/development/access_control_model.rst +++ b/source/development/access_control_model.rst @@ -55,7 +55,7 @@ Example: if some activities must be seen and updated between nurses and psycholo The concepts translated into code ----------------------------------- -.. figure:: /static/access_control_model.png +.. figure:: /_static/access_control_model.png Schema of the access control model diff --git a/source/development/pagination.rst b/source/development/pagination.rst index 52d0d81f1..cc223a5ef 100644 --- a/source/development/pagination.rst +++ b/source/development/pagination.rst @@ -24,7 +24,7 @@ In the controller, get the :class:`Chill\Main\Pagination\PaginatorFactory` from Then, render the pagination using the dedicated twig function. -.. code-block:: html+jinja2 +.. code-block:: html+twig {% extends "ChillPersonBundle::layout.html.twig" %} @@ -55,7 +55,7 @@ Where does the :code:`$paginator` get the page number ? Internally, the :code:`$paginator` object has a link to the :code:`Request` object, and it reads the :code:`page` parameter which contains the current page number. If this parameter is not present, the :code:`$paginator` assumes that we are on page 1. -.. figure:: /static/puml/pagination-sequence.png +.. figure:: /_static/puml/pagination-sequence.png The :code:`$paginator` get the current page from the request. diff --git a/source/installation/index.rst b/source/installation/index.rst index efb83d83b..42d128412 100644 --- a/source/installation/index.rst +++ b/source/installation/index.rst @@ -12,23 +12,16 @@ Free Documentation License". Installation -############################### +############# -Canonical installation -====================== -.. toctree:: - :maxdepth: 1 - - Common installation - -Very quick install with docker -================================= +Install with docker +=================== .. toctree:: :maxdepth: 2 - Very quick install with docker + Install with docker Usage in production ==================== @@ -37,6 +30,14 @@ Usage in production :maxdepth: 2 Installation in production + +Installation without docker +=========================== + +.. toctree:: + :maxdepth: 1 + + Common installation Update Chill and maintenance ============================== diff --git a/source/installation/install_with_docker.rst b/source/installation/install_with_docker.rst new file mode 100644 index 000000000..3fe1aca20 --- /dev/null +++ b/source/installation/install_with_docker.rst @@ -0,0 +1,80 @@ +.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +Install with docker +#################### + +The installation with docker is the canonical way to install Chill in production. + +Availables images and flavors +============================= + +We provide docker images which here : https://hub.docker.com/r/chill/standard/ + +There are differents "flavors" of docker, depending on which bundles are installed. Those flavors are available as tags, which are named according to bundles'names, with a prefix for the stable or dev versions. Those flavors are listed here : https://hub.docker.com/r/chill/standard/tags/. + + +How to install +============== + +Prerequisites +------------- + +Make sure you have installed ``docker`` and ``docker-compose`` installed. + + +Create your ``docker-compose`` project +-------------------------------------- + +1. Create an empty working directory (``mkdir chill && cd chill``) +2. Download or copy-paste the above :download:`docker-compose.yml file ` + +.. literalinclude:: /_static/code/installation/docker-compose.yml + :language: yaml + +3. Adapt eventually the image with your own requested flavor. +4. Download or copy-paster the above :download:`nginx.conf file `. This file must be located in the same directory of your ``docker-compose.yml`` file. + +.. literalinclude:: /_static/code/installation/nginx.conf + :language: nginx + +5. Launch the stack with ``docker-compose up``. Docker and docker-compose will download the container images, create an internal network and create the database schema. +6. Browse http://localhost:8080, you are ready to start ! + +To stop the container, you can type ``CTRL+C`` in the terminal to stop container **OR** run ``docker-compose stop`` in a separate terminal. + +On startup, you will only have access to the admin user: login ``admin``, password ``admin`` (as defined in ``docker-compose.yml`` file, under an environment variabled called ``ADMIN_PASSWORD``. + +Create fixtures (more user and fake data) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can create fixtures using the command ``docker-compose exec fpm php -d memory_limit=-1 doctrine:fixtures:load``. + +This will create those users, which password is always ``password``: + +* center a_social +* center a_administrative +* center a_direction +* center b_social +* center b_administrative +* center b_direction +* multi_center + +Create your own images +====================== + +You can create your own images, compile yourself and adapt the flavors to your needs. The source of the docker images are available here : https://framagit.org/Chill-project/docker-standard + + +.. _the composer documentation: https://getcomposer.org/doc/ +.. _the composer introduction: https://getcomposer.org/doc/00-intro.md +.. _the standard architecture: https://github.com/Champs-Libres/chill-standard +.. _composer: https://getcomposer.org +.. _Firefox: https://www.mozilla.org +.. _symfony framework: http://symfony.com +.. _*unaccent* extension: http://www.postgresql.org/docs/current/static/unaccent.html diff --git a/source/installation/installation.rst b/source/installation/installation_without_docker.rst similarity index 90% rename from source/installation/installation.rst rename to source/installation/installation_without_docker.rst index 63bc8b0c5..23e14b9f1 100644 --- a/source/installation/installation.rst +++ b/source/installation/installation_without_docker.rst @@ -6,14 +6,11 @@ A copy of the license is included in the section entitled "GNU Free Documentation License". -.. _install: -Install chill -############# +Install chill without docker +############################ -.. _basic-installation: - Basic installation `````````````````` @@ -45,34 +42,17 @@ Install composer .. note:: If you do not know composer, it is a good idea to have a glance at `the composer documentation`_ -Install composer on your system : +Install composer on your system, according to the instructions here : https://getcomposer.org/download -.. code-block:: bash - - curl -sS https://getcomposer.org/installer | php - -Install composer.phar globally -"""""""""""""""""""""""""""""" - -.. note:: - This part is not mandatory, if you do not want to install composer globally, you will have to replace in the commands of this tutorial `composer` by `php composer.phar`. - -Install composer globally on you system will made the installation process easier. To do this, simply run - -.. code-block:: bash - - sudo mv composer.phar /usr/local/bin/composer - sudo chmod +x /usr/local/bin/composer - -You can test the installation by running `which composer` or `composer`: those command should not raise any error. - -.. note:: - See `the composer introduction`_ to learn how to install composer on Mac OS X and Windows - -The docker database -""""""""""""""""""" +Install a database +"""""""""""""""""" Let's continue now by installing and configuring the docker database. + +.. note:: + If you do not want install a database with docker, you should create a postgresql database manually on your system, and add the extension ``UNACCENT``: ``CREATE EXTENSION "unaccent"``. + + You will find all details concerning the installation of docker on their official site looking for your OS into the menu `Install/Docker Engine `_. Once docker is installed, run : diff --git a/source/installation/very_quick_start_with_docker.rst b/source/installation/very_quick_start_with_docker.rst deleted file mode 100644 index 43c21ee87..000000000 --- a/source/installation/very_quick_start_with_docker.rst +++ /dev/null @@ -1,114 +0,0 @@ -.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.3 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -Very quick start with docker -############################# - - -.. _quick-start-with-docker: - -We have created a `docker container `_ to let you test `Chill` easily. - -.. note:: - - We assume docker is already installed on your machine. If Docker is not installed, have a look at `the install page in the docker documentation `_. - -Starting the containers -======================== - -Mac OS X & docker ------------------ - -To use docker on Mac OS X you need to use `boot2docker` or `docker-machine` - -Configuration of `boot2docker` -`````````````````````````````` - -.. code-block:: bash - - $ boot2docker start - $ boot2docker shellinit - - -Configuration of `docker-machine` -````````````````````````````````` - -.. code-block:: bash - - $ docker-machine start default - $ eval "$(docker-machine env default)" - - -Getting the last version of the docker images ----------------------------------------------- - -.. code-block:: bash - - docker pull chill/database - docker pull chill/demo-flavor - - -Prepare a database ------------------- - -.. code-block:: bash - - docker run --rm --name=chill_database chill/database - -The first time you will run this command, the image will be downloaded from docker registry. Please be patient. - -Run the container containing the code and attach it to the database -------------------------------------------------------------------- - -.. code-block:: bash - - docker run --rm --link chill_database:db -p 8989:8000 --name=chill_php chill/demo-flavor - -The image will also be downloaded from docker registry on first run. - -You can then browse on `http://localhost:8989 `_ and login with the created users, like `center a_social` (the complete list is below). Password is always 'password'. For Mac OS X, replace `localhost` by the IP of the docker VM (`boot2docker ip` or `docker-machine ip default`). - -Stopping the containers -======================= - -.. code-block:: bash - - docker stop chill_php - docker stop chill_database - -Limitations -============ - -* Those container should not be used in production -* The database should not be persisted or store persistant information: at each container startup, the container's data will be erased and replaced by new (partially) random fixtures - -Users created -============== - -The passwords are always `password` : - -The user's login created are : - -* center a_social -* center a_administrative -* center a_direction -* center b_social -* center b_administrative -* center b_direction -* multi_center -* admin - - - -.. _the composer documentation: https://getcomposer.org/doc/ -.. _the composer introduction: https://getcomposer.org/doc/00-intro.md -.. _the standard architecture: https://github.com/Champs-Libres/chill-standard -.. _composer: https://getcomposer.org -.. _Firefox: https://www.mozilla.org -.. _symfony framework: http://symfony.com -.. _*unaccent* extension: http://www.postgresql.org/docs/current/static/unaccent.html