Skip to content

[BUG]: Compile failed using PECL on Alpine linux based docker images #16769

Open
@vkozelka

Description

@vkozelka

Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord

Describe the bug
If using alpine based docker images, phalcon using pecl installation failed

To Reproduce
To reproduce this issue you can try only using this dockerfile and try build the image

Steps to reproduce the behavior:

I do not know if it helps, but install with similar errors are for me only on alpine images

This dockerfile is good but install fails

ARG PHP_VERSION=8.4.7

FROM php:${PHP_VERSION}-fpm-alpine

WORKDIR /srv/app

RUN apk update && apk add --no-cache \
    ${PHPIZE_DEPS} \
    icu-dev \
    libzip-dev \
    libpng-dev \
    jpeg-dev \
    freetype-dev \
    libxml2-dev \
    oniguruma-dev \
    mariadb-client \
    git \
    unzip \
    linux-headers \
    pcre-dev

RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) \
    pdo_mysql \
    intl \
    opcache \
    zip \
    gd \
    mbstring \
    xml \
    ctype \
    bcmath \
    sockets

RUN pecl install apcu && docker-php-ext-enable apcu
RUN pecl install redis && docker-php-ext-enable redis
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN pecl install psr && docker-php-ext-enable psr
RUN pecl install phalcon-5.9.0 && docker-php-ext-enable phalcon

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

ARG UID=1000
ARG GID=1000
RUN addgroup -g ${GID} --system appgroup && \
    adduser -u ${UID} --system -G appgroup appuser

RUN chown -R appuser:appgroup /srv/app

USER appuser

EXPOSE 9000
CMD ["php-fpm"]

When i change image form alpine to default php:8.4.7-fpm (and also apk > apt, updates package names for debian in first install)

install proceeds well. Hope this helps somebody

docker composer build

Expected behavior
Expected behavior is that image is built.

Details

  • Phalcon version: 5.9
  • PHP Version: tested on 8.3.21 and 8.4.7
  • Operating System: Docker (alpine linux)
  • Installation type: pecl install phalcon-5.9.0
  • Zephir version (if any):
  • Server: Caddy used in docker stack
  • Other related info (Database, table schema): not needed

Additional context
Workaround is change alpine based image to debian based image and install work. for example converted my dockerfile do debian based is below

ARG PHP_VERSION=8.4.7

# Použijeme standardní Debian-based PHP image
FROM php:${PHP_VERSION}-fpm

WORKDIR /srv/app

# Instalace závislostí pro Debian
# Ekvivalenty apk balíčků a další běžně potřebné
RUN apt-get update && apt-get install -y --no-install-recommends \
    ${PHPIZE_DEPS} \
    libicu-dev \
    libzip-dev \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    libxml2-dev \
    libonig-dev \
    mariadb-client \
    git \
    unzip \
    libpcre3-dev \
    && rm -rf /var/lib/apt/lists/*

# Konfigurace a instalace PHP rozšíření (mělo by fungovat stejně)
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) \
    pdo_mysql \
    intl \
    opcache \
    zip \
    gd \
    mbstring \
    xml \
    ctype \
    bcmath \
    sockets

# Instalace rozšíření přes PECL (mělo by fungovat stejně)
RUN pecl install apcu && docker-php-ext-enable apcu
RUN pecl install redis && docker-php-ext-enable redis
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN pecl install psr && docker-php-ext-enable psr
RUN pecl install phalcon-5.9.0 && docker-php-ext-enable phalcon

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

ARG UID=1000
ARG GID=1000
# Vytvoření skupiny a uživatele na Debianu
# Použijeme standardní příkazy, -r pro systémové pokud by UID/GID nebyly specifikovány nebo <1000
# Ale s UID/GID=1000 to budou běžní uživatelé/skupiny
RUN groupadd -g ${GID} appgroup || true && \
    useradd -u ${UID} -g appgroup -ms /bin/bash appuser

RUN chown -R appuser:appgroup /srv/app

USER appuser

EXPOSE 9000
CMD ["php-fpm"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions