diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ddad99..57e957d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,10 +18,12 @@ jobs: strategy: matrix: version: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] - flavor: [ '', '-apache', '-fpm' ] + flavor: [ '', '-apache', '-fpm', '-alpine', '-fpm-alpine' ] include: - version: 'latest' flavor: '' + - version: 'alpine' + flavor: '' services: registry: image: registry:2 @@ -41,6 +43,7 @@ jobs: cache-from: type=registry,ref=chialab/php:${{ matrix.version }}${{ matrix.flavor }} cache-to: type=inline context: . + file: ${{ ((contains(matrix.flavor, 'alpine') || matrix.version == 'alpine') && 'Dockerfile.alpine') || 'Dockerfile' }} build-args: | BASE_IMAGE=php:${{ matrix.version }}${{ matrix.flavor }} tags: localhost:5000/chialab/php:${{ matrix.version }}${{ matrix.flavor }} @@ -110,10 +113,12 @@ jobs: strategy: matrix: version: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] - flavor: [ '', '-apache', '-fpm' ] + flavor: [ '', '-apache', '-fpm', '-alpine', '-fpm-alpine' ] include: - version: 'latest' flavor: '' + - version: 'alpine' + flavor: '' services: registry: image: registry:2 @@ -152,6 +157,7 @@ jobs: cache-from: type=registry,ref=chialab/php:${{ matrix.version }}${{ matrix.flavor }} cache-to: type=inline context: . + file: ${{ ((contains(matrix.flavor, 'alpine') || matrix.version == 'alpine') && 'Dockerfile.alpine') || 'Dockerfile' }} build-args: | BASE_IMAGE=php:${{ matrix.version }}${{ matrix.flavor }} tags: | diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..9fddb5c --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,58 @@ +ARG BASE_IMAGE=php:alpine +FROM ${BASE_IMAGE} +LABEL maintainer="dev@chialab.io" + +# Download script to install PHP extensions and dependencies +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions + +RUN apk add --no-cache \ + coreutils \ + curl \ + git \ + zip unzip \ +# iconv, mbstring and pdo_sqlite are omitted as they are already installed + && PHP_EXTENSIONS=" \ + amqp \ + bcmath \ + bz2 \ + calendar \ + event \ + exif \ + gd \ + gettext \ + imagick \ + intl \ + ldap \ + memcached \ + mysqli \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + redis \ + soap \ + sockets \ + xsl \ + zip \ + " \ + && case "$PHP_VERSION" in \ + 5.6.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt mysql";; \ + 7.0.*|7.1.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt";; \ + esac \ + && install-php-extensions $PHP_EXTENSIONS \ + && if command -v a2enmod; then a2enmod rewrite; fi + +# Install Composer. +ENV PATH=$PATH:/root/composer/vendor/bin \ + COMPOSER_ALLOW_SUPERUSER=1 \ + COMPOSER_HOME=/root/composer +RUN cd /root \ + # Download installer and check for its integrity. + && curl -sSL https://getcomposer.org/installer > composer-setup.php \ + && curl -sSL https://composer.github.io/installer.sha384sum > composer-setup.sha384sum \ + && sha384sum --check composer-setup.sha384sum \ + # Install Composer 2. + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer --2 \ + # Remove installer files. + && rm /root/composer-setup.php /root/composer-setup.sha384sum diff --git a/Makefile b/Makefile index afc3866..efc38cc 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,11 @@ EXTENSIONS := \ xsl \ zip \ sockets -ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to PHP < 7.2. EXTENSIONS += mcrypt endif -ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to 5.x series images. EXTENSIONS += mysql endif @@ -52,8 +52,8 @@ test: echo 'FAIL [Missing image!!!]'; \ exit 1; \ fi - @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) bash -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ - if [[ "$(PHP_VERSION)" != "latest" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ + @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ + if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \ exit 1; \ fi diff --git a/dev/Makefile b/dev/Makefile index 765f2e4..bfba162 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -34,11 +34,11 @@ EXTENSIONS := \ xsl \ zip \ sockets -ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to PHP < 7.2. EXTENSIONS += mcrypt endif -ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to 5.x series images. EXTENSIONS += mysql endif @@ -53,8 +53,8 @@ test: echo 'FAIL [Missing image!!!]'; \ exit 1; \ fi - @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) bash -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ - if [[ "$(PHP_VERSION)" != "latest" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ + @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ + if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \ exit 1; \ fi diff --git a/pcov/Makefile b/pcov/Makefile index 0360281..16f8c69 100644 --- a/pcov/Makefile +++ b/pcov/Makefile @@ -34,7 +34,7 @@ EXTENSIONS := \ xsl \ zip \ sockets -ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to PHP < 7.2. EXTENSIONS += mcrypt endif @@ -49,8 +49,8 @@ test: echo 'FAIL [Missing image!!!]'; \ exit 1; \ fi - @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) bash -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ - if [[ "$(PHP_VERSION)" != "latest" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ + @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ + if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \ exit 1; \ fi diff --git a/xhprof/Makefile b/xhprof/Makefile index 4323102..7dfbf51 100644 --- a/xhprof/Makefile +++ b/xhprof/Makefile @@ -34,11 +34,11 @@ EXTENSIONS := \ xhprof \ xsl \ zip -ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to PHP < 7.2. EXTENSIONS += mcrypt endif -ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest)) +ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 latest alpine)) # Add more extensions to 5.x series images. EXTENSIONS += mysql endif @@ -53,8 +53,8 @@ test: echo 'FAIL [Missing image!!!]'; \ exit 1; \ fi - @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) bash -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ - if [[ "$(PHP_VERSION)" != "latest" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ + @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ + if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \ exit 1; \ fi