From 2ca8dd4e3c100f3618923cc50d8b9c81ab94b31a Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Mon, 8 May 2023 14:05:57 -0400 Subject: [PATCH 01/16] Sugar v13 - Support for PHP 8.2 (#1) * Fixed copyright notice as it was mistakely not updated * Implemented Sugar 13 * Added prefix to the images * Fixed Prefix tag with Flavor * Removing latest from the build * Addd meta id * Fixed context * Updating the context * Adding multiple platforms * Moved platforms to QEMU * Add platforms to build and push * amd64/v4 not supported * Restricting to linux/amd64,linux/arm64 * Fixed ES volume and Removed prebuilt yml * Fixed ES and removed latest * Added missing images * Added Docker config for DH images --------- Co-authored-by: Enrico Simonetti --- .github/workflows/sugar13.yml | 74 +++++++++++++++ README.md | 23 ++--- images/mysql/8032/Dockerfile | 4 + images/mysql/8032/config/mysql/docker.cnf | 13 +++ images/permissions/apps/sugarfixpermissions | 5 + images/php/82/apache/Dockerfile | 78 +++++++++++++++ .../apache2/mods-available/deflate.conf | 1 + .../config/apache2/sites-available/sugar.conf | 14 +++ images/php/82/apache/config/php/docker.ini | 19 ++++ .../config/php/mods-available/opcache.ini | 30 ++++++ .../config/php/mods-available/redis.ini | 1 + .../config/php/mods-available/tideways.ini | 2 + .../config/php/mods-available/xdebug.ini | 13 +++ .../config/php/mods-available/xhprof.ini | 2 + .../82/apache/config/php/opcache-blacklist | 7 ++ images/php/82/cron/Dockerfile | 78 +++++++++++++++ images/php/82/cron/apps/sugarcron | 25 +++++ images/php/82/cron/config/php/docker.ini | 11 +++ .../config/php/mods-available/opcache.ini | 30 ++++++ .../cron/config/php/mods-available/redis.ini | 1 + .../config/php/mods-available/tideways.ini | 2 + .../cron/config/php/mods-available/xdebug.ini | 10 ++ .../cron/config/php/mods-available/xhprof.ini | 2 + .../php/82/cron/config/php/opcache-blacklist | 7 ++ stacks/sugar13/README.md | 10 ++ stacks/sugar13/php82-local-build.yml | 94 +++++++++++++++++++ stacks/sugar13/php82.yml | 93 ++++++++++++++++++ tests/web_tests/8.2/composer.json | 5 + tests/web_tests/8.2/test_1.php | 2 + tests/web_tests/8.2/test_2.php | 9 ++ tests/web_tests/8.2/test_3.php | 10 ++ tests/web_tests/8.2/test_4.php | 20 ++++ tests/web_tests/8.2/test_5.php | 59 ++++++++++++ tests/web_tests/8.2/test_6.php | 3 + utilities/build/build.sh | 2 +- utilities/installfromzip.sh | 1 + utilities/stack.sh | 2 +- utilities/stacks.conf | 2 + 38 files changed, 751 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/sugar13.yml create mode 100755 images/mysql/8032/Dockerfile create mode 100644 images/mysql/8032/config/mysql/docker.cnf create mode 100644 images/php/82/apache/Dockerfile create mode 100644 images/php/82/apache/config/apache2/mods-available/deflate.conf create mode 100644 images/php/82/apache/config/apache2/sites-available/sugar.conf create mode 100644 images/php/82/apache/config/php/docker.ini create mode 100644 images/php/82/apache/config/php/mods-available/opcache.ini create mode 100644 images/php/82/apache/config/php/mods-available/redis.ini create mode 100644 images/php/82/apache/config/php/mods-available/tideways.ini create mode 100644 images/php/82/apache/config/php/mods-available/xdebug.ini create mode 100644 images/php/82/apache/config/php/mods-available/xhprof.ini create mode 100644 images/php/82/apache/config/php/opcache-blacklist create mode 100644 images/php/82/cron/Dockerfile create mode 100644 images/php/82/cron/apps/sugarcron create mode 100644 images/php/82/cron/config/php/docker.ini create mode 100644 images/php/82/cron/config/php/mods-available/opcache.ini create mode 100644 images/php/82/cron/config/php/mods-available/redis.ini create mode 100644 images/php/82/cron/config/php/mods-available/tideways.ini create mode 100644 images/php/82/cron/config/php/mods-available/xdebug.ini create mode 100644 images/php/82/cron/config/php/mods-available/xhprof.ini create mode 100644 images/php/82/cron/config/php/opcache-blacklist create mode 100644 stacks/sugar13/README.md create mode 100644 stacks/sugar13/php82-local-build.yml create mode 100644 stacks/sugar13/php82.yml create mode 100644 tests/web_tests/8.2/composer.json create mode 100644 tests/web_tests/8.2/test_1.php create mode 100644 tests/web_tests/8.2/test_2.php create mode 100644 tests/web_tests/8.2/test_3.php create mode 100644 tests/web_tests/8.2/test_4.php create mode 100644 tests/web_tests/8.2/test_5.php create mode 100644 tests/web_tests/8.2/test_6.php diff --git a/.github/workflows/sugar13.yml b/.github/workflows/sugar13.yml new file mode 100644 index 000000000..f1b60c21c --- /dev/null +++ b/.github/workflows/sugar13.yml @@ -0,0 +1,74 @@ +name: ci-v13 +on: + push: + tags: + - 'v*' + # branches: [ master, dev ] + # pull_request: + # branches: [ master ] +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + run: ['stacks/sugar13/php82-local-build.yml'] + steps: + - run: sudo sysctl -w vm.max_map_count=262144 + - run: echo '127.0.0.1 docker.local' | sudo tee -a /etc/hosts + - uses: actions/checkout@v1 + - run: cp -r ./tests/web_tests ./data/app/sugar/ + - run: ./tests/start.sh ${{ matrix.run }} + - run: ./tests/web_tests.sh ${{ matrix.run }} 13.0 8.2 + - run: ./tests/stop.sh ${{ matrix.run }} + + docker: + strategy: + fail-fast: false + matrix: + include: + - dockercontext: ./images/php/82/apache + image: sugarcrmdevelopers/sugardockerized + prefix: php8.2-apache- + - dockercontext: ./images/php/82/cron + image: sugarcrmdevelopers/sugardockerized + prefix: php8.2-cron- + - dockercontext: ./images/mysql/8032 + image: sugarcrmdevelopers/sugardockerized + prefix: mysql8.0.32- + - dockercontext: ./images/permissions + image: sugarcrmdevelopers/sugardockerized + prefix: permissions- + - dockercontext: ./images/testsmtp + image: sugarcrmdevelopers/sugardockerized + prefix: testsmtp- + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ matrix.image }} + flavor: | + latest=true + prefix=${{ matrix.prefix }},onlatest=true + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: ${{ matrix.dockercontext }} + push: true + platforms: 'linux/amd64,linux/arm64' + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index de517d22b..d98b8161a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sugar Dockerized [![Build Status](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar12.yml/badge.svg)](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar12.yml) ![Docker Pulls](https://img.shields.io/docker/pulls/esimonetti/sugardockerized.svg) +# Sugar Dockerized [![Build Status](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar13.yml/badge.svg)](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar13.yml) ![Docker Pulls](https://img.shields.io/docker/pulls/esimonetti/sugardockerized.svg) This repository will help you deploy a Docker based **development only** full stack for Sugar, meeting all the platform requirements for a different set of platform combinations. @@ -21,11 +21,12 @@ If you find this software useful, please consider supporting the work that went ## Stacks available There are few stacks available, with in itself multiple platform combinations. You can read more about the specific stacks on the links below: +* [Sugar 13](stacks/sugar13/README.md) - This stack is valid from version 13 for local developement also of Sugar Cloud only versions * [Sugar 12](stacks/sugar12/README.md) - This stack is valid from version 12 for local developement also of Sugar Cloud only versions * [Sugar 11](stacks/sugar11/README.md) - This stack is valid from version 11 for local developement also of Sugar Cloud only versions You will find additional stacks within the [stack directory of the project](stacks). -For most stacks, there are both the pre-built version (eg on Sugar 9: `./stacks/sugar9/php73.yml`) and a locally built version (eg on Sugar 9: `./stacks/sugar9/php73-local-build.yml`). The locally built version will be built run-time, and therefore those stacks will let you specify additional changes you might require to the docker images provided. Local builds will take much longer to deploy than pre-built ones. +For most stacks, there are both the pre-built version (eg on Sugar 13: `./stacks/sugar13/php82.yml`) and a locally built version (eg on Sugar 13: `./stacks/sugar13/php82-local-build.yml`). The locally built version will be built run-time, and therefore those stacks will let you specify additional changes you might require to the docker images provided. Local builds will take much longer to deploy than pre-built ones. ### Types of stacks There are mainly three types of stack: @@ -65,7 +66,7 @@ For details about the hostnames and credentials of each of the infrastructure co * Run the utility `build/build.sh`. Read more about [build/build.sh](https://github.com/esimonetti/SugarDockerized#buildbuildsh) ## Current version support -The main stacks work with [Sugar version 9.0 and all its platform requirements](http://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_9.0.x_Supported_Platforms/). Additional stacks are aligned with the platform requirements of version [8.0](http://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_8.0.x_Supported_Platforms/), [7.9](http://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_7.9.x_Supported_Platforms/) and stacks for Sugar Cloud only versions for local development only. +The main stacks work with [Sugar version 13.0 and all its platform requirements](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_13.0.x_Supported_Platforms/). Additional stacks are aligned with the platform requirements of version [12.x](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_12.0.x_Supported_Platforms/), [11.x](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_11.0.x_Supported_Platforms/) and stacks for Sugar Cloud only versions for local development only. ## System's details @@ -233,10 +234,10 @@ All directories and files within "data" are now owned by uid:gid 1000:1000 It sets the correct ownership of the data directories #### stack.sh -```./utilities/stack.sh 80 down``` +```./utilities/stack.sh 13 down``` ``` -./utilities/stack.sh 80 down -stacks/sugar8/php71.yml down +./utilities/stack.sh 13 down +stacks/sugar13/php82.yml down Stopping sugar-cron ... done Stopping sugar-web1 ... done Stopping sugar-redis ... done @@ -248,10 +249,10 @@ Removing sugar-redis ... done Removing sugar-mysql ... done Removing sugar-permissions ... done Removing sugar-elasticsearch ... done -Removing network sugar8_default +Removing network sugar13_default No stopped containers ``` -It helps to take the default stack for the sugar version passed as a parameter, up or down. It expects two parameters: version number (eg: 80, 90 etc) and up/down. +It helps to take the default stack for the sugar version passed as a parameter, up or down. It expects two parameters: version number (eg: 12, 13 etc) and up/down. Have a look at the configuration file `./utilities/stacks.conf`, to know all the available stack combinations for the script. For some of the main stacks is available the "local" version of the stack, that allows local modification of settings and local docker image building. #### runcli.sh @@ -306,8 +307,8 @@ The following arguments should be adapted to target server: #### installfromzip.sh This script requires a Sugar zip package, and the zip package needs to be on the host running SugarDockerized. -If the installable zip package is located within the local directory `~/installable/SugarEnt-9.0.2.zip` the install command would be: -```./utilities/installfromzip.sh ~/installable/SugarEnt-9.0.2.zip``` +If the installable zip package is located within the local directory `~/installable/SugarEnt-13.0.0.zip` the install command would be: +```./utilities/installfromzip.sh ~/installable/SugarEnt-13.0.0.zip``` The script will perform all the steps required to silently install the software within the SugarDockerized stack currently running. To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](https://github.com/esimonetti/SugarDockerized#buildsilentinstallsh). @@ -316,7 +317,7 @@ To know more about additional custom configuration parameters and actions that c This script is most likely for Sugar Employees only. The script requires a clone of Sugar's git repository within `./data/app/Mango` with the `index.php` located within `./data/app/Mango/sugarcrm/index.php`. If we want to build the application version 10.0.0 Enterprise, the build command would be: -```./utilities/build/build.sh ent 10.0.0``` +```./utilities/build/build.sh ent 13.0.0``` The script will perform all the steps necessary to build the current branch of the software and also perform its silent installation. To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](https://github.com/esimonetti/SugarDockerized#buildsilentinstallsh). diff --git a/images/mysql/8032/Dockerfile b/images/mysql/8032/Dockerfile new file mode 100755 index 000000000..4e829b593 --- /dev/null +++ b/images/mysql/8032/Dockerfile @@ -0,0 +1,4 @@ +FROM mysql:8.0.32 +MAINTAINER enrico.simonetti@gmail.com + +COPY config/mysql/docker.cnf /etc/mysql/conf.d/docker.cnf diff --git a/images/mysql/8032/config/mysql/docker.cnf b/images/mysql/8032/config/mysql/docker.cnf new file mode 100644 index 000000000..baf9ec946 --- /dev/null +++ b/images/mysql/8032/config/mysql/docker.cnf @@ -0,0 +1,13 @@ +[mysqld] +skip-host-cache +skip-name-resolve +default-storage-engine=InnoDB +innodb_file_per_table +innodb_buffer_pool_size=256M +character-set-server=utf8mb4 +collation-server=utf8mb4_general_ci +optimizer-switch=block_nested_loop=off +sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" + +[mysqldump] +max-allowed-packet=128M diff --git a/images/permissions/apps/sugarfixpermissions b/images/permissions/apps/sugarfixpermissions index 37352438a..d3bd4402a 100644 --- a/images/permissions/apps/sugarfixpermissions +++ b/images/permissions/apps/sugarfixpermissions @@ -2,9 +2,12 @@ DIR=/var/www/html +echo Fixing ownership permissions # Only change ownership on files that aren't currently owned by sugar:sugar find ${DIR} -noleaf \( \! -user sugar -o \! -group sugar \) -print0 | xargs -0 -r chown sugar:sugar +echo Fixing mode of files + # Only change the mode of files/directories within sugar that are not 664/775. Exludes phpunit and sugarcrm find ${DIR}/sugar -noleaf -type d \! -perm 775 -print0 2> /dev/null | xargs -0 -r chmod 775 2> /dev/null find ${DIR}/sugar -noleaf -type f \! -name phpunit \! -name sugarcrm \! -perm 664 -print0 2> /dev/null | xargs -0 -r chmod 664 2> /dev/null @@ -12,10 +15,12 @@ find ${DIR}/sugar -noleaf -type f \! -name phpunit \! -name sugarcrm \! -perm 66 # Directly set these to mode 700 if [ -e ${DIR}/sugar/bin/sugarcrm ] then + echo Fixing mode of sugarcrm chmod 700 ${DIR}/sugar/bin/sugarcrm fi if [ -e ${DIR}/sugar/vendor/phpunit/phpunit/phpunit ] then + echo Fixing mode of phpunit chmod 700 ${DIR}/sugar/vendor/phpunit/phpunit/phpunit fi diff --git a/images/php/82/apache/Dockerfile b/images/php/82/apache/Dockerfile new file mode 100644 index 000000000..63beb420d --- /dev/null +++ b/images/php/82/apache/Dockerfile @@ -0,0 +1,78 @@ +FROM php:8.2.2-apache + +RUN apt-get update \ + && apt-get install -y \ + graphviz \ + libpng-dev \ + libgmp-dev \ + libzip-dev \ + libc-client-dev \ + libkrb5-dev \ + libldap2-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libxml2-dev \ + git \ + --no-install-recommends + +RUN apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +RUN adduser sugar --disabled-password --disabled-login --gecos "" + +RUN echo " /usr/local/php/prepend.php + +COPY config/apache2/mods-available/deflate.conf /etc/apache2/mods-available/deflate.conf +COPY config/apache2/sites-available/sugar.conf /etc/apache2/sites-available/sugar.conf + +RUN set -ex \ + && . "/etc/apache2/envvars" \ + && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" \ + && a2enmod headers expires deflate rewrite \ + && sed -i "s#Timeout .*#Timeout 600#" /etc/apache2/apache2.conf \ + && a2dissite 000-default \ + && a2ensite sugar + +RUN docker-php-ext-install mysqli \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install gd \ + && docker-php-ext-install gmp \ + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && docker-php-ext-install imap \ + && docker-php-ext-install zip \ + && docker-php-ext-install ldap \ + && pecl install xdebug-3.2.0 \ + && pecl install redis \ + && docker-php-ext-enable redis \ + && docker-php-ext-install soap + +RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ +&& docker-php-ext-install -j$(nproc) gd + +# enabled by default, it can be disabled locally +COPY config/php/mods-available/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini +COPY config/php/mods-available/opcache.ini /usr/local/etc/php/conf.d/opcache.ini +COPY config/php/opcache-blacklist /usr/local/etc/php/opcache-blacklist + +RUN git clone https://github.com/tideways/php-xhprof-extension.git tideways \ + && cd tideways \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/tideways.ini /usr/local/etc/php/conf.d/tideways.ini + +RUN git clone https://github.com/longxinH/xhprof.git xhprof \ + && cd xhprof/extension/ \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/xhprof.ini /usr/local/etc/php/conf.d/xhprof.ini + +WORKDIR "/var/www/html/sugar" diff --git a/images/php/82/apache/config/apache2/mods-available/deflate.conf b/images/php/82/apache/config/apache2/mods-available/deflate.conf new file mode 100644 index 000000000..7bb892d3e --- /dev/null +++ b/images/php/82/apache/config/apache2/mods-available/deflate.conf @@ -0,0 +1 @@ +AddOutputFilterByType DEFLATE application/json application/javascript text/css diff --git a/images/php/82/apache/config/apache2/sites-available/sugar.conf b/images/php/82/apache/config/apache2/sites-available/sugar.conf new file mode 100644 index 000000000..6411ef409 --- /dev/null +++ b/images/php/82/apache/config/apache2/sites-available/sugar.conf @@ -0,0 +1,14 @@ + + ServerAdmin webmaster@localhost + ServerName localhost + + DocumentRoot /var/www/html + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + + Options Indexes FollowSymLinks + AllowOverride All + + diff --git a/images/php/82/apache/config/php/docker.ini b/images/php/82/apache/config/php/docker.ini new file mode 100644 index 000000000..4280b2847 --- /dev/null +++ b/images/php/82/apache/config/php/docker.ini @@ -0,0 +1,19 @@ +date.timezone = GMT +error_reporting = E_ALL \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED +error_log = /var/log/apache2/error.log +log_errors = On +display_errors = Off +memory_limit = 1024M +post_max_size = 100M +upload_max_filesize = 100M +max_execution_time = 600 +max_input_time = 600 +realpath_cache_size = 512k +realpath_cache_ttl = 600 +mbstring.func_overload = 0 +session.use_cookies = 1 +session.cookie_httponly = 1 +session.use_trans_sid = 0 +session.save_handler = redis +session.save_path = "tcp://sugar-redis:6379" +auto_prepend_file = "/usr/local/php/prepend.php" \ No newline at end of file diff --git a/images/php/82/apache/config/php/mods-available/opcache.ini b/images/php/82/apache/config/php/mods-available/opcache.ini new file mode 100644 index 000000000..b0e4ac566 --- /dev/null +++ b/images/php/82/apache/config/php/mods-available/opcache.ini @@ -0,0 +1,30 @@ +; configuration for php ZendOpcache module +; priority=10 +zend_extension=opcache.so +opcache.blacklist_filename="/usr/local/etc/php/opcache-blacklist" +opcache.consistency_checks=0 +opcache.dups_fix=0 +opcache.enable=1 +opcache.enable_cli=0 +opcache.enable_file_override=0 +opcache.error_log="" +opcache.fast_shutdown=1 +opcache.file_update_protection=2 +opcache.force_restart_timeout=180 +opcache.inherited_hack=1 +opcache.interned_strings_buffer=8 +opcache.load_comments=1 +opcache.log_verbosity_level=1 +opcache.max_accelerated_files=4000 +opcache.max_file_size=0 +opcache.max_wasted_percentage=5 +opcache.memory_consumption=256 +opcache.optimization_level=0x7FFFBFFF +opcache.preferred_memory_model="" +opcache.protect_memory=0 +opcache.restrict_api="" +opcache.revalidate_freq=2 +opcache.revalidate_path=0 +opcache.save_comments=1 +opcache.use_cwd=1 +opcache.validate_timestamps=1 diff --git a/images/php/82/apache/config/php/mods-available/redis.ini b/images/php/82/apache/config/php/mods-available/redis.ini new file mode 100644 index 000000000..6aecae489 --- /dev/null +++ b/images/php/82/apache/config/php/mods-available/redis.ini @@ -0,0 +1 @@ +extension=redis.so diff --git a/images/php/82/apache/config/php/mods-available/tideways.ini b/images/php/82/apache/config/php/mods-available/tideways.ini new file mode 100644 index 000000000..de7c8f9f0 --- /dev/null +++ b/images/php/82/apache/config/php/mods-available/tideways.ini @@ -0,0 +1,2 @@ +extension=tideways_xhprof.so +tideways_xhprof.auto_prepend_library=0 diff --git a/images/php/82/apache/config/php/mods-available/xdebug.ini b/images/php/82/apache/config/php/mods-available/xdebug.ini new file mode 100644 index 000000000..a1c102c2d --- /dev/null +++ b/images/php/82/apache/config/php/mods-available/xdebug.ini @@ -0,0 +1,13 @@ +;zend_extension=xdebug.so +xdebug.max_nesting_level=500 +xdebug.profiler_enable=0 + +; enable remote debug +; Below are xdebug2 options. Use default xdebug3 +;xdebug.remote_enable=1 +;xdebug.remote_port=9000 +;xdebug.remote_host=10.10.10.1 +;xdebug.remote_autostart = 1 +xdebug.client_host=10.10.10.1 +xdebug.client_port=9003 +xdebug.idekey=XDEBUG_SESSION diff --git a/images/php/82/apache/config/php/mods-available/xhprof.ini b/images/php/82/apache/config/php/mods-available/xhprof.ini new file mode 100644 index 000000000..dd7fd32c6 --- /dev/null +++ b/images/php/82/apache/config/php/mods-available/xhprof.ini @@ -0,0 +1,2 @@ +extension = xhprof.so +xhprof.output_dir = /tmp/xhprof diff --git a/images/php/82/apache/config/php/opcache-blacklist b/images/php/82/apache/config/php/opcache-blacklist new file mode 100644 index 000000000..5edb9d104 --- /dev/null +++ b/images/php/82/apache/config/php/opcache-blacklist @@ -0,0 +1,7 @@ +/var/www/html/sugar/config_override.php +/var/www/html/sugar/cache/modules/Teams/TeamSetCache.php +/var/www/html/sugar/cache/modules/Teams/TeamSetMD5Cache.php +/var/www/html/sugar/cache/class_map.php +/var/www/html/sugar/cache/smarty/templates_c/* +/var/www/html/sugar/custom/modules/unified_search_modules_display.php +/var/www/html/sugar/custom/modulebuilder/* diff --git a/images/php/82/cron/Dockerfile b/images/php/82/cron/Dockerfile new file mode 100644 index 000000000..0c600ce12 --- /dev/null +++ b/images/php/82/cron/Dockerfile @@ -0,0 +1,78 @@ +FROM php:8.2.2-cli + +RUN apt-get update \ + && apt-get install -y \ + sudo \ + vim \ + unzip \ + libpng-dev \ + libgmp-dev \ + libzip-dev \ + libc-client-dev \ + libkrb5-dev \ + libldap2-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libxml2-dev \ + git \ + --no-install-recommends + +RUN apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +RUN adduser sugar --disabled-password --disabled-login --gecos "" \ + && echo "sugar ALL=NOPASSWD: ALL" > /etc/sudoers.d/sugar + +RUN echo " /usr/local/php/prepend.php + +RUN docker-php-ext-install mysqli \ + && docker-php-ext-install bcmath \ + && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \ + && docker-php-ext-install gd \ + && docker-php-ext-install gmp \ + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && docker-php-ext-install imap \ + && docker-php-ext-install zip \ + && docker-php-ext-install ldap \ + && docker-php-ext-install ldap \ + && pecl install xdebug-3.2.0 \ + && pecl install redis \ + && docker-php-ext-enable redis \ + && docker-php-ext-install soap + +RUN docker-php-ext-install -j$(nproc) gd + +# disable by default, it can be enabled locally +#COPY config/php/mods-available/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini +COPY config/php/mods-available/opcache.ini /usr/local/etc/php/conf.d/opcache.ini +COPY config/php/opcache-blacklist /usr/local/etc/php/opcache-blacklist + +RUN git clone https://github.com/tideways/php-xhprof-extension.git tideways \ + && cd tideways \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/tideways.ini /usr/local/etc/php/conf.d/tideways.ini + +RUN git clone https://github.com/longxinH/xhprof.git xhprof \ + && cd xhprof/extension/ \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/xhprof.ini /usr/local/etc/php/conf.d/xhprof.ini + +RUN curl -sS http://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer + +COPY apps/sugarcron /usr/local/bin/sugarcron +RUN chmod +x /usr/local/bin/sugarcron + +WORKDIR "/var/www/html/sugar" +USER sugar + +CMD ["/usr/local/bin/sugarcron"] diff --git a/images/php/82/cron/apps/sugarcron b/images/php/82/cron/apps/sugarcron new file mode 100644 index 000000000..ce24473ac --- /dev/null +++ b/images/php/82/cron/apps/sugarcron @@ -0,0 +1,25 @@ +#!/usr/local/bin/php +connect('sugar-redis', 6379); +$redis->set($ok, $ok); + +if ($redis->get($ok) == $ok) { + echo $ok; +} diff --git a/tests/web_tests/8.2/test_4.php b/tests/web_tests/8.2/test_4.php new file mode 100644 index 000000000..9ac401e21 --- /dev/null +++ b/tests/web_tests/8.2/test_4.php @@ -0,0 +1,20 @@ +connect_error) { + die('Connection failed: ' . $conn->connect_error); +} + +$sql = 'CREATE DATABASE dockertest'; +if ($conn->query($sql) === TRUE) { + $conn->select_db('dockertest'); + $sql = 'CREATE TABLE test ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL )'; + if ($conn->query($sql) === TRUE) { + echo $ok; + } + $sql = 'DROP DATABASE dockertest'; + $conn->query($sql); +} + +$conn->close(); diff --git a/tests/web_tests/8.2/test_5.php b/tests/web_tests/8.2/test_5.php new file mode 100644 index 000000000..7f73a81d2 --- /dev/null +++ b/tests/web_tests/8.2/test_5.php @@ -0,0 +1,59 @@ + 4.0, + 'headers' => array( + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ) + ) +); + +$error = true; + +$response = $client->get($url . '_stats'); +if ($response->getStatusCode() == 200) { + + $response = $client->put($url . 'testbucket'); + if ($response->getStatusCode() == 200) { + $response = $client->put( + $url . 'testbucket/_doc/enrico?refresh=true', + array ( + //'debug' => TRUE, + 'json' => array( + 'name' => 'Enrico Simonetti' + ) + ) + ); + if ($response->getStatusCode() == 201) { + $response = $client->get( + $url . 'testbucket/_search', + array( + //'debug' => TRUE, + 'query' => array( + 'q' => 'simonetti' + ) + ) + ); + $decoded = json_decode($response->getBody(), true); + if (!empty($decoded['hits']) + && $decoded['hits']['total']['value'] === 1 + && $decoded['hits']['hits']['0']['_id'] === 'enrico') { + // expected result found + $error = false; + } + } + + $response = $client->delete($url . 'testbucket'); + } +} + +if (!$error) { + echo $ok; +} diff --git a/tests/web_tests/8.2/test_6.php b/tests/web_tests/8.2/test_6.php new file mode 100644 index 000000000..11dced1e9 --- /dev/null +++ b/tests/web_tests/8.2/test_6.php @@ -0,0 +1,3 @@ + Date: Wed, 10 May 2023 10:09:41 -0400 Subject: [PATCH 02/16] Decoupled Images for PHP8.0 (#2) * Decoupled Images for PHP8.0 * Added sugar12 and commons to GH Actions * Fixed strategy run for local build only --- .github/workflows/sugar-commons.yml | 50 ++++++++++++++++++ .github/workflows/sugar12.yml | 58 ++++++++++++++++++--- .github/workflows/sugar13.yml | 3 -- .gitignore | 1 + images/php/80/apache/Dockerfile | 20 -------- images/php/80/apache/config/php/docker.ini | 19 +++++++ images/php/80/cron/Dockerfile | 12 ----- images/php/80/cron/config/php/docker.ini | 11 ++++ stacks/sugar12/php80-local-build.yml | 6 +++ stacks/sugar12/php80.yml | 13 ++--- tests/web_tests/8.0/composer.json | 5 ++ tests/web_tests/8.0/test_1.php | 2 + tests/web_tests/8.0/test_2.php | 9 ++++ tests/web_tests/8.0/test_3.php | 10 ++++ tests/web_tests/8.0/test_4.php | 20 ++++++++ tests/web_tests/8.0/test_5.php | 59 ++++++++++++++++++++++ tests/web_tests/8.0/test_6.php | 3 ++ 17 files changed, 253 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/sugar-commons.yml create mode 100644 images/php/80/apache/config/php/docker.ini create mode 100644 images/php/80/cron/config/php/docker.ini create mode 100644 tests/web_tests/8.0/composer.json create mode 100644 tests/web_tests/8.0/test_1.php create mode 100644 tests/web_tests/8.0/test_2.php create mode 100644 tests/web_tests/8.0/test_3.php create mode 100644 tests/web_tests/8.0/test_4.php create mode 100644 tests/web_tests/8.0/test_5.php create mode 100644 tests/web_tests/8.0/test_6.php diff --git a/.github/workflows/sugar-commons.yml b/.github/workflows/sugar-commons.yml new file mode 100644 index 000000000..ec84ec985 --- /dev/null +++ b/.github/workflows/sugar-commons.yml @@ -0,0 +1,50 @@ +name: ci-commons +on: + push: + tags: + - 'v*' + # branches: [ master, dev ] + # pull_request: + # branches: [ master ] +jobs: + docker: + strategy: + fail-fast: false + matrix: + include: + - dockercontext: ./images/permissions + image: sugarcrmdevelopers/sugardockerized + prefix: permissions- + - dockercontext: ./images/testsmtp + image: sugarcrmdevelopers/sugardockerized + prefix: testsmtp- + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ matrix.image }} + flavor: | + latest=true + prefix=${{ matrix.prefix }},onlatest=true + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: ${{ matrix.dockercontext }} + push: true + platforms: 'linux/amd64,linux/arm64' + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/sugar12.yml b/.github/workflows/sugar12.yml index ec8319174..2c815db20 100644 --- a/.github/workflows/sugar12.yml +++ b/.github/workflows/sugar12.yml @@ -1,21 +1,65 @@ -name: +name: ci-v12 on: - #push: - # branches: [ master, dev ] - pull_request: - branches: [ master ] + push: + tags: + - 'v*' jobs: tests: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - run: ['stacks/sugar12/php80.yml', 'stacks/sugar12/php80-local-build.yml'] + run: ['stacks/sugar12/php80-local-build.yml'] steps: - run: sudo sysctl -w vm.max_map_count=262144 - run: echo '127.0.0.1 docker.local' | sudo tee -a /etc/hosts - uses: actions/checkout@v1 - run: cp -r ./tests/web_tests ./data/app/sugar/ - run: ./tests/start.sh ${{ matrix.run }} - - run: ./tests/web_tests.sh ${{ matrix.run }} 11.0 7.4 + - run: ./tests/web_tests.sh ${{ matrix.run }} 12.0 8.0 - run: ./tests/stop.sh ${{ matrix.run }} + + docker: + strategy: + fail-fast: false + matrix: + include: + - dockercontext: ./images/php/80/apache + image: sugarcrmdevelopers/sugardockerized + prefix: php8.0-apache- + - dockercontext: ./images/php/80/cron + image: sugarcrmdevelopers/sugardockerized + prefix: php8.0-cron- + - dockercontext: ./images/mysql/80 + image: sugarcrmdevelopers/sugardockerized + prefix: mysql8.0- + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ matrix.image }} + flavor: | + latest=true + prefix=${{ matrix.prefix }},onlatest=true + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: ${{ matrix.dockercontext }} + push: true + platforms: 'linux/amd64,linux/arm64' + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/sugar13.yml b/.github/workflows/sugar13.yml index f1b60c21c..a24840703 100644 --- a/.github/workflows/sugar13.yml +++ b/.github/workflows/sugar13.yml @@ -3,9 +3,6 @@ on: push: tags: - 'v*' - # branches: [ master, dev ] - # pull_request: - # branches: [ master ] jobs: tests: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 7fa42ca46..c30b64563 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ data backups +.DS_Store \ No newline at end of file diff --git a/images/php/80/apache/Dockerfile b/images/php/80/apache/Dockerfile index d42e7b503..82889b995 100644 --- a/images/php/80/apache/Dockerfile +++ b/images/php/80/apache/Dockerfile @@ -24,26 +24,6 @@ RUN adduser sugar --disabled-password --disabled-login --gecos "" RUN echo " /usr/local/php/prepend.php -RUN echo 'date.timezone = GMT' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'error_reporting = E_ALL \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'error_log = /var/log/apache2/error.log' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'log_errors = On' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'display_errors = Off' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'post_max_size = 100M' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'upload_max_filesize = 100M' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'max_execution_time = 600' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'max_input_time = 600' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'realpath_cache_size = 512k' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'realpath_cache_ttl = 600' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'mbstring.func_overload = 0' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'session.use_cookies = 1' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'session.cookie_httponly = 1' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'session.use_trans_sid = 0' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'session.save_handler = redis' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'session.save_path = "tcp://sugar-redis:6379"' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'auto_prepend_file = "/usr/local/php/prepend.php"' >> /usr/local/etc/php/conf.d/docker.ini - COPY config/apache2/mods-available/deflate.conf /etc/apache2/mods-available/deflate.conf COPY config/apache2/sites-available/sugar.conf /etc/apache2/sites-available/sugar.conf diff --git a/images/php/80/apache/config/php/docker.ini b/images/php/80/apache/config/php/docker.ini new file mode 100644 index 000000000..4280b2847 --- /dev/null +++ b/images/php/80/apache/config/php/docker.ini @@ -0,0 +1,19 @@ +date.timezone = GMT +error_reporting = E_ALL \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED +error_log = /var/log/apache2/error.log +log_errors = On +display_errors = Off +memory_limit = 1024M +post_max_size = 100M +upload_max_filesize = 100M +max_execution_time = 600 +max_input_time = 600 +realpath_cache_size = 512k +realpath_cache_ttl = 600 +mbstring.func_overload = 0 +session.use_cookies = 1 +session.cookie_httponly = 1 +session.use_trans_sid = 0 +session.save_handler = redis +session.save_path = "tcp://sugar-redis:6379" +auto_prepend_file = "/usr/local/php/prepend.php" \ No newline at end of file diff --git a/images/php/80/cron/Dockerfile b/images/php/80/cron/Dockerfile index eb99e99dd..7e092222a 100644 --- a/images/php/80/cron/Dockerfile +++ b/images/php/80/cron/Dockerfile @@ -27,18 +27,6 @@ RUN adduser sugar --disabled-password --disabled-login --gecos "" \ RUN echo " /usr/local/php/prepend.php -RUN echo 'date.timezone = GMT' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'error_reporting = E_ALL \& ~E_WARNING \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'error_log = /proc/1/fd/1' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'log_errors = On' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'display_errors = Off' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'max_execution_time = -1' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'realpath_cache_size = 512k' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'realpath_cache_ttl = 600' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'mbstring.func_overload = 0' >> /usr/local/etc/php/conf.d/docker.ini \ - && echo 'auto_prepend_file = "/usr/local/php/prepend.php"' >> /usr/local/etc/php/conf.d/docker.ini - RUN docker-php-ext-install mysqli \ && docker-php-ext-install bcmath \ && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \ diff --git a/images/php/80/cron/config/php/docker.ini b/images/php/80/cron/config/php/docker.ini new file mode 100644 index 000000000..c44055bec --- /dev/null +++ b/images/php/80/cron/config/php/docker.ini @@ -0,0 +1,11 @@ +date.timezone = GMT +error_reporting = E_ALL \& ~E_WARNING \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED +error_log = /proc/1/fd/1 +log_errors = On +display_errors = Off +memory_limit = -1 +max_execution_time = -1 +realpath_cache_size = 512k +realpath_cache_ttl = 600 +mbstring.func_overload = 0 +auto_prepend_file = "/usr/local/php/prepend.php" \ No newline at end of file diff --git a/stacks/sugar12/php80-local-build.yml b/stacks/sugar12/php80-local-build.yml index 1a462ce8d..b75c0fce4 100644 --- a/stacks/sugar12/php80-local-build.yml +++ b/stacks/sugar12/php80-local-build.yml @@ -14,6 +14,7 @@ services: - "APACHE_RUN_GROUP=sugar" volumes: - ../../data/app:/var/www/html + - ../../images/php/80/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -29,6 +30,7 @@ services: build: ../../images/php/80/cron volumes: - ../../data/app:/var/www/html + - ../../images/php/80/cron/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -81,6 +83,10 @@ services: build: ../../images/permissions volumes: - ../../data/app:/var/www/html + testsmtp: + container_name: "sugar-smtp" + image: sugar_testsmtp + build: ../../images/testsmtp volumes: es-data01: diff --git a/stacks/sugar12/php80.yml b/stacks/sugar12/php80.yml index 99f59a170..2c824a588 100644 --- a/stacks/sugar12/php80.yml +++ b/stacks/sugar12/php80.yml @@ -3,7 +3,7 @@ version: '3' services: web1: container_name: "sugar-web1" - image: esimonetti/sugardockerized:php8.0-apache-1.51 + image: sugarcrmdevelopers/sugardockerized:php8.0-apache-latest ports: - "80:80" extra_hosts: @@ -13,6 +13,7 @@ services: - "APACHE_RUN_GROUP=sugar" volumes: - ../../data/app:/var/www/html + - ../../images/php/80/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -26,9 +27,10 @@ services: - testsmtp cron: container_name: "sugar-cron" - image: esimonetti/sugardockerized:php8.0-cron-1.51 + image: sugarcrmdevelopers/sugardockerized:php8.0-cron-latest volumes: - ../../data/app:/var/www/html + - ../../images/php/80/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -42,7 +44,7 @@ services: - testsmtp mysql: container_name: "sugar-mysql" - image: esimonetti/sugardockerized:mysql8.0-1.50 + image: sugarcrmdevelopers/sugardockerized:mysql8.0-latest ports: - "3306:3306" volumes: @@ -78,13 +80,12 @@ services: - ../../data/redis:/data permissions: container_name: "sugar-permissions" - image: esimonetti/sugardockerized:permissions-1.19 + image: sugarcrmdevelopers/sugardockerized:permissions-latest volumes: - ../../data/app:/var/www/html testsmtp: container_name: "sugar-smtp" - image: sugar_testsmtp - build: ../../images/testsmtp + image: sugarcrmdevelopers/sugardockerized:testsmtp-latest volumes: es-data01: diff --git a/tests/web_tests/8.0/composer.json b/tests/web_tests/8.0/composer.json new file mode 100644 index 000000000..b2a681338 --- /dev/null +++ b/tests/web_tests/8.0/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "guzzlehttp/guzzle": "6.5.6" + } +} diff --git a/tests/web_tests/8.0/test_1.php b/tests/web_tests/8.0/test_1.php new file mode 100644 index 000000000..3b5622980 --- /dev/null +++ b/tests/web_tests/8.0/test_1.php @@ -0,0 +1,2 @@ +connect('sugar-redis', 6379); +$redis->set($ok, $ok); + +if ($redis->get($ok) == $ok) { + echo $ok; +} diff --git a/tests/web_tests/8.0/test_4.php b/tests/web_tests/8.0/test_4.php new file mode 100644 index 000000000..9ac401e21 --- /dev/null +++ b/tests/web_tests/8.0/test_4.php @@ -0,0 +1,20 @@ +connect_error) { + die('Connection failed: ' . $conn->connect_error); +} + +$sql = 'CREATE DATABASE dockertest'; +if ($conn->query($sql) === TRUE) { + $conn->select_db('dockertest'); + $sql = 'CREATE TABLE test ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL )'; + if ($conn->query($sql) === TRUE) { + echo $ok; + } + $sql = 'DROP DATABASE dockertest'; + $conn->query($sql); +} + +$conn->close(); diff --git a/tests/web_tests/8.0/test_5.php b/tests/web_tests/8.0/test_5.php new file mode 100644 index 000000000..0a080b086 --- /dev/null +++ b/tests/web_tests/8.0/test_5.php @@ -0,0 +1,59 @@ + 4.0, + 'headers' => array( + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ) + ) +); + +$error = true; + +$response = $client->get($url . '_stats'); +if ($response->getStatusCode() == 200) { + + $response = $client->put($url . 'testbucket'); + if ($response->getStatusCode() == 200) { + $response = $client->put( + $url . 'testbucket/user/enrico?refresh=true', + array ( + //'debug' => TRUE, + 'json' => array( + 'name' => 'Enrico Simonetti' + ) + ) + ); + if ($response->getStatusCode() == 201) { + $response = $client->get( + $url . 'testbucket/user/_search', + array( + //'debug' => TRUE, + 'query' => array( + 'q' => 'simonetti' + ) + ) + ); + $decoded = json_decode($response->getBody(), true); + if (!empty($decoded['hits']) + && $decoded['hits']['total']['value'] === 1 + && $decoded['hits']['hits']['0']['_id'] === 'enrico') { + // expected result found + $error = false; + } + } + + $response = $client->delete($url . 'testbucket'); + } +} + +if (!$error) { + echo $ok; +} diff --git a/tests/web_tests/8.0/test_6.php b/tests/web_tests/8.0/test_6.php new file mode 100644 index 000000000..11dced1e9 --- /dev/null +++ b/tests/web_tests/8.0/test_6.php @@ -0,0 +1,3 @@ + Date: Tue, 5 Dec 2023 12:03:56 -0500 Subject: [PATCH 03/16] Implemented Cloud backup restore (#3) * Implemented Cloud backup restore * Added restorefromfile.sh to README --- README.md | 41 ++++++ utilities/build/simpleRepair.php | 29 +++++ .../configs/config_override_dockerized.php | 13 ++ utilities/restorefromfile.sh | 122 ++++++++++++++++++ 4 files changed, 205 insertions(+) create mode 100644 utilities/build/simpleRepair.php create mode 100644 utilities/configs/config_override_dockerized.php create mode 100755 utilities/restorefromfile.sh diff --git a/README.md b/README.md index d98b8161a..6649fd542 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,47 @@ System repaired It restores a previous snapshot of sugar files from `backups/backup_802_2018_11_21/sugar` and of MySQL from `backups/backup_802_2018_11_21/sugar.sql` The script assumes that the database name is sugar and the web directory is sugar as well. The script does not restore Elasticsearch and/or Redis. +#### restorefromfile.sh +```./utilities/restorefromfile.sh ~/Downloads/your-cloud-backup.sugarcrm.com.1320ent.1699996734.b76cf32986a8800255e21124a572dc4c151170c2.tar.gz``` +``` +Cleaning up previous install (./data/app/sugar) if any, please wait... +Decompressing /path-to-your-downloads-folder/Downloads/your-cloud-backup.sugarcrm.com.1320ent.1699996734.b76cf32986a8800255e21124a572dc4c151170c2.tar.gz, please wait... +Restoring application files +Application files restored +Restoring database +Database "sugar" dropped +mysql: [Warning] Using a password on the command line interface can be insecure. +mysql: [Warning] Using a password on the command line interface can be insecure. +Database restored +Dockerizing Backup config files... +Cleaning up please wait... +Fixing Sugar permissions, please wait... +Done +Restarting sugar-web1 container, please wait... +Done +Restarting sugar-cron container, please wait... +Done +Deleting all previous redis values +Done +Deleting all previous Elasticsearch indices, please wait... +Done +Repairing system +Preparing SystemUser... +Running QRR... +Rebuilding cache... +Warming up Services... +Done repairing... +System repaired +Performing Elasticsearch re-index +Scheduling reindex ... +Consuming queue ... please be patient +Consuming queue ... finish batch #1 +Reindexing complete +Restore completed! +``` +It restores a SugarCloud snapshot/backup that contains your full Sugar instance with files, custom folders as well as full database backup. +The script will [config_override.php](/utilities/configs/config_override_dockerized.php) settings to make your instance Docker ready. The script does not restore Elasticsearch and/or Redis. + #### jmeter/build.sh This script installs the jmeter components present on the [performance repository](https://github.com/sugarcrm/performance). Access to the repository is needed, if you are a Sugar Partner or Customer you can request access by mailing: developers@sugarcrm.com diff --git a/utilities/build/simpleRepair.php b/utilities/build/simpleRepair.php new file mode 100644 index 000000000..0bd5e6c28 --- /dev/null +++ b/utilities/build/simpleRepair.php @@ -0,0 +1,29 @@ +getSystemUser(); + +echo("Running QRR...\n"); +$repair = new \RepairAndClear(); +$repair->repairAndClearAll(['clearAll'], [$mod_strings['LBL_ALL_MODULES']], true, false, ''); + +echo("Rebuilding cache...\n"); +\SugarAutoLoader::buildCache(); + +echo("Warming up Services...\n"); +$sd = new \ServiceDictionary(); +$sd->buildAllDictionaries(); + +echo("Done repairing...\n"); diff --git a/utilities/configs/config_override_dockerized.php b/utilities/configs/config_override_dockerized.php new file mode 100644 index 000000000..26f9273bb --- /dev/null +++ b/utilities/configs/config_override_dockerized.php @@ -0,0 +1,13 @@ +$sugar_config['full_text_engine']['Elastic']['host'] = 'sugar-elasticsearch'; +$sugar_config['full_text_engine']['Elastic']['port'] = '9200'; +$sugar_config['dbconfig']['db_host_name'] = 'sugar-mysql'; +$sugar_config['dbconfig']['db_user_name'] = 'root'; +$sugar_config['dbconfig']['db_password'] = 'root'; +$sugar_config['dbconfig']['db_name'] = 'sugar'; +$sugar_config['dbconfig']['db_type'] = 'mysql'; +$sugar_config['dbconfig']['db_host_name'] = 'sugar-mysql'; +$sugar_config['external_cache']['redis']['host'] = 'sugar-redis'; +$sugar_config['external_cache_disabled'] = 'false'; +$sugar_config['external_cache_disabled_redis'] = 'false'; +$sugar_config['host_name'] = 'docker.local'; +$sugar_config['site_url'] = 'http://docker.local/sugar'; diff --git a/utilities/restorefromfile.sh b/utilities/restorefromfile.sh new file mode 100755 index 000000000..00d4b4102 --- /dev/null +++ b/utilities/restorefromfile.sh @@ -0,0 +1,122 @@ +#!/bin/bash + +# Rafael Fernandes +# sugarcrm.com + +if [ -z $1 ] +then + echo Provide the backup suffix as script parameters +else + # check if the stack is running + running=`docker ps | grep sugar-mysql | wc -l` + + if [ $running -gt 0 ] + then + # running + now="$(date)" + echo "Starting restore at $now" + + # enter the repo's root directory + REPO="$( dirname ${BASH_SOURCE[0]} )/../" + cd $REPO + + # locate the file + if [ ! -f $1 ] + then + echo $1 does not exist, please provide the tar.gz file path containing the backup to restore + exit 1 + fi + + # if it is our repo, and the source exists, and the destination does not + if [ -f '.gitignore' ] && [ -d 'data' ] + then + echo "Cleaning up previous install (./data/app/sugar) if any, please wait..." + if [ -d 'data/app/sugar' ] + then + rm -rf data/app/sugar + fi + TEMP_FOLDER=./data/app/tmp + if [ -d $TEMP_FOLDER ] + then + rm -rf $TEMP_FOLDER + fi + + mkdir -p "$TEMP_FOLDER/sql" + echo Decompressing $1, please wait... + tar -xf $1 -C $TEMP_FOLDER --strip-components=1 + for f in $TEMP_FOLDER/*.sql; do + mv "$f" "$TEMP_FOLDER/sql/" + done + for f in $TEMP_FOLDER/sugar*; do + mv "$f" $TEMP_FOLDER/sugar + done + + if [ ! -d $TEMP_FOLDER/sugar ] + then + echo \"$TEMP_FOLDER/sugar\" cannot be empty + exit 1 + fi + + if [ -d $TEMP_FOLDER/sql ] + then + find $TEMP_FOLDER/sql -type f -name 'sugar*' ! -name '*triggers*' -exec sh -c 'sql=${1:-:}; x="${2:-:}"; mv "$x" "$sql/sugar.sql"' bash "$TEMP_FOLDER/sql" {} +\; + find $TEMP_FOLDER/sql -type f -name '*triggers*' -exec sh -c 'sql=${1:-:}; x="{}"; mv "${2:-:}" "$sql/sugar_triggers.sql"' bash "$TEMP_FOLDER/sql" {} +\; + fi + + echo Restoring application files + SUGAR_TMP_DIR=`ls -d $TEMP_FOLDER/sugar*` + mv $SUGAR_TMP_DIR ./data/app/sugar + echo Application files restored + + echo Restoring database + docker exec -it sugar-mysql mysqladmin -h localhost -f -u root -proot drop sugar | grep -v "mysqladmin: \[Warning\]" + docker exec -it sugar-mysql mysqladmin -h localhost -u root -proot create sugar | grep -v "mysqladmin: \[Warning\]" + + if [ -f $TEMP_FOLDER/sql/sugar.sql.tgz ] + then + if hash tar 2>/dev/null; then + tar -zxf $TEMP_FOLDER/sql/sugar.sql.tgz + echo Database uncompressed to $TEMP_FOLDER/sql/sugar.sql + fi + fi + + if [ -f $TEMP_FOLDER/sql/sugar.sql ] + then + cat $TEMP_FOLDER/sql/sugar.sql | docker exec -i sugar-mysql mysql -h localhost -u root -proot sugar + if [ -f $TEMP_FOLDER/sql/sugar_triggers.sql ] + then + cat $TEMP_FOLDER/sql/sugar_triggers.sql | docker exec -i sugar-mysql mysql -h localhost -u root -proot sugar + fi + echo Database restored + else + echo Database not found! The selected restore is corrupted + exit 1 + fi + echo "Dockerizing Backup config files..." + sed -i.bak 's@RewriteBase /@RewriteBase /sugar@g' ./data/app/sugar/.htaccess + cat ./utilities/configs/config_override_dockerized.php >> ./data/app/sugar/config_override.php + + echo "Cleaning up please wait..." + if [ -d $TEMP_FOLDER ] + then + rm -rf $TEMP_FOLDER + fi + + # refresh all transient storages + ./utilities/build/refreshsystem.sh + + echo Repairing system + cp ./utilities/build/simpleRepair.php ./data/app/sugar + ./utilities/runcli.sh "php simpleRepair.php" + echo System repaired + + echo Performing Elasticsearch re-index + ./utilities/runcli.sh "./bin/sugarcrm search:silent_reindex --clearData" + echo Restore completed! + fi + now="$(date)" + echo "Restore finished at $now" + else + echo The stack is not running, please start the stack first + fi +fi From a49d51beb36b299e3f598c87fe3feb4b77a51169 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:38:17 -0500 Subject: [PATCH 04/16] Updated README with sugar-developers project (#4) * Update README.md * Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6649fd542..033cd5d4e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sugar Dockerized [![Build Status](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar13.yml/badge.svg)](https://github.com/esimonetti/SugarDockerized/actions/workflows/sugar13.yml) ![Docker Pulls](https://img.shields.io/docker/pulls/esimonetti/sugardockerized.svg) +# Sugar Dockerized [![Build Status](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml/badge.svg)](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml) This repository will help you deploy a Docker based **development only** full stack for Sugar, meeting all the platform requirements for a different set of platform combinations. @@ -46,24 +46,24 @@ There are multiple stack components as docker containers, that perform different ## SugarDockerized installation * The first step for everything to work smoothly, is to add on your computer's host file `/etc/hosts` the entry `docker.local` to point to your machine's ip (it might be `127.0.0.1` if running the stack locally, or the LAN static ip address of the VM running Docker. If using the Debian VirtualBox image provided at the bottom of this README, the ip address is `10.10.10.10`) -* Clone the repository with `git clone https://github.com/esimonetti/SugarDockerized.git sugardocker` and enter sugardocker with `cd sugardocker` +* Clone the repository with `git clone https://github.com/sugarcrm-developers/SugarDockerized.git sugardocker` and enter sugardocker with `cd sugardocker` * Choose the yml stack to run, within [stacks](stacks/) ## Starting and stopping the desired stack -Please leverage the utility script [stack.sh](https://github.com/esimonetti/SugarDockerized#stacksh) that will help with automation of the most common stacks. The utility will also notify you if a new version of SugarDockerized is available. +Please leverage the utility script [stack.sh](#stacksh) that will help with automation of the most common stacks. The utility will also notify you if a new version of SugarDockerized is available. ## Installation - How to get Sugar installed -For details about the hostnames and credentials of each of the infrastructure components, refer to [Sugar Setup details](https://github.com/esimonetti/SugarDockerized#sugar-setup-details). +For details about the hostnames and credentials of each of the infrastructure components, refer to [Sugar Setup details](#sugar-setup-details). ### Sugar installation via installable zip file * The first step is to copy (cp/scp/rsync/filezilla etc) the compressed installable zip file into a known path within the Linux host running SugarDockerized -* Run the utility `installfromzip.sh`. Read more about [installfromzip.sh](https://github.com/esimonetti/SugarDockerized#installfromzipsh) +* Run the utility `installfromzip.sh`. Read more about [installfromzip.sh](#installfromzipsh) ### Sugar installation building from git source * To be able to proceed further, you would need read permission access to Sugar's official git source control repository * Clone the full git repository within your `./data/app/` directory so that the repository is located in `./data/app/Mango/` * Switch to the correct branch -* Run the utility `build/build.sh`. Read more about [build/build.sh](https://github.com/esimonetti/SugarDockerized#buildbuildsh) +* Run the utility `build/build.sh`. Read more about [build/build.sh](#buildbuildsh) ## Current version support The main stacks work with [Sugar version 13.0 and all its platform requirements](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_13.0.x_Supported_Platforms/). Additional stacks are aligned with the platform requirements of version [12.x](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_12.0.x_Supported_Platforms/), [11.x](https://support.sugarcrm.com/Resources/Supported_Platforms/Sugar_11.0.x_Supported_Platforms/) and stacks for Sugar Cloud only versions for local development only. @@ -352,7 +352,7 @@ If the installable zip package is located within the local directory `~/installa ```./utilities/installfromzip.sh ~/installable/SugarEnt-13.0.0.zip``` The script will perform all the steps required to silently install the software within the SugarDockerized stack currently running. -To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](https://github.com/esimonetti/SugarDockerized#buildsilentinstallsh). +To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](#buildsilentinstallsh). #### build/build.sh This script is most likely for Sugar Employees only. @@ -361,7 +361,7 @@ If we want to build the application version 10.0.0 Enterprise, the build command ```./utilities/build/build.sh ent 13.0.0``` The script will perform all the steps necessary to build the current branch of the software and also perform its silent installation. -To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](https://github.com/esimonetti/SugarDockerized#buildsilentinstallsh). +To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](#buildsilentinstallsh). #### build/silentinstall.sh The script is leveraged by both `installfromzip.sh` and `build/build.sh` to install silently Sugar on the current stack. From 73c21b945de352dc4fec28d50c3d31b30128a08c Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:17:33 -0500 Subject: [PATCH 05/16] Added Github Actions badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 033cd5d4e..25353eb73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sugar Dockerized [![Build Status](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml/badge.svg)](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml) +# Sugar Dockerized [![Build Status](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar12.yml/badge.svg)](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar12.yml) [![Build Status](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml/badge.svg)](https://github.com/sugarcrm-developers/SugarDockerized/actions/workflows/sugar13.yml) This repository will help you deploy a Docker based **development only** full stack for Sugar, meeting all the platform requirements for a different set of platform combinations. From 428ce4886174b5d9bb3361f5649a69470448c763 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:18:08 -0500 Subject: [PATCH 06/16] Fixed Xdebug 3 and added php.ini config (#5) * Implemented Cloud backup restore * Added restorefromfile.sh to README * Fixed Xdebug 3 and added php.ini config --- README.md | 8 +++++--- images/php/80/apache/config/php/docker.ini | 5 ++++- .../php/80/apache/config/php/mods-available/xdebug.ini | 9 +++------ images/php/82/apache/config/php/docker.ini | 5 ++++- .../php/82/apache/config/php/mods-available/xdebug.ini | 9 +++------ utilities/xdebug.sh | 6 +++--- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 25353eb73..7f5481875 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ Apache web servers have enabled: Apache web servers have PHP with enabled: * Zend OPcache - Configured for Sugar with the assumption the files will be located within the correct path * XHProf and Tideways profilers -* Xdebug is installed but it is not enabled by default (due to its performance impact). For PHP 5.6 images and all cron images if there is the need to enable it, you would have to uncomment the configuration option on the PHP Dockerfile of choice, and leverage the stack configuration with local build. For other case see [`xdebug.sh`](#xdebugsh). +* `Xdebug` is installed but it is not enabled by default (due to its performance impact). For PHP 5.6 images and all cron images if there is the need to enable it, you would have to uncomment the configuration option on the PHP Dockerfile of choice, and leverage the stack configuration with local build. For other case see [`xdebug.sh`](#xdebugsh). + * Remember, `Xdebug` will connect from the Container to your Host not the other way around. In summary, we instructed Xdebug to start with a request and try to send the debug events to the host with the IP `host.docker.internal` on port `9003`. * If you use an IDE such as PHPStorm, you can setup DBGp Proxy under the menus Preference -> Language & Framework -> PHP -> Debug -> DBGp Proxy. Example settings are available in the screenshot below: PHPStorm xdebug settings @@ -213,11 +214,12 @@ Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies ``` Due to performance impact, Xdebug is disabled by default. This script prompts you to activate Xdebug, check if Xdebug is activated, or disable it. -If you do not want to configure DBGp Proxy when running the script, you can specify the second argument `change-ip`. In this case, the script will change the `xdebug.remote_host` option to your local IP address. +If you do not want to configure DBGp Proxy when running the script, you can specify the second argument `change-ip`. In this case, the script will change the `xdebug.client_host` option to your local IP address. +By default, we are setting `host.docker.internal` which should resolve to Docker's internal IP address used by the host. ``` ./utilities/xdebug.sh start change-ip Start xDebug -New IP of remote_host: 192.168.0.105 +New IP of client_host: 192.168.0.105 6c9a9862b60c PHP 7.1.33 (cli) (built: Nov 22 2019 18:28:25) ( NTS ) Copyright (c) 1997-2018 The PHP Group diff --git a/images/php/80/apache/config/php/docker.ini b/images/php/80/apache/config/php/docker.ini index 4280b2847..3c7421d39 100644 --- a/images/php/80/apache/config/php/docker.ini +++ b/images/php/80/apache/config/php/docker.ini @@ -16,4 +16,7 @@ session.cookie_httponly = 1 session.use_trans_sid = 0 session.save_handler = redis session.save_path = "tcp://sugar-redis:6379" -auto_prepend_file = "/usr/local/php/prepend.php" \ No newline at end of file +short_open_tag = Off +enable_dl = Off +allow_url_fopen = On +allow_url_include = Off diff --git a/images/php/80/apache/config/php/mods-available/xdebug.ini b/images/php/80/apache/config/php/mods-available/xdebug.ini index a1c102c2d..03228693e 100644 --- a/images/php/80/apache/config/php/mods-available/xdebug.ini +++ b/images/php/80/apache/config/php/mods-available/xdebug.ini @@ -3,11 +3,8 @@ xdebug.max_nesting_level=500 xdebug.profiler_enable=0 ; enable remote debug -; Below are xdebug2 options. Use default xdebug3 -;xdebug.remote_enable=1 -;xdebug.remote_port=9000 -;xdebug.remote_host=10.10.10.1 -;xdebug.remote_autostart = 1 -xdebug.client_host=10.10.10.1 +xdebug.client_host=host.docker.internal xdebug.client_port=9003 xdebug.idekey=XDEBUG_SESSION +xdebug.start_with_request=yes +xdebug.mode=debug \ No newline at end of file diff --git a/images/php/82/apache/config/php/docker.ini b/images/php/82/apache/config/php/docker.ini index 4280b2847..3c7421d39 100644 --- a/images/php/82/apache/config/php/docker.ini +++ b/images/php/82/apache/config/php/docker.ini @@ -16,4 +16,7 @@ session.cookie_httponly = 1 session.use_trans_sid = 0 session.save_handler = redis session.save_path = "tcp://sugar-redis:6379" -auto_prepend_file = "/usr/local/php/prepend.php" \ No newline at end of file +short_open_tag = Off +enable_dl = Off +allow_url_fopen = On +allow_url_include = Off diff --git a/images/php/82/apache/config/php/mods-available/xdebug.ini b/images/php/82/apache/config/php/mods-available/xdebug.ini index a1c102c2d..03228693e 100644 --- a/images/php/82/apache/config/php/mods-available/xdebug.ini +++ b/images/php/82/apache/config/php/mods-available/xdebug.ini @@ -3,11 +3,8 @@ xdebug.max_nesting_level=500 xdebug.profiler_enable=0 ; enable remote debug -; Below are xdebug2 options. Use default xdebug3 -;xdebug.remote_enable=1 -;xdebug.remote_port=9000 -;xdebug.remote_host=10.10.10.1 -;xdebug.remote_autostart = 1 -xdebug.client_host=10.10.10.1 +xdebug.client_host=host.docker.internal xdebug.client_port=9003 xdebug.idekey=XDEBUG_SESSION +xdebug.start_with_request=yes +xdebug.mode=debug \ No newline at end of file diff --git a/utilities/xdebug.sh b/utilities/xdebug.sh index 44d431a31..0d4dffebd 100755 --- a/utilities/xdebug.sh +++ b/utilities/xdebug.sh @@ -32,11 +32,11 @@ xdebug_start () if [[ "$1" == "change-ip" ]]; then # Grab IP address of eth0 IP=$(getMyIP) - # Change IP address for parameter xdebug.remote_host - IP_CMD="sed -i 's/^xdebug.remote_host=.*/xdebug.remote_host=$IP/g' \ + # Change IP address for parameter xdebug.client_host + IP_CMD="sed -i 's/^xdebug.client_host=.*/xdebug.client_host=$IP/g' \ /usr/local/etc/php/conf.d/xdebug.ini" docker exec -it $PHP_CONTAINER bash -c "${IP_CMD}" - echo "New IP of remote_host: $IP" + echo "New IP of client_host: $IP" fi docker restart $PHP_CONTAINER From a6a37ba5c44eed8caf7f6fa41fc3dc8afd6562f9 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:39:38 -0500 Subject: [PATCH 07/16] Removed unnecessary test cases (#6) * Delete tests/web_tests/8.0/test_6.php * Delete tests/web_tests/8.2/test_6.php --- tests/web_tests/8.0/test_6.php | 3 --- tests/web_tests/8.2/test_6.php | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 tests/web_tests/8.0/test_6.php delete mode 100644 tests/web_tests/8.2/test_6.php diff --git a/tests/web_tests/8.0/test_6.php b/tests/web_tests/8.0/test_6.php deleted file mode 100644 index 11dced1e9..000000000 --- a/tests/web_tests/8.0/test_6.php +++ /dev/null @@ -1,3 +0,0 @@ - Date: Fri, 15 Dec 2023 11:53:58 -0500 Subject: [PATCH 08/16] Decrease counter to remove webtest (#7) --- tests/web_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/web_tests.sh b/tests/web_tests.sh index d0df8d273..fd600f1ff 100755 --- a/tests/web_tests.sh +++ b/tests/web_tests.sh @@ -51,7 +51,7 @@ else echo Executing CLI and web tests - for i in {1..6} + for i in {1..5} do OUTPUT_CLI=`./utilities/runcli.sh "php ./web_tests/$3/test_$i.php | grep ok | wc -l"` if [ $OUTPUT_CLI != '1' ] From 78ec790525cde765f5b48028da9dcdb459c9fc4d Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:55:58 -0400 Subject: [PATCH 09/16] Removed buildfromsource instructions not relevant from non-sugar employees --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 7f5481875..195ec77c0 100644 --- a/README.md +++ b/README.md @@ -356,15 +356,6 @@ If the installable zip package is located within the local directory `~/installa The script will perform all the steps required to silently install the software within the SugarDockerized stack currently running. To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](#buildsilentinstallsh). -#### build/build.sh -This script is most likely for Sugar Employees only. -The script requires a clone of Sugar's git repository within `./data/app/Mango` with the `index.php` located within `./data/app/Mango/sugarcrm/index.php`. -If we want to build the application version 10.0.0 Enterprise, the build command would be: -```./utilities/build/build.sh ent 13.0.0``` - -The script will perform all the steps necessary to build the current branch of the software and also perform its silent installation. -To know more about additional custom configuration parameters and actions that can be used/performed during the silent installation refer to [script build/silentinstall.sh](#buildsilentinstallsh). - #### build/silentinstall.sh The script is leveraged by both `installfromzip.sh` and `build/build.sh` to install silently Sugar on the current stack. This script allows a certain degree of flexibility by allowing the following customisations: From 4b26380cb2450d27484708d641c7c62fe9daf852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devesa=20Agust=C3=ADn?= Date: Mon, 15 Apr 2024 11:08:37 -0300 Subject: [PATCH 10/16] Update installfromzip.sh (#8) Add the instruction that warns if "unzip" is not settled. This will prevent future errors that happen to me. --- utilities/installfromzip.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utilities/installfromzip.sh b/utilities/installfromzip.sh index 0e1b0d431..72285781d 100755 --- a/utilities/installfromzip.sh +++ b/utilities/installfromzip.sh @@ -2,6 +2,11 @@ # Enrico Simonetti # enricosimonetti.com +if [ ! -x "$(command -v unzip)" ] +then + echo "The command unzip is not available, please install it" + exit 1 +fi if [ -z $1 ] then From 31a40cd1d46edbd6b25f2bed845af0a26f34949f Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:46:56 -0400 Subject: [PATCH 11/16] Update config_override_dockerized.php (#9) --- utilities/configs/config_override_dockerized.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utilities/configs/config_override_dockerized.php b/utilities/configs/config_override_dockerized.php index 26f9273bb..09bfef989 100644 --- a/utilities/configs/config_override_dockerized.php +++ b/utilities/configs/config_override_dockerized.php @@ -1,11 +1,13 @@ $sugar_config['full_text_engine']['Elastic']['host'] = 'sugar-elasticsearch'; $sugar_config['full_text_engine']['Elastic']['port'] = '9200'; +$sugar_config['full_text_engine']['Elastic']['curl'] = array(); $sugar_config['dbconfig']['db_host_name'] = 'sugar-mysql'; $sugar_config['dbconfig']['db_user_name'] = 'root'; $sugar_config['dbconfig']['db_password'] = 'root'; $sugar_config['dbconfig']['db_name'] = 'sugar'; $sugar_config['dbconfig']['db_type'] = 'mysql'; $sugar_config['dbconfig']['db_host_name'] = 'sugar-mysql'; +$sugar_config['db_manager'] = 'MysqliManager'; $sugar_config['external_cache']['redis']['host'] = 'sugar-redis'; $sugar_config['external_cache_disabled'] = 'false'; $sugar_config['external_cache_disabled_redis'] = 'false'; From 804f2efe363d9fdfce4cf9b696a505f5022d2f18 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:22:50 -0400 Subject: [PATCH 12/16] Fix for legacy db manager on config.php causing 500 errors (#10) * Implemented Cloud backup restore * Added restorefromfile.sh to README * Fixed Xdebug 3 and added php.ini config * Removing not valid test cases * Update simpleRepair.php --- utilities/build/simpleRepair.php | 2 +- utilities/configs/config_override_dockerized.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/utilities/build/simpleRepair.php b/utilities/build/simpleRepair.php index 0bd5e6c28..36a5e8f59 100644 --- a/utilities/build/simpleRepair.php +++ b/utilities/build/simpleRepair.php @@ -17,7 +17,7 @@ echo("Running QRR...\n"); $repair = new \RepairAndClear(); -$repair->repairAndClearAll(['clearAll'], [$mod_strings['LBL_ALL_MODULES']], true, false, ''); +$repair->repairAndClearAll(['clearAll'], [$mod_strings['LBL_ALL_MODULES']], false, false, ''); echo("Rebuilding cache...\n"); \SugarAutoLoader::buildCache(); diff --git a/utilities/configs/config_override_dockerized.php b/utilities/configs/config_override_dockerized.php index 09bfef989..518e46728 100644 --- a/utilities/configs/config_override_dockerized.php +++ b/utilities/configs/config_override_dockerized.php @@ -8,6 +8,7 @@ $sugar_config['dbconfig']['db_type'] = 'mysql'; $sugar_config['dbconfig']['db_host_name'] = 'sugar-mysql'; $sugar_config['db_manager'] = 'MysqliManager'; +$sugar_config['db'] = array(); $sugar_config['external_cache']['redis']['host'] = 'sugar-redis'; $sugar_config['external_cache_disabled'] = 'false'; $sugar_config['external_cache_disabled_redis'] = 'false'; From 4f70fb7ee362a099729250f44be5c35a181607e2 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Tue, 21 May 2024 11:14:22 -0400 Subject: [PATCH 13/16] Sugar 14.0 Stack (#11) * Sugar 14.0 Stack --- .github/workflows/sugar14.yml | 71 ++++++++++++++ data/app/sugar/.gitkeep | 1 + images/mysql/830/Dockerfile | 4 + images/mysql/830/config/mysql/docker.cnf | 13 +++ images/permissions/Dockerfile | 2 +- images/php/83/apache/Dockerfile | 78 +++++++++++++++ .../apache2/mods-available/deflate.conf | 1 + .../config/apache2/sites-available/sugar.conf | 14 +++ images/php/83/apache/config/php/docker.ini | 22 +++++ .../config/php/mods-available/opcache.ini | 30 ++++++ .../config/php/mods-available/redis.ini | 1 + .../config/php/mods-available/tideways.ini | 2 + .../config/php/mods-available/xdebug.ini | 10 ++ .../config/php/mods-available/xhprof.ini | 2 + .../83/apache/config/php/opcache-blacklist | 7 ++ images/php/83/cron/Dockerfile | 78 +++++++++++++++ images/php/83/cron/apps/sugarcron | 25 +++++ images/php/83/cron/config/php/docker.ini | 11 +++ .../config/php/mods-available/opcache.ini | 30 ++++++ .../cron/config/php/mods-available/redis.ini | 1 + .../config/php/mods-available/tideways.ini | 2 + .../cron/config/php/mods-available/xdebug.ini | 10 ++ .../cron/config/php/mods-available/xhprof.ini | 2 + .../php/83/cron/config/php/opcache-blacklist | 7 ++ stacks/sugar14/README.md | 10 ++ stacks/sugar14/php83-local-build.yml | 94 +++++++++++++++++++ stacks/sugar14/php83.yml | 93 ++++++++++++++++++ tests/web_tests/8.3/composer.json | 5 + tests/web_tests/8.3/test_1.php | 2 + tests/web_tests/8.3/test_2.php | 9 ++ tests/web_tests/8.3/test_3.php | 10 ++ tests/web_tests/8.3/test_4.php | 20 ++++ tests/web_tests/8.3/test_5.php | 59 ++++++++++++ .../configs/config_override_dockerized.php | 5 +- utilities/stack.sh | 2 +- utilities/stacks.conf | 2 + utilities/sugardockerized/checkversion.sh | 3 +- utilities/sugardockerized/install.sh | 2 +- utilities/sugardockerized/selfupgrade.sh | 2 +- version | 2 +- 40 files changed, 735 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/sugar14.yml create mode 100755 images/mysql/830/Dockerfile create mode 100644 images/mysql/830/config/mysql/docker.cnf create mode 100644 images/php/83/apache/Dockerfile create mode 100644 images/php/83/apache/config/apache2/mods-available/deflate.conf create mode 100644 images/php/83/apache/config/apache2/sites-available/sugar.conf create mode 100644 images/php/83/apache/config/php/docker.ini create mode 100644 images/php/83/apache/config/php/mods-available/opcache.ini create mode 100644 images/php/83/apache/config/php/mods-available/redis.ini create mode 100644 images/php/83/apache/config/php/mods-available/tideways.ini create mode 100644 images/php/83/apache/config/php/mods-available/xdebug.ini create mode 100644 images/php/83/apache/config/php/mods-available/xhprof.ini create mode 100644 images/php/83/apache/config/php/opcache-blacklist create mode 100644 images/php/83/cron/Dockerfile create mode 100644 images/php/83/cron/apps/sugarcron create mode 100644 images/php/83/cron/config/php/docker.ini create mode 100644 images/php/83/cron/config/php/mods-available/opcache.ini create mode 100644 images/php/83/cron/config/php/mods-available/redis.ini create mode 100644 images/php/83/cron/config/php/mods-available/tideways.ini create mode 100644 images/php/83/cron/config/php/mods-available/xdebug.ini create mode 100644 images/php/83/cron/config/php/mods-available/xhprof.ini create mode 100644 images/php/83/cron/config/php/opcache-blacklist create mode 100644 stacks/sugar14/README.md create mode 100644 stacks/sugar14/php83-local-build.yml create mode 100644 stacks/sugar14/php83.yml create mode 100644 tests/web_tests/8.3/composer.json create mode 100644 tests/web_tests/8.3/test_1.php create mode 100644 tests/web_tests/8.3/test_2.php create mode 100644 tests/web_tests/8.3/test_3.php create mode 100644 tests/web_tests/8.3/test_4.php create mode 100644 tests/web_tests/8.3/test_5.php diff --git a/.github/workflows/sugar14.yml b/.github/workflows/sugar14.yml new file mode 100644 index 000000000..7526beaba --- /dev/null +++ b/.github/workflows/sugar14.yml @@ -0,0 +1,71 @@ +name: ci-v14 +on: + push: + tags: + - 'v*' +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + run: ['stacks/sugar14/php83-local-build.yml'] + steps: + - run: sudo sysctl -w vm.max_map_count=262144 + - run: echo '127.0.0.1 docker.local' | sudo tee -a /etc/hosts + - uses: actions/checkout@v1 + - run: cp -r ./tests/web_tests ./data/app/sugar/ + - run: ./tests/start.sh ${{ matrix.run }} + - run: ./tests/web_tests.sh ${{ matrix.run }} 14.0 8.3 + - run: ./tests/stop.sh ${{ matrix.run }} + + docker: + strategy: + fail-fast: false + matrix: + include: + - dockercontext: ./images/php/83/apache + image: sugarcrmdevelopers/sugardockerized + prefix: php8.3-apache- + - dockercontext: ./images/php/83/cron + image: sugarcrmdevelopers/sugardockerized + prefix: php8.3-cron- + - dockercontext: ./images/mysql/830 + image: sugarcrmdevelopers/sugardockerized + prefix: mysql8.3.0- + - dockercontext: ./images/permissions + image: sugarcrmdevelopers/sugardockerized + prefix: permissions- + - dockercontext: ./images/testsmtp + image: sugarcrmdevelopers/sugardockerized + prefix: testsmtp- + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ matrix.image }} + flavor: | + latest=true + prefix=${{ matrix.prefix }},onlatest=true + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: ${{ matrix.dockercontext }} + push: true + platforms: 'linux/amd64,linux/arm64' + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/data/app/sugar/.gitkeep b/data/app/sugar/.gitkeep index e69de29bb..8b1378917 100644 --- a/data/app/sugar/.gitkeep +++ b/data/app/sugar/.gitkeep @@ -0,0 +1 @@ + diff --git a/images/mysql/830/Dockerfile b/images/mysql/830/Dockerfile new file mode 100755 index 000000000..bf4928e95 --- /dev/null +++ b/images/mysql/830/Dockerfile @@ -0,0 +1,4 @@ +FROM mysql:8.3.0 +MAINTAINER developers@sugarcrm.com + +COPY config/mysql/docker.cnf /etc/mysql/conf.d/docker.cnf diff --git a/images/mysql/830/config/mysql/docker.cnf b/images/mysql/830/config/mysql/docker.cnf new file mode 100644 index 000000000..d954b355b --- /dev/null +++ b/images/mysql/830/config/mysql/docker.cnf @@ -0,0 +1,13 @@ +[mysqld] +host-cache-size=0 +skip-name-resolve +default-storage-engine=InnoDB +innodb_file_per_table +innodb_buffer_pool_size=256M +character-set-server=utf8mb4 +collation-server=utf8mb4_general_ci +optimizer-switch=block_nested_loop=off +sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" + +[mysqldump] +max-allowed-packet=128M diff --git a/images/permissions/Dockerfile b/images/permissions/Dockerfile index 6f2062dd6..197f54fee 100755 --- a/images/permissions/Dockerfile +++ b/images/permissions/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:8.8 +FROM debian:stable-slim MAINTAINER enrico.simonetti@gmail.com RUN adduser sugar --disabled-password --disabled-login --gecos "" diff --git a/images/php/83/apache/Dockerfile b/images/php/83/apache/Dockerfile new file mode 100644 index 000000000..163520fca --- /dev/null +++ b/images/php/83/apache/Dockerfile @@ -0,0 +1,78 @@ +FROM php:8.3.6-apache + +RUN apt-get update \ + && apt-get install -y \ + graphviz \ + libpng-dev \ + libgmp-dev \ + libzip-dev \ + libc-client-dev \ + libkrb5-dev \ + libldap2-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libxml2-dev \ + git \ + --no-install-recommends + +RUN apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +RUN adduser sugar --disabled-password --disabled-login --gecos "" + +RUN echo " /usr/local/php/prepend.php + +COPY config/apache2/mods-available/deflate.conf /etc/apache2/mods-available/deflate.conf +COPY config/apache2/sites-available/sugar.conf /etc/apache2/sites-available/sugar.conf + +RUN set -ex \ + && . "/etc/apache2/envvars" \ + && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" \ + && a2enmod headers expires deflate rewrite \ + && sed -i "s#Timeout .*#Timeout 600#" /etc/apache2/apache2.conf \ + && a2dissite 000-default \ + && a2ensite sugar + +RUN docker-php-ext-install mysqli \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install gd \ + && docker-php-ext-install gmp \ + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && docker-php-ext-install imap \ + && docker-php-ext-install zip \ + && docker-php-ext-install ldap \ + && pecl install xdebug-3.3.0 \ + && pecl install redis \ + && docker-php-ext-enable redis \ + && docker-php-ext-install soap + +RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ +&& docker-php-ext-install -j$(nproc) gd + +# enabled by default, it can be disabled locally +COPY config/php/mods-available/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini +COPY config/php/mods-available/opcache.ini /usr/local/etc/php/conf.d/opcache.ini +COPY config/php/opcache-blacklist /usr/local/etc/php/opcache-blacklist + +RUN git clone https://github.com/tideways/php-xhprof-extension.git tideways \ + && cd tideways \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/tideways.ini /usr/local/etc/php/conf.d/tideways.ini + +RUN git clone https://github.com/longxinH/xhprof.git xhprof \ + && cd xhprof/extension/ \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/xhprof.ini /usr/local/etc/php/conf.d/xhprof.ini + +WORKDIR "/var/www/html/sugar" diff --git a/images/php/83/apache/config/apache2/mods-available/deflate.conf b/images/php/83/apache/config/apache2/mods-available/deflate.conf new file mode 100644 index 000000000..7bb892d3e --- /dev/null +++ b/images/php/83/apache/config/apache2/mods-available/deflate.conf @@ -0,0 +1 @@ +AddOutputFilterByType DEFLATE application/json application/javascript text/css diff --git a/images/php/83/apache/config/apache2/sites-available/sugar.conf b/images/php/83/apache/config/apache2/sites-available/sugar.conf new file mode 100644 index 000000000..6411ef409 --- /dev/null +++ b/images/php/83/apache/config/apache2/sites-available/sugar.conf @@ -0,0 +1,14 @@ + + ServerAdmin webmaster@localhost + ServerName localhost + + DocumentRoot /var/www/html + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + + Options Indexes FollowSymLinks + AllowOverride All + + diff --git a/images/php/83/apache/config/php/docker.ini b/images/php/83/apache/config/php/docker.ini new file mode 100644 index 000000000..3c7421d39 --- /dev/null +++ b/images/php/83/apache/config/php/docker.ini @@ -0,0 +1,22 @@ +date.timezone = GMT +error_reporting = E_ALL \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED +error_log = /var/log/apache2/error.log +log_errors = On +display_errors = Off +memory_limit = 1024M +post_max_size = 100M +upload_max_filesize = 100M +max_execution_time = 600 +max_input_time = 600 +realpath_cache_size = 512k +realpath_cache_ttl = 600 +mbstring.func_overload = 0 +session.use_cookies = 1 +session.cookie_httponly = 1 +session.use_trans_sid = 0 +session.save_handler = redis +session.save_path = "tcp://sugar-redis:6379" +short_open_tag = Off +enable_dl = Off +allow_url_fopen = On +allow_url_include = Off diff --git a/images/php/83/apache/config/php/mods-available/opcache.ini b/images/php/83/apache/config/php/mods-available/opcache.ini new file mode 100644 index 000000000..b0e4ac566 --- /dev/null +++ b/images/php/83/apache/config/php/mods-available/opcache.ini @@ -0,0 +1,30 @@ +; configuration for php ZendOpcache module +; priority=10 +zend_extension=opcache.so +opcache.blacklist_filename="/usr/local/etc/php/opcache-blacklist" +opcache.consistency_checks=0 +opcache.dups_fix=0 +opcache.enable=1 +opcache.enable_cli=0 +opcache.enable_file_override=0 +opcache.error_log="" +opcache.fast_shutdown=1 +opcache.file_update_protection=2 +opcache.force_restart_timeout=180 +opcache.inherited_hack=1 +opcache.interned_strings_buffer=8 +opcache.load_comments=1 +opcache.log_verbosity_level=1 +opcache.max_accelerated_files=4000 +opcache.max_file_size=0 +opcache.max_wasted_percentage=5 +opcache.memory_consumption=256 +opcache.optimization_level=0x7FFFBFFF +opcache.preferred_memory_model="" +opcache.protect_memory=0 +opcache.restrict_api="" +opcache.revalidate_freq=2 +opcache.revalidate_path=0 +opcache.save_comments=1 +opcache.use_cwd=1 +opcache.validate_timestamps=1 diff --git a/images/php/83/apache/config/php/mods-available/redis.ini b/images/php/83/apache/config/php/mods-available/redis.ini new file mode 100644 index 000000000..6aecae489 --- /dev/null +++ b/images/php/83/apache/config/php/mods-available/redis.ini @@ -0,0 +1 @@ +extension=redis.so diff --git a/images/php/83/apache/config/php/mods-available/tideways.ini b/images/php/83/apache/config/php/mods-available/tideways.ini new file mode 100644 index 000000000..de7c8f9f0 --- /dev/null +++ b/images/php/83/apache/config/php/mods-available/tideways.ini @@ -0,0 +1,2 @@ +extension=tideways_xhprof.so +tideways_xhprof.auto_prepend_library=0 diff --git a/images/php/83/apache/config/php/mods-available/xdebug.ini b/images/php/83/apache/config/php/mods-available/xdebug.ini new file mode 100644 index 000000000..03228693e --- /dev/null +++ b/images/php/83/apache/config/php/mods-available/xdebug.ini @@ -0,0 +1,10 @@ +;zend_extension=xdebug.so +xdebug.max_nesting_level=500 +xdebug.profiler_enable=0 + +; enable remote debug +xdebug.client_host=host.docker.internal +xdebug.client_port=9003 +xdebug.idekey=XDEBUG_SESSION +xdebug.start_with_request=yes +xdebug.mode=debug \ No newline at end of file diff --git a/images/php/83/apache/config/php/mods-available/xhprof.ini b/images/php/83/apache/config/php/mods-available/xhprof.ini new file mode 100644 index 000000000..dd7fd32c6 --- /dev/null +++ b/images/php/83/apache/config/php/mods-available/xhprof.ini @@ -0,0 +1,2 @@ +extension = xhprof.so +xhprof.output_dir = /tmp/xhprof diff --git a/images/php/83/apache/config/php/opcache-blacklist b/images/php/83/apache/config/php/opcache-blacklist new file mode 100644 index 000000000..5edb9d104 --- /dev/null +++ b/images/php/83/apache/config/php/opcache-blacklist @@ -0,0 +1,7 @@ +/var/www/html/sugar/config_override.php +/var/www/html/sugar/cache/modules/Teams/TeamSetCache.php +/var/www/html/sugar/cache/modules/Teams/TeamSetMD5Cache.php +/var/www/html/sugar/cache/class_map.php +/var/www/html/sugar/cache/smarty/templates_c/* +/var/www/html/sugar/custom/modules/unified_search_modules_display.php +/var/www/html/sugar/custom/modulebuilder/* diff --git a/images/php/83/cron/Dockerfile b/images/php/83/cron/Dockerfile new file mode 100644 index 000000000..91928df94 --- /dev/null +++ b/images/php/83/cron/Dockerfile @@ -0,0 +1,78 @@ +FROM php:8.3.6-cli + +RUN apt-get update \ + && apt-get install -y \ + sudo \ + vim \ + unzip \ + libpng-dev \ + libgmp-dev \ + libzip-dev \ + libc-client-dev \ + libkrb5-dev \ + libldap2-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libxml2-dev \ + git \ + --no-install-recommends + +RUN apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +RUN adduser sugar --disabled-password --disabled-login --gecos "" \ + && echo "sugar ALL=NOPASSWD: ALL" > /etc/sudoers.d/sugar + +RUN echo " /usr/local/php/prepend.php + +RUN docker-php-ext-install mysqli \ + && docker-php-ext-install bcmath \ + && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \ + && docker-php-ext-install gd \ + && docker-php-ext-install gmp \ + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && docker-php-ext-install imap \ + && docker-php-ext-install zip \ + && docker-php-ext-install ldap \ + && docker-php-ext-install ldap \ + && pecl install xdebug-3.3.0 \ + && pecl install redis \ + && docker-php-ext-enable redis \ + && docker-php-ext-install soap + +RUN docker-php-ext-install -j$(nproc) gd + +# disable by default, it can be enabled locally +#COPY config/php/mods-available/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini +COPY config/php/mods-available/opcache.ini /usr/local/etc/php/conf.d/opcache.ini +COPY config/php/opcache-blacklist /usr/local/etc/php/opcache-blacklist + +RUN git clone https://github.com/tideways/php-xhprof-extension.git tideways \ + && cd tideways \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/tideways.ini /usr/local/etc/php/conf.d/tideways.ini + +RUN git clone https://github.com/longxinH/xhprof.git xhprof \ + && cd xhprof/extension/ \ + && /usr/local/bin/phpize \ + && ./configure --with-php-config=/usr/local/bin/php-config \ + && make \ + && make install + +COPY config/php/mods-available/xhprof.ini /usr/local/etc/php/conf.d/xhprof.ini + +RUN curl -sS http://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer + +COPY apps/sugarcron /usr/local/bin/sugarcron +RUN chmod +x /usr/local/bin/sugarcron + +WORKDIR "/var/www/html/sugar" +USER sugar + +CMD ["/usr/local/bin/sugarcron"] diff --git a/images/php/83/cron/apps/sugarcron b/images/php/83/cron/apps/sugarcron new file mode 100644 index 000000000..ce24473ac --- /dev/null +++ b/images/php/83/cron/apps/sugarcron @@ -0,0 +1,25 @@ +#!/usr/local/bin/php +connect('sugar-redis', 6379); +$redis->set($ok, $ok); + +if ($redis->get($ok) == $ok) { + echo $ok; +} diff --git a/tests/web_tests/8.3/test_4.php b/tests/web_tests/8.3/test_4.php new file mode 100644 index 000000000..9ac401e21 --- /dev/null +++ b/tests/web_tests/8.3/test_4.php @@ -0,0 +1,20 @@ +connect_error) { + die('Connection failed: ' . $conn->connect_error); +} + +$sql = 'CREATE DATABASE dockertest'; +if ($conn->query($sql) === TRUE) { + $conn->select_db('dockertest'); + $sql = 'CREATE TABLE test ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL )'; + if ($conn->query($sql) === TRUE) { + echo $ok; + } + $sql = 'DROP DATABASE dockertest'; + $conn->query($sql); +} + +$conn->close(); diff --git a/tests/web_tests/8.3/test_5.php b/tests/web_tests/8.3/test_5.php new file mode 100644 index 000000000..7f73a81d2 --- /dev/null +++ b/tests/web_tests/8.3/test_5.php @@ -0,0 +1,59 @@ + 4.0, + 'headers' => array( + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ) + ) +); + +$error = true; + +$response = $client->get($url . '_stats'); +if ($response->getStatusCode() == 200) { + + $response = $client->put($url . 'testbucket'); + if ($response->getStatusCode() == 200) { + $response = $client->put( + $url . 'testbucket/_doc/enrico?refresh=true', + array ( + //'debug' => TRUE, + 'json' => array( + 'name' => 'Enrico Simonetti' + ) + ) + ); + if ($response->getStatusCode() == 201) { + $response = $client->get( + $url . 'testbucket/_search', + array( + //'debug' => TRUE, + 'query' => array( + 'q' => 'simonetti' + ) + ) + ); + $decoded = json_decode($response->getBody(), true); + if (!empty($decoded['hits']) + && $decoded['hits']['total']['value'] === 1 + && $decoded['hits']['hits']['0']['_id'] === 'enrico') { + // expected result found + $error = false; + } + } + + $response = $client->delete($url . 'testbucket'); + } +} + +if (!$error) { + echo $ok; +} diff --git a/utilities/configs/config_override_dockerized.php b/utilities/configs/config_override_dockerized.php index 518e46728..0012e9a6d 100644 --- a/utilities/configs/config_override_dockerized.php +++ b/utilities/configs/config_override_dockerized.php @@ -10,7 +10,8 @@ $sugar_config['db_manager'] = 'MysqliManager'; $sugar_config['db'] = array(); $sugar_config['external_cache']['redis']['host'] = 'sugar-redis'; -$sugar_config['external_cache_disabled'] = 'false'; -$sugar_config['external_cache_disabled_redis'] = 'false'; +$sugar_config['external_cache']['redis']['port'] = '6379'; +$sugar_config['external_cache_disabled'] = 0; +$sugar_config['external_cache_disabled_redis'] = 0; $sugar_config['host_name'] = 'docker.local'; $sugar_config['site_url'] = 'http://docker.local/sugar'; diff --git a/utilities/stack.sh b/utilities/stack.sh index 9ab34708a..d34e7b218 100755 --- a/utilities/stack.sh +++ b/utilities/stack.sh @@ -13,7 +13,7 @@ cd $REPO if [ -z $1 ] || [ -z $2 ] then - echo Provide two parameters. The sugar stack version keyword for \(eg: 13, 12\) and the action \(up, down\). The stacks keywords available can be found below: + echo Provide two parameters. The sugar stack version keyword for \(eg: 14, 13\) and the action \(up, down\). The stacks keywords available can be found below: for index in "${stacks[@]}" ; do KEY="${index%%::*}" echo $KEY diff --git a/utilities/stacks.conf b/utilities/stacks.conf index 48e56dec5..a38ba963c 100644 --- a/utilities/stacks.conf +++ b/utilities/stacks.conf @@ -21,4 +21,6 @@ stacks=( '12-local::stacks/sugar12/php80-local-build.yml' '13::stacks/sugar13/php82.yml' '13-local::stacks/sugar13/php82-local-build.yml' + '14::stacks/sugar14/php83.yml' + '14-local::stacks/sugar14/php83-local-build.yml' ) diff --git a/utilities/sugardockerized/checkversion.sh b/utilities/sugardockerized/checkversion.sh index c5f90a074..6aa1311be 100755 --- a/utilities/sugardockerized/checkversion.sh +++ b/utilities/sugardockerized/checkversion.sh @@ -8,8 +8,7 @@ REPO="$( dirname ${BASH_SOURCE[0]} )/../../" cd $REPO VERSIONFILE=version -#VERSIONFILEURL=https://raw.githubusercontent.com/esimonetti/SugarDockerized/dev/version -VERSIONFILEURL=https://raw.githubusercontent.com/esimonetti/SugarDockerized/master/version +VERSIONFILEURL=https://raw.githubusercontent.com/sugarcrm-developers/SugarDockerized/master/version # if it is our repo if [ -f '.gitignore' ] && [ -d 'data' ] diff --git a/utilities/sugardockerized/install.sh b/utilities/sugardockerized/install.sh index b4e86f7a4..51d233467 100755 --- a/utilities/sugardockerized/install.sh +++ b/utilities/sugardockerized/install.sh @@ -3,7 +3,7 @@ # Enrico Simonetti # enricosimonetti.com -REPOURL=https://github.com/esimonetti/SugarDockerized.git +REPOURL=https://github.com/sugarcrm-developers/SugarDockerized.git INSTALLDIR='sugardocker' diff --git a/utilities/sugardockerized/selfupgrade.sh b/utilities/sugardockerized/selfupgrade.sh index 4ee11865a..92768e6cf 100755 --- a/utilities/sugardockerized/selfupgrade.sh +++ b/utilities/sugardockerized/selfupgrade.sh @@ -3,7 +3,7 @@ # Enrico Simonetti # enricosimonetti.com -REPOURL=https://github.com/esimonetti/SugarDockerized.git +REPOURL=https://github.com/sugarcrm-developers/SugarDockerized.git # enter the repo's root directory REPO="$( dirname ${BASH_SOURCE[0]} )/../../" diff --git a/version b/version index 08369aae5..cd5ac039d 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.51 +2.0 From 814194cd322e8d628ac744211bd437f3ed23f765 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Tue, 21 May 2024 11:24:14 -0400 Subject: [PATCH 14/16] Patched workflows to execute on tag (#12) * Update sugar9.yml * Update sugar11.yml --- .github/workflows/sugar11.yml | 5 +++-- .github/workflows/sugar9.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sugar11.yml b/.github/workflows/sugar11.yml index 240d8eb99..a05f898b6 100644 --- a/.github/workflows/sugar11.yml +++ b/.github/workflows/sugar11.yml @@ -2,8 +2,9 @@ name: on: #push: # branches: [ master, dev ] - pull_request: - branches: [ master ] + push: + tags: + - 'v*' jobs: tests: runs-on: ubuntu-latest diff --git a/.github/workflows/sugar9.yml b/.github/workflows/sugar9.yml index 616a1047c..80403609d 100644 --- a/.github/workflows/sugar9.yml +++ b/.github/workflows/sugar9.yml @@ -2,8 +2,9 @@ name: on: #push: # branches: [ master, dev ] - pull_request: - branches: [ master ] + push: + tags: + - 'v*' jobs: tests: runs-on: ubuntu-latest From fa6e664361d2d14491b31823628d00398a5deb94 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Tue, 21 May 2024 15:43:28 -0400 Subject: [PATCH 15/16] Modifying to use proper Docker images. (#13) --- stacks/sugar14/php83.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stacks/sugar14/php83.yml b/stacks/sugar14/php83.yml index 55d4a1d45..99fc386c6 100644 --- a/stacks/sugar14/php83.yml +++ b/stacks/sugar14/php83.yml @@ -3,7 +3,7 @@ version: '3' services: web1: container_name: "sugar-web1" - image: sugarcrmdevelopers/sugardockerized:php8.2-apache-latest + image: sugarcrmdevelopers/sugardockerized:php8.3-apache-latest ports: - "80:80" extra_hosts: @@ -13,7 +13,7 @@ services: - "APACHE_RUN_GROUP=sugar" volumes: - ../../data/app:/var/www/html - - ../../images/php/82/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini + - ../../images/php/83/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -27,10 +27,10 @@ services: - testsmtp cron: container_name: "sugar-cron" - image: sugarcrmdevelopers/sugardockerized:php8.2-cron-latest + image: sugarcrmdevelopers/sugardockerized:php8.3-cron-latest volumes: - ../../data/app:/var/www/html - - ../../images/php/82/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini + - ../../images/php/83/apache/config/php/docker.ini:/usr/local/etc/php/conf.d/docker.ini depends_on: - mysql - elasticsearch @@ -44,11 +44,11 @@ services: - testsmtp mysql: container_name: "sugar-mysql" - image: sugarcrmdevelopers/sugardockerized:mysql8.0.32-latest + image: sugarcrmdevelopers/sugardockerized:mysql8.3.0-latest ports: - "3306:3306" volumes: - - ../../data/mysql/8032:/var/lib/mysql + - ../../data/mysql/830:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_USER=sugar @@ -63,7 +63,7 @@ services: - es-data01:/usr/share/elasticsearch/data environment: - node.name=sugar1 - - cluster.name=sugarcrm13 + - cluster.name=sugarcrm14 - discovery.type=single-node - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - xpack.security.enabled=false From 4c737e6fb0372508e4c02ee2b001a74eed5dbcb4 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Thu, 17 Oct 2024 09:11:31 -0400 Subject: [PATCH 16/16] Fixed when .htaccess not present (#16) * Modifying to use proper Docker images. * Fixed when .htaccess not present --- utilities/configs/.htaccess | 75 ++++++++++++++++++++++++++++++++++++ utilities/restorefromfile.sh | 3 ++ 2 files changed, 78 insertions(+) create mode 100644 utilities/configs/.htaccess diff --git a/utilities/configs/.htaccess b/utilities/configs/.htaccess new file mode 100644 index 000000000..dd5edd856 --- /dev/null +++ b/utilities/configs/.htaccess @@ -0,0 +1,75 @@ +# BEGIN SUGARCRM RESTRICTIONS +# Fix mimetype for logo.svg (SP-1395) +AddType image/svg+xml .svg +AddType application/json .json +AddType application/javascript .js + +ErrorDocument 404 /404.php +ErrorDocument 403 /404.php + + + Options +FollowSymLinks + RewriteEngine On + RewriteBase / + RewriteRule (?i)package\.json - [F] + RewriteRule (?i)yarn\.lock - [F] + RewriteRule (?i)gulpfile\.js - [F] + RewriteRule (?i)webpack\.config\.js - [F] + RewriteRule (?i)\.git - [F] + RewriteRule (?i)\.log$ - [F] + RewriteRule (?i)^bin/ - [F] + RewriteRule (?i)^cache/diagnostic/ - [F] + RewriteRule (?i)^composer\.(json|lock)$ - [F] + RewriteRule (?i)^cron\.php$ - [F] + RewriteRule (?i)^custom/blowfish/ - [F] + RewriteRule (?i)^dist/ - [F] + RewriteRule (?i)^emailmandelivery\.php$ - [F] + RewriteRule (?i)^files\.md5$ - [F] + RewriteRule (?i)^src/ - [F] + RewriteRule (?i)^upload/ - [F] + RewriteRule (?i)^upgrades/ - [F] + RewriteRule (?i)^vendor/(?!ytree.*\.(css|gif|js|png)$) - [F] + RewriteRule (?i)^(cache|clients|data|examples|include|install|jssource|metadata|ModuleInstall|modules|soap|xtemplate)/.*\.(php|tpl|phar)$ - [F] + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^rest/(.*)$ api/rest.php?__sugar_url=$1 [L,QSA] + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^cache/api/metadata/lang_(.._..)_(.*)_public(_ordered)?\.json$ rest/v10/lang/public/$1?platform=$2&ordered=$3 [N,QSA,DPI] + + RewriteRule ^cache/api/metadata/lang_(.._..)_([^_]*)(_ordered)?\.json$ rest/v10/lang/$1?platform=$2&ordered=$3 [N,QSA,DPI] + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^cache/Expressions/functions_cache(_debug)?.js$ rest/v10/ExpressionEngine/functions?debug=$1 [N,QSA,DPI] + RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&module=app_strings&lang=$1 [L,QSA,DPI] + RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&module=$1&lang=$2 [L,QSA,DPI] + RewriteRule ^oauth-handler/(.*)$ index.php?module=EAPM&action=$1 [L,QSA] + RewriteRule ^portal/(.*)$ portal2/$1 [L,QSA] + RewriteRule ^portal$ portal/? [R=301,L] + + + + AddType application/x-font-woff .woff + + + + Header set ETag "" + Header set Cache-Control "max-age=2592000" + Header set Expires "01 Jan 2112 00:00:00 GMT" + + + + ExpiresByType text/css "access plus 1 month" + ExpiresByType text/javascript "access plus 1 month" + ExpiresByType application/x-javascript "access plus 1 month" + ExpiresByType image/gif "access plus 1 month" + ExpiresByType image/jpg "access plus 1 month" + ExpiresByType image/png "access plus 1 month" + ExpiresByType application/x-font-woff "access plus 1 month" + ExpiresByType image/svg "access plus 1 month" + + + Header always set X-Frame-Options "SAMEORIGIN" + +# END SUGARCRM RESTRICTIONS diff --git a/utilities/restorefromfile.sh b/utilities/restorefromfile.sh index 00d4b4102..b29c33f65 100755 --- a/utilities/restorefromfile.sh +++ b/utilities/restorefromfile.sh @@ -93,6 +93,9 @@ else exit 1 fi echo "Dockerizing Backup config files..." + if [ ! -f ./data/app/sugar/.htaccess ]; then + cp ./utilities/configs/.htaccess ./data/app/sugar/.htaccess + fi sed -i.bak 's@RewriteBase /@RewriteBase /sugar@g' ./data/app/sugar/.htaccess cat ./utilities/configs/config_override_dockerized.php >> ./data/app/sugar/config_override.php