Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine builds on Docker fail #16327

Open
FaimMedia opened this issue Apr 19, 2023 · 5 comments
Open

Alpine builds on Docker fail #16327

FaimMedia opened this issue Apr 19, 2023 · 5 comments
Assignees

Comments

@FaimMedia
Copy link

FaimMedia commented Apr 19, 2023

Hi,

Since a few weeks my Docker builds on Alpine doesn't seem to work anymore. This is my (partial) Dockerfile:

FROM php:8.2-fpm-alpine

ARG PHALCON_VERSION=5.2.1

RUN set -xe && \
        apk add --no-cache --virtual .build-deps \
            autoconf \
            g++ \
            make \
        && \
        docker-php-source extract && \
        # Install ext-phalcon
	cd / && \
        curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz && \
        tar xzf /v${PHALCON_VERSION}.tar.gz && \
        docker-php-ext-install -j $(getconf _NPROCESSORS_ONLN) \
            /cphalcon-${PHALCON_VERSION}/build/phalcon \
        && \
        # Remove all temp files
        rm -r \
            /v${PHALCON_VERSION}.tar.gz \
            /cphalcon-${PHALCON_VERSION} \
        && \
        docker-php-source delete && \
        apk del .build-deps

I've also tried the official approach via PECL (as described on the website), but this giving me the same results:

FROM php:8.2-fpm-alpine

RUN apk update && \
 	apk --no-cache --virtual .build-deps add pcre-dev ${PHPIZE_DEPS}

RUN pecl channel-update pecl.php.net \
	&& pecl install phalcon-5.2.1

This gives me a lot (500+) of compile errors which will eventually quit:

