Skip to content

Commit

Permalink
Decoupled Images for PHP8.0 (#2)
Browse files Browse the repository at this point in the history
* Decoupled Images for PHP8.0

* Added sugar12 and commons to GH Actions

* Fixed strategy run for local build only
  • Loading branch information
rfernandes-sugarcrm authored May 10, 2023
1 parent 2ca8dd4 commit 2e3a501
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 48 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/sugar-commons.yml
Original file line number Diff line number Diff line change
@@ -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 }}
58 changes: 51 additions & 7 deletions .github/workflows/sugar12.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 0 additions & 3 deletions .github/workflows/sugar13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
tags:
- 'v*'
# branches: [ master, dev ]
# pull_request:
# branches: [ master ]
jobs:
tests:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
data
backups
.DS_Store
20 changes: 0 additions & 20 deletions images/php/80/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ RUN adduser sugar --disabled-password --disabled-login --gecos ""

RUN echo "<?php \$_SERVER['SERVER_SOFTWARE'] = 'SugarDockerized';" > /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

Expand Down
19 changes: 19 additions & 0 deletions images/php/80/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"
12 changes: 0 additions & 12 deletions images/php/80/cron/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ RUN adduser sugar --disabled-password --disabled-login --gecos "" \

RUN echo "<?php \$_SERVER['SERVER_SOFTWARE'] = 'SugarDockerized';" > /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 \
Expand Down
11 changes: 11 additions & 0 deletions images/php/80/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"
6 changes: 6 additions & 0 deletions stacks/sugar12/php80-local-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 7 additions & 6 deletions stacks/sugar12/php80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/web_tests/8.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"guzzlehttp/guzzle": "6.5.6"
}
}
2 changes: 2 additions & 0 deletions tests/web_tests/8.0/test_1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo 'ok';
9 changes: 9 additions & 0 deletions tests/web_tests/8.0/test_2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
session_start();
$ok = 'ok';

$_SESSION[$ok] = $ok;

if ($_SESSION[$ok] == $ok) {
echo $ok;
}
10 changes: 10 additions & 0 deletions tests/web_tests/8.0/test_3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
$ok = 'ok';

$redis = new Redis();
$redis->connect('sugar-redis', 6379);
$redis->set($ok, $ok);

if ($redis->get($ok) == $ok) {
echo $ok;
}
20 changes: 20 additions & 0 deletions tests/web_tests/8.0/test_4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
$ok = 'ok';

$conn = new mysqli('sugar-mysql', 'root', 'root');
if ($conn->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();
Loading

0 comments on commit 2e3a501

Please sign in to comment.