Skip to content

Conversation

@louisbels
Copy link

What:

  • Bug Fix
  • New Feature

Description:

Problem

Pest 4.x requires PHP 8.3+ minimum and the sockets extension. The existing Dockerfile was using PHP 8.1 and didn't include sockets.

Solution

Reorganize Dockerfile to meet Pest 4 requirements and fix the build order:

  • Upgraded PHP from 8.1 to 8.3 (Pest 4 minimum requirement)
  • Added sockets extension (Pest 4 requirement)
  • Consolidated all apk add commands into a single RUN with --no-cache
  • Moved linux-headers autoconf build-base before docker-php-ext-install

Changes

Before

Before (PHP 8.1, no sockets, wrong build order)

ARG PHP=8.1
RUN apk update && apk add zip libzip-dev icu-dev git
RUN docker-php-ext-install zip intl
RUN apk add --no-cache linux-headers autoconf build-base  # Too late!

After (PHP 8.3, sockets added, correct build order)

ARG PHP=8.3
RUN apk update && apk add --no-cache \
    zip libzip-dev icu-dev git \
    linux-headers autoconf build-base  # Available for compilation
RUN docker-php-ext-install zip intl sockets

Testing

docker compose build 
make install            # Now succeeds

Fixes Docker build failure when upgrading to PHP 8.3+ with sockets extension.

The issue occurred because build tools (gcc, make, autoconf) were being
installed after attempting to compile PHP extensions, causing the build to
fail with exit code 2.

Changes:
- Consolidated all dependencies in single RUN command with --no-cache
- Added linux-headers, autoconf, build-base before extension compilation
- Added sockets extension to docker-php-ext-install
- Upgraded default PHP version from 8.1 to 8.3

This ensures build tools are available before pecl/docker-php-ext-install
attempts to compile extensions.
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

Successfully merging this pull request may close these issues.

1 participant