From 2e3a5011033d519d4cbaa18c3e4dce3e52ab23e5 Mon Sep 17 00:00:00 2001 From: Rafael Fernandes <87442654+rfernandes-sugarcrm@users.noreply.github.com> Date: Wed, 10 May 2023 10:09:41 -0400 Subject: [PATCH] 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 @@ +