Skip to content

Commit

Permalink
Sugar 14.0 Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
rfernandes-sugarcrm committed May 21, 2024
1 parent 804f2ef commit 5af7727
Show file tree
Hide file tree
Showing 40 changed files with 734 additions and 9 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/sugar14.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Empty file removed data/app/sugar/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions images/mysql/830/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mysql:8.3.0
MAINTAINER [email protected]

COPY config/mysql/docker.cnf /etc/mysql/conf.d/docker.cnf
13 changes: 13 additions & 0 deletions images/mysql/830/config/mysql/docker.cnf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion images/permissions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:8.8
FROM debian:stable-slim
MAINTAINER [email protected]

RUN adduser sugar --disabled-password --disabled-login --gecos ""
Expand Down
78 changes: 78 additions & 0 deletions images/php/83/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 "<?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.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"
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/83/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>
22 changes: 22 additions & 0 deletions images/php/83/apache/config/php/docker.ini
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions images/php/83/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/83/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/83/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
10 changes: 10 additions & 0 deletions images/php/83/apache/config/php/mods-available/xdebug.ini
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions images/php/83/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/83/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/*
78 changes: 78 additions & 0 deletions images/php/83/cron/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 "<?php \$_SERVER['SERVER_SOFTWARE'] = 'SugarDockerized';" > /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"]
25 changes: 25 additions & 0 deletions images/php/83/cron/apps/sugarcron
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/local/bin/php
<?php

while (true) {

$folder = '/var/www/html/sugar';
$cron_pause = 'cron_pause';
$cron = 'cron.php';

if (is_dir($folder) && !file_exists($folder . '/' . $cron_pause) && file_exists($folder . '/' . $cron) && is_readable($folder . '/' . $cron)) {
echo '[' . date('Y-m-d H:i:s') . '] sugar cron start' . PHP_EOL;
$output = array();
exec('cd ' . $folder . ' && php -f ' . $cron . ' && cd /', $output);
if (!empty($output)) {
echo implode(PHP_EOL, $output).PHP_EOL;
}
echo '[' . date('Y-m-d H:i:s') . '] sugar cron end' . PHP_EOL;
if (file_exists($folder . '/' . $cron_pause)) {
echo 'Pausing cron now. To unpause, remove ' . $folder . $cron_pause . PHP_EOL;
}
}

// snooze a minute
sleep(60);
}
11 changes: 11 additions & 0 deletions images/php/83/cron/config/php/docker.ini
Original file line number Diff line number Diff line change
@@ -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"
Loading

0 comments on commit 5af7727

Please sign in to comment.