Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
973ed5e
add php56 support + jinja2 templating to php modules
RSchumacher13 Sep 7, 2020
1ac8165
Merge branch 'master' into feat/php-56-support
RSchumacher13 Sep 7, 2020
5918b45
add ansible dependency to ci.sh script
RSchumacher13 Sep 8, 2020
600ff11
Merge branch 'feat/php-56-support' of github.com:continuousphp/runtim…
RSchumacher13 Sep 8, 2020
ff4f830
give a new try to ci.sh
RSchumacher13 Sep 8, 2020
ccfaf69
give a new try to ci.sh
RSchumacher13 Sep 8, 2020
c8d9929
give a new try to ci.sh
RSchumacher13 Sep 8, 2020
d1b08ff
display used php version in CI
RSchumacher13 Sep 8, 2020
6b88d38
install ansible via pip2
RSchumacher13 Sep 8, 2020
f615e97
ci.sh tries
RSchumacher13 Sep 8, 2020
27ca46e
another try
RSchumacher13 Sep 8, 2020
2d0174c
another try
RSchumacher13 Sep 8, 2020
d28f696
another try
RSchumacher13 Sep 8, 2020
b59eb71
force python3
RSchumacher13 Sep 8, 2020
00b392c
force python3
RSchumacher13 Sep 8, 2020
b04e9a8
another try
RSchumacher13 Sep 8, 2020
ab6cd96
force pip3 for ansible setup
RSchumacher13 Sep 8, 2020
beaf822
output ssh key
RSchumacher13 Sep 8, 2020
866ca52
output ssh key
RSchumacher13 Sep 8, 2020
68c09dd
clean uneeded verbose outputs
RSchumacher13 Sep 9, 2020
ed850f7
refactor code duplicate
RSchumacher13 Sep 9, 2020
c4f25b1
displays exception
RSchumacher13 Sep 9, 2020
1b598f0
fix semantic versioning for devilbox container
RSchumacher13 Sep 10, 2020
83dc0e1
add normal runtime form php-5.6.40
RSchumacher13 Sep 10, 2020
7f44662
Delete php_custom.yml
RSchumacher13 Sep 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ start_builder() {
echo "EC2 Runtime Builder IP: $ip"
break
fi

aws ec2 start-instances --instance-ids $AWS_RUNTIME_EC2_ID
sleep 20
done
Expand All @@ -50,23 +49,24 @@ run_copy_build_package() {
run_build() {
runtime=$1
version=$2
exec_builder "cd /usr/local/runtime-containers/$CPHP_BUILD_ID; ./bin/docker-template build --runtime $runtime --version $version --verbose --replace" || return 1
exec_builder "cd /usr/local/runtime-containers/$CPHP_BUILD_ID ; ./bin/docker-template build --runtime $runtime --version $version --verbose --replace" || return 1
return 0
}

run_test() {
runtime=$1
version=$2
exec_builder "cd /usr/local/runtime-containers/$CPHP_BUILD_ID && ./bin/docker-template test --runtime $runtime --version $version --verbose" || return 1
exec_builder "cd /usr/local/runtime-containers/$CPHP_BUILD_ID ; ./bin/docker-template test --runtime $runtime --version $version --verbose" || return 1
return 0
}

run_deploy() {
runtime=$1
version=$2
exec_builder "docker tag continuous:php_$version 310957825501.dkr.ecr.us-east-1.amazonaws.com/cphp/runtime/php:$version"
echo $runtime:$version
exec_builder "docker tag continuous:php_$version 310957825501.dkr.ecr.us-east-1.amazonaws.com/cphp/runtime/$runtime:$version"
exec_builder "aws ecr get-login --region us-east-1 --registry-ids 310957825501 --no-include-email | bash"
exec_builder "docker push 310957825501.dkr.ecr.us-east-1.amazonaws.com/cphp/runtime/php:$version"
exec_builder "docker push 310957825501.dkr.ecr.us-east-1.amazonaws.com/cphp/runtime/$runtime:$version"
}

action=$1
Expand Down
29 changes: 19 additions & 10 deletions bin/docker-template
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ from shutil import copy2, copytree, rmtree
import subprocess
import sys
import yaml

from pathlib import Path
from ansible.plugins.test.core import version_compare
from jinja2 import Environment, FileSystemLoader

class App:

def __init__(self, args):

self.root = '/'.join([os.path.dirname(os.path.realpath(__file__)), '..'])
self.batsimage = '/'.join([self.root, 'bats', 'batsimage.d'])
self.logs = '/'.join([self.root, 'bin', 'logs.txt'])
Expand Down Expand Up @@ -63,7 +64,7 @@ class App:
""" Display outputs into the shell """
output = subprocess.run(cmd.split(' '), capture_output=False)
if 0 != output.returncode:
raise Exception('ERROR');
raise Exception(output);

def clean_up_context(self):
""" Clean up temporary files """
Expand Down Expand Up @@ -106,15 +107,24 @@ class App:
# Here replace by flavour image or version "example php:version"
if version == 'generic':
base = 'debian:jessie'
# Devilbox container doesn't respect semantic versioning
elif version == '5.6.40-fpm':
base = 'devilbox/php-fpm:5.6-base'
else:
base = '{}:{}'.format(self.template['image'], version)

dockerfile.write('FROM '+base+'\n')
for component in self.template['components']:
component_file = '/'.join([self.components,
component, self.template['flavour'], component+'.dtc'])
dockerfile.write(
open(component_file, 'r').read()+'\n')

component_file = '/'.join([self.components, component, self.template['flavour'], component+'.dtc'])
component_path = '/'.join([self.components, component, self.template['flavour']])
if (component == "php_modules"):
j2_env = Environment(loader=FileSystemLoader(component_path), trim_blocks=True)
j2_env.filters['version'] = version_compare
component_content = j2_env.get_template(component+'.j2').render(PHP_VERSION=version)
with open(component_path + '/' + component +'.dtc', 'w') as f:
f.write(component_content)
dockerfile.write(open(component_file, 'r').read()+'\n')

def generate_runtime_container(self):
""" Create a container for each version of specified runtime """
for version in self.versions:
Expand Down Expand Up @@ -181,7 +191,6 @@ class App:
self.versions = list(filter(lambda version:
self.exec('/'.join([self.root, 'bin', 'check_container.sh continuous:{}_{}'
.format(self.runtime, version)]), not self.verbose) == 0, self.versions))

self.display('Versions that have been created : \n' +
'\n'.join(self.versions), "green")

Expand All @@ -191,7 +200,7 @@ class App:

self.display('Versions that are supposed to exist : \n' +
'\n'.join(self.versions), "blue")

self.versions = list(filter(lambda version:
self.exec('/'.join([self.root, 'bin', 'check_container.sh continuous:{}_{}'
.format(self.runtime, version)]), not self.verbose) == 0, self.versions))
Expand Down
2 changes: 1 addition & 1 deletion components/ansible/deb/ansible.dtc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
RUN pip install ansible
RUN pip3 install ansible
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USER root

# Installing libraries
# Installing generic system libraries
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y \
build-essential libaio1 \
Expand All @@ -25,23 +25,60 @@ RUN apt-get update && apt-get upgrade -y \
libtidy-dev \
libxslt-dev \
libzip-dev \
libsodium-dev \
&& apt-get autoremove --purge -y && apt-get autoclean -y && apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/*



{% if PHP_VERSION | version('7.1.40', '<') and PHP_VERSION | version('7.0.0', '>')%}
# Libsodium for PHP 7.0.0...7.1.40
RUN pecl install -f libsodium && docker-php-ext-enable sodium
{% endif %}

{% if PHP_VERSION | version('7.1.0', '<') and PHP_VERSION | version('7.0.0', '>') %}
# Xdebug for PHP 7.0.0...7.1.0
RUN pecl install xdebug-2.9.0 && docker-php-ext-enable xdebug.so
{% endif %}

{% if PHP_VERSION | version('7.1.0', '>=') %}
# Xdebug for PHP >= 7.1.0
RUN pecl install xdebug && docker-php-ext-enable xdebug.so
{% endif %}

{% if PHP_VERSION | version('7.4.0', '<') %}
# GD for PHP < 7.4.0
RUN docker-php-ext-install recode
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd
{% endif %}

{% if PHP_VERSION | version('7.3.99', '>') %}
# GD for PHP > 7.3.99
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && docker-php-ext-install gd
{% endif %}

# Configure extension
RUN docker-php-ext-configure zip \
&& PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl
RUN docker-php-ext-configure zip && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl

#Since the release of PHP5, system libs have changed location, shocker...
RUN ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

#Generic Pecl dependencies
RUN docker-php-ext-install \
bcmath bz2 calendar dba enchant exif gettext gmp imap intl ldap mysqli pcntl pdo_mysql \
pdo_pgsql pgsql pspell shmop soap sockets sysvmsg sysvsem sysvshm tidy xmlrpc xsl zip

ADD files/php_modules/install_modules.sh .
RUN chmod +x ./install_modules.sh && ./install_modules.sh


{% if PHP_VERSION | version('7', '<') %}
# Pecl dependencies for PHP < 7
RUN pecl install libsodium-1.0.6 amqp apcu-4.0.11 memcached-2.2.0 mongodb-1.7.5 redis-2.2.8 mailparse-2.1.6 \
&& docker-php-ext-enable amqp.so apcu.so memcached.so mongodb.so redis.so mailparse.so libsodium.so
{% endif %}

{% if PHP_VERSION | version('7', '>') %}
# Oracle OCI8 Downloading
RUN wget -O ./instantclient-basic.zip \
https://continuousphp-infra.s3-us-west-1.amazonaws.com/oracle/php_runtime/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip \
Expand All @@ -57,8 +94,9 @@ RUN ldconfig \
&& echo "instantclient,/usr/local/instantclient" | pecl install oci8 \
&& docker-php-ext-enable oci8.so

# Using pecl for some extensions
# Pecl dependencies for PHP > 7
RUN pecl install amqp apcu ast memcached mongodb redis mailparse \
&& docker-php-ext-enable amqp.so ast.so apcu.so memcached.so mongodb.so redis.so mailparse.so
{% endif %}

WORKDIR /home/cphp
WORKDIR /home/cphp
79 changes: 75 additions & 4 deletions components/php_modules/deb/tests/php_modules.bats
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
php_version=$(php -v | head -n 1 | awk '{print $2}')

@test "php-modules < 7.4" {
if [[ "$php_version" > "7.3.99" ]]; then
@test "php-modules < 7.3.99 and php-modules > 7" {
if [[ "$php_version" > "7.3.99" || "$php_version" < "7.0.0" ]]; then
skip
fi
php -m | grep recode
}

@test "php-modules" {
@test "php-modules > 7" {
if [[ "$php_version" > "7" ]]; then
php -m | grep amqp
php -m | grep apcu
php -m | grep ast
Expand Down Expand Up @@ -71,4 +71,75 @@ php_version=$(php -v | head -n 1 | awk '{print $2}')
php -m | grep xdebug
php -m | grep xml
php -m | grep mailparse
else
skip
fi
}

@test "php-modules < 7" {
if [[ "$php_version" < "7" ]]; then
php -m | grep amqp
php -m | grep apcu
php -m | grep bz2
php -m | grep calendar
php -m | grep Core
php -m | grep ctype
php -m | grep curl
php -m | grep date
php -m | grep dba
php -m | grep dom
php -m | grep enchant
php -m | grep exif
php -m | grep fileinfo
php -m | grep filter
php -m | grep ftp
php -m | grep gd
php -m | grep gettext
php -m | grep gmp
php -m | grep hash
php -m | grep iconv
php -m | grep imap
php -m | grep intl
php -m | grep json
php -m | grep ldap
php -m | grep libxml
php -m | grep mbstring
php -m | grep memcached
php -m | grep mongodb
php -m | grep mysqli
php -m | grep mysqlnd
php -m | grep openssl
php -m | grep pcntl
php -m | grep pcre
php -m | grep PDO
php -m | grep pdo_mysql
php -m | grep pdo_pgsql
php -m | grep pdo_sqlite
php -m | grep pgsql
php -m | grep Phar
php -m | grep posix
php -m | grep pspell
php -m | grep readline
php -m | grep redis
php -m | grep Reflection
php -m | grep session
php -m | grep shmop
php -m | grep SimpleXML
php -m | grep soap
php -m | grep sockets
php -m | grep sodium
php -m | grep SPL
php -m | grep sqlite3
php -m | grep standard
php -m | grep sysvmsg
php -m | grep sysvsem
php -m | grep sysvshm
php -m | grep tidy
php -m | grep tokenizer
php -m | grep xml
php -m | grep mailparse
else
skip
fi
}

30 changes: 0 additions & 30 deletions components/php_modules/files/install_modules.sh

This file was deleted.

1 change: 1 addition & 0 deletions runtimes/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ versions:
- 7.3.8-fpm
- 7.4.2-fpm
- 7.3.13-fpm
- 5.6.40-fpm
components:
- entrypoint
- init_cphp
Expand Down