diff --git a/Dockerfile.cloud b/Dockerfile.cloud index d036d88..8f300f6 100644 --- a/Dockerfile.cloud +++ b/Dockerfile.cloud @@ -53,7 +53,7 @@ COPY provision/ /opt/docker/provision/ COPY app/ /app/ -RUN /opt/docker/bin/provision add --tag bootstrap --tag entrypoint boilerplate-main boilerplate-deployment \ +RUN /opt/docker/bin/provision run --tag bootstrap --role boilerplate-main --role boilerplate-deployment \ && /opt/docker/bin/bootstrap.sh # Configure volume/workdir diff --git a/Dockerfile.development b/Dockerfile.development index 5c1ce6e..3827cd0 100644 --- a/Dockerfile.development +++ b/Dockerfile.development @@ -51,7 +51,7 @@ ENV PROVISION_CONTEXT "development" COPY etc/ /opt/docker/etc/ COPY provision/ /opt/docker/provision/ -RUN /opt/docker/bin/provision add --tag bootstrap --tag entrypoint boilerplate-main boilerplate-main-development boilerplate-deployment \ +RUN /opt/docker/bin/provision run --tag bootstrap --role boilerplate-main --role boilerplate-main-development --role boilerplate-deployment \ && /opt/docker/bin/bootstrap.sh # Configure volume/workdir diff --git a/Dockerfile.production b/Dockerfile.production index 271bd3b..54d9f50 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -51,7 +51,7 @@ ENV PROVISION_CONTEXT "production" COPY etc/ /opt/docker/etc/ COPY provision/ /opt/docker/provision/ -RUN /opt/docker/bin/provision add --tag bootstrap --tag entrypoint boilerplate-main boilerplate-deployment \ +RUN /opt/docker/bin/provision run --tag bootstrap --role boilerplate-main --role boilerplate-deployment \ && /opt/docker/bin/bootstrap.sh # Configure volume/workdir diff --git a/documentation/docs/index.rst b/documentation/docs/index.rst index 23a4371..3742049 100644 --- a/documentation/docs/index.rst +++ b/documentation/docs/index.rst @@ -18,7 +18,7 @@ Overview .. toctree:: - Back to Project Overview + Back to Project Overview content/introduction .. toctree:: diff --git a/etc/application.development.yml b/etc/application.development.yml index 20f6f47..7e790d3 100644 --- a/etc/application.development.yml +++ b/etc/application.development.yml @@ -1,8 +1,6 @@ --- PROVISION: - systemUpdate: false - install: apacheModPagespeed: false @@ -28,6 +26,9 @@ MAIL: # - { variable: "relayhost", value: "foobar" } PHP: + # PHP debugger [xdebug or blackfire or none] + debugger: "xdebug" + fpm: conf: # PM diff --git a/etc/application.environment.yml b/etc/application.environment.yml deleted file mode 100644 index 5de506a..0000000 --- a/etc/application.environment.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -DOCKER_ENVIRONMENT: - # Application - TYPO3_CONTEXT: "{{ lookup('env','TYPO3_CONTEXT') }}" - - SYMFONY_ENV: "{{ lookup('env','SYMFONY_ENV') }}" - SYMFONY_DEBUG: "{{ lookup('env','SYMFONY_DEBUG') }}" - - CAKE_ENV: "{{ lookup('env','CAKE_ENV') }}" - - YII_ENVIRONMENT: "{{ lookup('env','YII_ENVIRONMENT') }}" - - # General - CLI_SCRIPT: "{{ lookup('env','CLI_SCRIPT') }}" - MAIL_GATEWAY: "{{ lookup('env','MAIL_GATEWAY') }}" - - # MySQL - MYSQL_ROOT_PASSWORD: "{{ lookup('env','MYSQL_ROOT_PASSWORD') }}" - MYSQL_USER: "{{ lookup('env','MYSQL_USER') }}" - MYSQL_PASSWORD: "{{ lookup('env','MYSQL_PASSWORD') }}" - MYSQL_DATABASE: "{{ lookup('env','MYSQL_DATABASE') }}" - - # Postgres - POSTGRES_USER: "{{ lookup('env','POSTGRES_USER') }}" - POSTGRES_PASSWORD: "{{ lookup('env','POSTGRES_PASSWORD') }}" - - # FTP - FTP_USER: "{{ lookup('env','FTP_USER') }}" - FTP_PASSWORD: "{{ lookup('env','FTP_PASSWORD') }}" - FTP_PATH: "{{ lookup('env','FTP_PATH') }}" diff --git a/etc/application.production.yml b/etc/application.production.yml index 00e29bd..4e3f07f 100644 --- a/etc/application.production.yml +++ b/etc/application.production.yml @@ -1,8 +1,6 @@ --- PROVISION: - systemUpdate: true - install: apacheModPagespeed: false diff --git a/provision/roles/boilerplate-main-development/tasks/bootstrap.yml b/provision/roles/boilerplate-main-development/tasks/bootstrap.yml index eb4bee1..2fdb9f9 100644 --- a/provision/roles/boilerplate-main-development/tasks/bootstrap.yml +++ b/provision/roles/boilerplate-main-development/tasks/bootstrap.yml @@ -1,7 +1,7 @@ --- -- include: bootstrap/php-blackfire/debian.yml - when: ansible_distribution == 'CentOS' and PROVISION.install.phpBlackfire is defined and PROVISION.install.phpBlackfire +- include: bootstrap/php-debugger.blackfire.yml + when: PHP.debugger is defined and PHP.debugger == "blackfire" -- include: bootstrap/php-blackfire/redhat.yml - when: ansible_os_family == 'Debian' and PROVISION.install.phpBlackfire is defined and PROVISION.install.phpBlackfire +- include: bootstrap/php-debugger.none.yml + when: PHP.debugger is not defined or PHP.debugger == "" or PHP.debugger == "none" diff --git a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/debian.yml b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/debian.yml deleted file mode 100644 index 243bee6..0000000 --- a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/debian.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: Add blackfire.io key - apt_key: - url: https://packagecloud.io/gpg.key - state: present - -- name: Add blackfire.io repository - apt_repository: - repo: 'deb http://packages.blackfire.io/debian any main' - state: present - update_cache: yes - -- name: Install blackfire-php - apt: - name: '{{ item }}' - state: present - with_items: - - blackfire-php diff --git a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/redhat.yml b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/redhat.yml deleted file mode 100644 index 56dcc76..0000000 --- a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-blackfire/redhat.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- - -- name: Add blackfire.io key - rpm_key: - key: https://packagecloud.io/gpg.key - state: present - -- name: Add blackfire.io repository - get_url: - url: http://packages.blackfire.io/fedora/blackfire.repo - dest: /etc/yum.repos.d/blackfire.repo - mode: 0644 - -- name: Disable gpg check for blackfire (CentOS 7 workaround) - lineinfile: - dest: /etc/yum.repos.d/blackfire.repo - regexp: '^repo_gpgcheck=1' - line: 'repo_gpgcheck=0' - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7' - -- name: Install blackfire-php - yum: - name: '{{ item }}' - state: present - with_items: - - blackfire-php diff --git a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.blackfire.yml b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.blackfire.yml new file mode 100644 index 0000000..51cf8df --- /dev/null +++ b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.blackfire.yml @@ -0,0 +1,41 @@ +--- + +- name: Disable xdebug + replace: + dest: '{{ item }}' + regexp: '^[;\s]*((zend_)?(extension=))' + replace: ';\1' + ignore_errors: yes + with_items: + # RedHat + - "/etc/php.d/xdebug.ini" + # Debian - PHP 5.x + - "/etc/php5/mods-available/xdebug.ini" + - "/etc/php5/cli/conf.d/20-xdebug.ini" + - "/etc/php5/cli/conf.d/xdebug.ini" + - "/etc/php5/fpm/conf.d/20-xdebug.ini" + - "/etc/php5/fpm/conf.d/xdebug.ini" + # Debian - PHP 7.x + - "/etc/php/7.0/mods-available/xdebug.ini" + - "/etc/php/7.0/cli/conf.d/20-xdebug.ini" + - "/etc/php/7.0/fpm/conf.d/20-xdebug.ini" + +- name: Enable blackfire + replace: + dest: '{{ item }}' + regexp: '^[;\s]*((zend_)?(extension=))' + replace: '\1' + ignore_errors: yes + with_items: + # RedHat + - "/etc/php.d/zz-blackfire.ini" + # Debian - PHP 5.x + - "/etc/php5/conf.d/90-blackfire.ini" + - "/etc/php5/conf.d/zz-blackfire.ini" + - "/etc/php5/cli/conf.d/90-blackfire.ini" + - "/etc/php5/cli/conf.d/zz-blackfire.ini" + - "/etc/php5/fpm/conf.d/90-blackfire.ini" + - "/etc/php5/fpm/conf.d/zz-blackfire.ini" + # Debian - PHP 7.x + - "/etc/php/7.0/cli/conf.d/90-blackfire.ini" + - "/etc/php/7.0/fpm/conf.d/90-blackfire.ini" diff --git a/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.none.yml b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.none.yml new file mode 100644 index 0000000..efa55a4 --- /dev/null +++ b/provision/roles/boilerplate-main-development/tasks/bootstrap/php-debugger.none.yml @@ -0,0 +1,41 @@ +--- + +- name: Disable xdebug + replace: + dest: '{{ item }}' + regexp: '^[;\s]*((zend_)?(extension=))' + replace: ';\1' + ignore_errors: yes + with_items: + # RedHat + - "/etc/php.d/xdebug.ini" + # Debian - PHP 5.x + - "/etc/php5/mods-available/xdebug.ini" + - "/etc/php5/cli/conf.d/20-xdebug.ini" + - "/etc/php5/cli/conf.d/xdebug.ini" + - "/etc/php5/fpm/conf.d/20-xdebug.ini" + - "/etc/php5/fpm/conf.d/xdebug.ini" + # Debian - PHP 7.x + - "/etc/php/7.0/mods-available/xdebug.ini" + - "/etc/php/7.0/cli/conf.d/20-xdebug.ini" + - "/etc/php/7.0/fpm/conf.d/20-xdebug.ini" + +- name: Disable blackfire + replace: + dest: '{{ item }}' + regexp: '^[;\s]*((zend_)?(extension=))' + replace: ';\1' + ignore_errors: yes + with_items: + # RedHat + - "/etc/php.d/zz-blackfire.ini" + # Debian - PHP 5.x + - "/etc/php5/conf.d/90-blackfire.ini" + - "/etc/php5/conf.d/zz-blackfire.ini" + - "/etc/php5/cli/conf.d/90-blackfire.ini" + - "/etc/php5/cli/conf.d/zz-blackfire.ini" + - "/etc/php5/fpm/conf.d/90-blackfire.ini" + - "/etc/php5/fpm/conf.d/zz-blackfire.ini" + # Debian - PHP 7.x + - "/etc/php/7.0/cli/conf.d/90-blackfire.ini" + - "/etc/php/7.0/fpm/conf.d/90-blackfire.ini" diff --git a/provision/roles/boilerplate-main/tasks/bootstrap.yml b/provision/roles/boilerplate-main/tasks/bootstrap.yml index eb3f70a..9e29b8f 100644 --- a/provision/roles/boilerplate-main/tasks/bootstrap.yml +++ b/provision/roles/boilerplate-main/tasks/bootstrap.yml @@ -9,15 +9,6 @@ # Run tasks ############################# -- include: bootstrap/systemUpdate.centos.yml - when: PROVISION.systemUpdate is defined and PROVISION.systemUpdate and ansible_distribution == 'CentOS' - -- include: bootstrap/systemUpdate.ubuntu.yml - when: PROVISION.systemUpdate is defined and PROVISION.systemUpdate and ansible_distribution == 'Ubuntu' - -- include: bootstrap/composer.yml - when: PROVISION.install.phpComposer is defined and PROVISION.install.phpComposer - - include: bootstrap/services.yml - include: bootstrap/cron.yml diff --git a/provision/roles/boilerplate-main/tasks/bootstrap/composer.yml b/provision/roles/boilerplate-main/tasks/bootstrap/composer.yml deleted file mode 100644 index df8da1e..0000000 --- a/provision/roles/boilerplate-main/tasks/bootstrap/composer.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- stat: path=/usr/local/bin/composer - register: composer_bin - -- name: Update composer (phar) - command: 'composer self-update' - when: composer_bin.stat.exists is defined and composer_bin.stat.exists - ignore_errors: yes - -- name: Install composer (phar) - raw: 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer' - when: composer_bin.stat.exists is defined and not composer_bin.stat.exists - diff --git a/provision/roles/boilerplate-main/tasks/bootstrap/php.yml b/provision/roles/boilerplate-main/tasks/bootstrap/php.yml index e0c09b9..8c21955 100644 --- a/provision/roles/boilerplate-main/tasks/bootstrap/php.yml +++ b/provision/roles/boilerplate-main/tasks/bootstrap/php.yml @@ -2,13 +2,30 @@ - include_vars: "/opt/docker/etc/application.{{ PROVISION_CONTEXT }}.yml" +############################# +# Stats +############################# + +- stat: + path: /opt/docker/etc/php/fpm/php-fpm.conf + register: phpFpmConf + +- stat: + path: /opt/docker/etc/php/fpm/pool.d/application.conf + register: phpFpmApplicationPool + +############################# +# Tasks +############################# + - name: Configure php-fpm (pool www.conf) lineinfile: dest: "/opt/docker/etc/php/fpm/pool.d/application.conf" regexp: '^[\s;]*{{ item.variable }}[\s]*=' line: '{{ item.variable }} = {{ item.value }}' with_items: "{{ PHP.fpm.conf }}" - when: PHP.fpm.conf is defined and item.value != "" + when: PHP.fpm.conf is defined and item.value != "" and + phpFpmApplicationPool.stat.exists is defined and phpFpmApplicationPool.stat.exists - name: Configure php-fpm (php-fpm.conf) lineinfile: @@ -17,6 +34,7 @@ line: '{{ item.key }} = {{ item.value }}' with_items: - { key: 'daemonize', value: 'no' } + when: phpFpmConf.stat.exists is defined and phpFpmConf.stat.exists - name: Set development environment php.ini file: diff --git a/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.centos.yml b/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.centos.yml deleted file mode 100644 index 15f1e0b..0000000 --- a/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.centos.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: Update system packages (yum) ... will take some time - yum: name=* state=latest diff --git a/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.ubuntu.yml b/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.ubuntu.yml deleted file mode 100644 index f2270d7..0000000 --- a/provision/roles/boilerplate-main/tasks/bootstrap/systemUpdate.ubuntu.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- name: Upgrade system packages (apt-get dist-upgrade) ... will take some time - apt: - upgrade: dist - update_cache: true diff --git a/provision/roles/boilerplate-main/tasks/entrypoint.yml b/provision/roles/boilerplate-main/tasks/entrypoint.yml deleted file mode 100644 index e0224ca..0000000 --- a/provision/roles/boilerplate-main/tasks/entrypoint.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- include: entrypoint/mysql.yml -- include: entrypoint/php.yml diff --git a/provision/roles/boilerplate-main/tasks/entrypoint/mysql.yml b/provision/roles/boilerplate-main/tasks/entrypoint/mysql.yml deleted file mode 100644 index 7072644..0000000 --- a/provision/roles/boilerplate-main/tasks/entrypoint/mysql.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: Deploy root my.cnf - template: - src: templates/my.cnf.j2 - dest: /root/.my.cnf - owner: root - group: root - mode: 0644 - -- name: Deploy user my.cnf - template: - src: templates/my.cnf.j2 - dest: /home/.my.cnf - owner: "{{ lookup('env','APPLICATION_USER') }}" - group: "{{ lookup('env','APPLICATION_USER') }}" - mode: 0644 diff --git a/provision/roles/boilerplate-main/tasks/entrypoint/php.yml b/provision/roles/boilerplate-main/tasks/entrypoint/php.yml deleted file mode 100644 index b841d2c..0000000 --- a/provision/roles/boilerplate-main/tasks/entrypoint/php.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- include_vars: "/opt/docker/etc/application.{{ PROVISION_CONTEXT }}.yml" -- include_vars: "/opt/docker/etc/application.environment.yml" - -- name: Configure environment variables from DOCKER_ENVIRONMENT for php-fpm (pool www.conf) - lineinfile: - dest: "/opt/docker/etc/php/fpm/pool.d/application.conf" - regexp: '^env\[{{ item.key }}\][\s]*=' - line: 'env[{{ item.key }}] = "{{ item.value }}"' - with_dict: "{{ DOCKER_ENVIRONMENT }}" - when: DOCKER_ENVIRONMENT is defined and item.value != '' diff --git a/provision/roles/boilerplate-main/tasks/main.yml b/provision/roles/boilerplate-main/tasks/main.yml index 7895a52..1806c1a 100644 --- a/provision/roles/boilerplate-main/tasks/main.yml +++ b/provision/roles/boilerplate-main/tasks/main.yml @@ -3,7 +3,3 @@ - include: bootstrap.yml tags: - bootstrap - -- include: entrypoint.yml - tags: - - entrypoint