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

Proposal - Merge PHP 8 versions into a single Dockerfile #17

Closed
aegypius opened this issue Feb 19, 2024 · 2 comments · Fixed by #20
Closed

Proposal - Merge PHP 8 versions into a single Dockerfile #17

aegypius opened this issue Feb 19, 2024 · 2 comments · Fixed by #20
Assignees

Comments

@aegypius
Copy link
Contributor

PHP 8 is quite consistent with its extensions and configuration, it may be more efficient for maintainers to use a single Dockerfile with multiple targets. This mean a single configuration file for all PHP 8 targets and parallel build to decrease build time.

This will solve #16 and reduce CI time in the future.

# ================================
# Configure base images
# ================================
FROM php:8.0-fpm as base_php_80
FROM php:8.1-fpm as base_php_81
FROM php:8.2-fpm as base_php_82
FROM php:8.3-fpm as base_php_83
FROM composer:2 as composer
FROM mlocati/php-extension-installer as extension-installer

# ================================
# Configure PHP
# ================================
FROM scratch as config 
WORKDIR /etc/php/conf.d/
COPY --link symfony.ini .
WORKDIR /etc/php/pool.d/
COPY --link symfony.pool.conf .

# ================================
# Build Final Images
# ================================
FROM base_php_80 as php_80
COPY --from=config / /
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
COPY --from=extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extension intl gd opcache mbstring zip pdo_pgsql soap pgsql exif apcu  memcached imagick xdebug

FROM base_php_81 as php_81
COPY --from=config / /
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
COPY --from=extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extension intl gd opcache mbstring zip pdo_pgsql soap pgsql exif apcu  memcached imagick xdebug

 # ...
@aegypius aegypius changed the title Proposal - Merge PHP 8 Proposal into a single Dockerfile Proposal - Merge PHP 8 versions into a single Dockerfile Feb 19, 2024
@thislg
Copy link
Member

thislg commented Feb 27, 2024

If it speeds up build time then let's try it

@lucasmirloup
Copy link
Member

Hi @aegypius 👋

Thanks for the proposal, and for suggesting mlocati/php-extension-installer 👍

I've opened a PR that uses this tool, but I've chosen to only use one Dockerfile stage and Docker Bake with a compose.yaml file to handle all versions, tags & platforms.

I could've split compilation on several GitHub workers, but that's not worth it in our case imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants