Skip to content

Commit

Permalink
Sugar v13 - Support for PHP 8.2 (#1)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
rfernandes-sugarcrm and esimonetti authored May 8, 2023
1 parent cf05a8b commit 2ca8dd4
Show file tree
Hide file tree
Showing 38 changed files with 751 additions and 13 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/sugar13.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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).
Expand All @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions images/mysql/8032/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mysql:8.0.32
MAINTAINER [email protected]

COPY config/mysql/docker.cnf /etc/mysql/conf.d/docker.cnf
13 changes: 13 additions & 0 deletions images/mysql/8032/config/mysql/docker.cnf
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions images/permissions/apps/sugarfixpermissions
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

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

# 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
78 changes: 78 additions & 0 deletions images/php/82/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 "<?php \$_SERVER['SERVER_SOFTWARE'] = 'SugarDockerized';" > /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"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AddOutputFilterByType DEFLATE application/json application/javascript text/css
14 changes: 14 additions & 0 deletions images/php/82/apache/config/apache2/sites-available/sugar.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
19 changes: 19 additions & 0 deletions images/php/82/apache/config/php/docker.ini
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions images/php/82/apache/config/php/mods-available/opcache.ini
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions images/php/82/apache/config/php/mods-available/redis.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=redis.so
2 changes: 2 additions & 0 deletions images/php/82/apache/config/php/mods-available/tideways.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension=tideways_xhprof.so
tideways_xhprof.auto_prepend_library=0
13 changes: 13 additions & 0 deletions images/php/82/apache/config/php/mods-available/xdebug.ini
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions images/php/82/apache/config/php/mods-available/xhprof.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof
7 changes: 7 additions & 0 deletions images/php/82/apache/config/php/opcache-blacklist
Original file line number Diff line number Diff line change
@@ -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/*
Loading

0 comments on commit 2ca8dd4

Please sign in to comment.