In file included from /usr/local/include/php/main/php.h:35,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/usr/local/include/php/Zend/zend_API.h:2182:71: note: expected 'zval **' {aka 'struct _zval_struct **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2182 | static zend_always_inline bool zend_parse_arg_array(zval *arg, zval **dest, bool check_null, bool or_object)
      |                                                                ~~~~~~~^~~~
In file included from /usr/local/include/php/Zend/zend_types.h:25,
                 from /usr/local/include/php/Zend/zend.h:27,
                 from /usr/local/include/php/main/php.h:31,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c: In function 'zim_Phalcon_Session_Adapter_Redis___construct':
/usr/local/include/php/Zend/zend_API.h:1558:60: warning: passing argument 2 of 'zend_parse_arg_array' from incompatible pointer type [-Wincompatible-pointer-types]
 1558 |                 if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
/usr/local/include/php/Zend/zend_portability.h:364:52: note: in definition of macro 'UNEXPECTED'
  364 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1565:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX2'
 1565 |         Z_PARAM_ARRAY_EX2(dest, check_null, separate, separate)
      |         ^~~~~~~~~~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1568:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX'
 1568 |         Z_PARAM_ARRAY_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~~~
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c:219202:17: note: in expansion of macro 'Z_PARAM_ARRAY'
219202 |                 Z_PARAM_ARRAY(options)
       |                 ^~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/usr/local/include/php/Zend/zend_API.h:2182:71: note: expected 'zval **' {aka 'struct _zval_struct **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2182 | static zend_always_inline bool zend_parse_arg_array(zval *arg, zval **dest, bool check_null, bool or_object)
      |                                                                ~~~~~~~^~~~
In file included from /usr/local/include/php/Zend/zend_types.h:25,
                 from /usr/local/include/php/Zend/zend.h:27,
                 from /usr/local/include/php/main/php.h:31,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c: In function 'zim_Phalcon_Session_Adapter_Stream___construct':
/usr/local/include/php/Zend/zend_API.h:1558:60: warning: passing argument 2 of 'zend_parse_arg_array' from incompatible pointer type [-Wincompatible-pointer-types]
 1558 |                 if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
/usr/local/include/php/Zend/zend_portability.h:364:52: note: in definition of macro 'UNEXPECTED'
  364 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1565:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX2'
 1565 |         Z_PARAM_ARRAY_EX2(dest, check_null, separate, separate)
      |         ^~~~~~~~~~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1568:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX'
 1568 |         Z_PARAM_ARRAY_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~~~
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c:219271:17: note: in expansion of macro 'Z_PARAM_ARRAY'
219271 |                 Z_PARAM_ARRAY(options)
       |                 ^~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/usr/local/include/php/Zend/zend_API.h:2182:71: note: expected 'zval **' {aka 'struct _zval_struct **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2182 | static zend_always_inline bool zend_parse_arg_array(zval *arg, zval **dest, bool check_null, bool or_object)
      |                                                                ~~~~~~~^~~~
In file included from /usr/local/include/php/Zend/zend_types.h:25,
                 from /usr/local/include/php/Zend/zend.h:27,
                 from /usr/local/include/php/main/php.h:31,
                 from /cphalcon-5.2.1/build/phalcon/phalcon.zep.c:46:
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c: In function 'zim_Phalcon_Session_Adapter_Stream_getArrVal':
/usr/local/include/php/Zend/zend_API.h:1558:60: warning: passing argument 2 of 'zend_parse_arg_array' from incompatible pointer type [-Wincompatible-pointer-types]
 1558 |                 if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
/usr/local/include/php/Zend/zend_portability.h:364:52: note: in definition of macro 'UNEXPECTED'
  364 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1565:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX2'
 1565 |         Z_PARAM_ARRAY_EX2(dest, check_null, separate, separate)
      |         ^~~~~~~~~~~~~~~~~
/usr/local/include/php/Zend/zend_API.h:1568:9: note: in expansion of macro 'Z_PARAM_ARRAY_EX'
 1568 |         Z_PARAM_ARRAY_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~~~
/cphalcon-5.2.1/build/phalcon/phalcon.zep.c:219600:17: note: in expansion of macro 'Z_PARAM_ARRAY'
219600 |                 Z_PARAM_ARRAY(collection)
       |                 ^~~~~~~~~~~~~

Also tried using Phalcon 5.1, PHP 8.0 and 8.1, Alpine 3.16, all with the same result. Tried the -DALPINE_LINUX=1 CFLAG, but seems to have no effect.

What is the issue here? Seems to be related to #16213.

When using the Zephir to compile, the build takes forever:

FROM php:8.2-fpm-alpine

RUN apk update && \
 	apk --no-cache --virtual .build-deps add pcre-dev ${PHPIZE_DEPS}

ARG PHALCON_VERSION=5.2.1

# pecl:
RUN pecl channel-update pecl.php.net \
	&& pecl install zephir_parser

RUN echo "extension=zephir_parser.so" > /usr/local/etc/php/conf.d/zephir.ini

RUN cd / \
	&& curl -LO https://github.com/zephir-lang/zephir/releases/download/0.17.0/zephir.phar \
	&& mv zephir.phar /usr/local/bin/zephir \
	&& chmod a+x /usr/local/bin/zephir

RUN cd / \
	&& curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz \
	&& tar xzf /v${PHALCON_VERSION}.tar.gz \
	&& rm -rf /v${PHALCON_VERSION}.tar.gz

RUN cd /cphalcon-${PHALCON_VERSION} \
	&& zephir fullclean \
	&& zephir compile \
	&& cd ext \
	&& phpize \
	&& ./configure \
	&& make \
	&& make install \
	&& cd .. \
	&& zephir install

Could someone please provide me with a solution here :-)

Greetings, Tim

@FaimMedia FaimMedia added bug A bug report status: unverified Unverified labels Apr 19, 2023
@FaimMedia FaimMedia changed the title Alpine builds Docker fail Alpine builds on Docker fail Apr 19, 2023
@yesworld
Copy link

I have the same warnings, but if you wait a while then everything is fine.

Everything works for me and my colleagues.
https://github.com/yesworld/starter-phalcon5-php8-docker

@Nazariy
Copy link

Nazariy commented Jun 1, 2023

Just keep in mind that compile from docker might be resource hungry, took me a while to figure out that I was running out of memory, after allocating 4GB was able to complete the build.

@Jeckerson
Copy link
Member

As @Nazariy said Phalcon will require at least 2Gb of RAM during compilation process. In case you are building docker image inside small virtual machine - add swap file with 2Gb.

@FaimMedia, I just finished to compile Phalcon inside aline, I suggest you to install it via pecl instead of git, as it way to straight forward, requires less steps and at the end docker image weights less.

Here are my commands:

docker run -it --rm php:8.2-fpm-alpine sh
apk update && apk add ${PHPIZE_DEPS}
pecl install phalcon
docker-php-ext-enable phalcon

Check if extension was enabled:

php --ri phalcon

with next output:

/var/www/html # php --ri phalcon

phalcon


Phalcon is a full stack PHP framework, delivered as a PHP extension, offering lower resource consumption and high performance.
phalcon => enabled
Author => Phalcon Team and contributors
Version => 5.2.1
Build Date => Jun  3 2023 14:33:36
Powered by Zephir => Version 0.17.0-$Id$

If you want to speed up compilation, set env variable with number of CPU cores of your compilation machine (before pecl install command):

export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"

@Jeckerson Jeckerson added not a bug Reported issue is not a bug and removed bug A bug report status: unverified Unverified labels Jun 3, 2023
@Jeckerson Jeckerson closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
@Druid33
Copy link

Druid33 commented Dec 13, 2024

Hi, propably i have the same problem.

Building phalcon in docker stop working this days. And Iam sure, that cca one week before everything works and i dont make any changes in docker file.

Commands @Jeckerson write...

docker run -it --rm php:8.2-fpm-alpine sh
apk update && apk add ${PHPIZE_DEPS}
pecl install phalcon
docker-php-ext-enable phalcon

...doesnt work now. Compilation failed with lot of errors.

I thing about some required libraries is missing or updated.

@Jeckerson
Copy link
Member

@Druid33 confirm on alpine. I'll try to investigate route of problem, for now you might change to php:8.2-fpm tag, as it successfully builds on Debian/Ubuntu.

@Jeckerson Jeckerson reopened this Dec 14, 2024
@Jeckerson Jeckerson self-assigned this Dec 14, 2024
@Jeckerson Jeckerson removed the not a bug Reported issue is not a bug label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants