thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
768 stars 137 forks source link

Building image from php:8.2-v4-apache or php:8.3-v4-apache fails with modified php.ini query #379

Closed cbtrimble closed 4 months ago

cbtrimble commented 5 months ago

Expected Behavior

Current Behavior

I like to run apt-get update && apt-get upgrade -y as part of my Dockerfile. With latest base images, this causes the image build to pause and wait with the following query:

...
=> => extracting sha256:3c167d035eb0fb0bff33db1f12c75c651641ba8c29126ffe56e8112a8887f33b                                                                           
=> => extracting sha256:2500d0f806b7a06d1e3fe7397c2e89e9f306a057ede48a4ed249df6da066691b                                                                           
=> [2/3] COPY src/ /var/www/html/
=> [3/3] RUN sudo apt-get update && sudo apt-get upgrade -y                                                                                                      => => #   1. install the package maintainer's version
=> => #   2. keep the local version currently installed
=> => #   3. show the differences between the versions
=> => #   4. show a side-by-side difference between the versions
=> => #   5. start a new shell to examine the situation
=> => # What do you want to do about modified configuration file php.ini?

Steps to Reproduce (for bugs)

Dockerfile:

FROM thecodingmachine/php:8.2-v4-apache
COPY src/ /var/www/html/

RUN sudo apt-get update && sudo apt-get upgrade -y

ENV APACHE_EXTENSIONS="headers"
ENV TEMPLATE_PHP_INI=production
ENV PHP_INI_EXPOSE_PHP=off
ENV PHP_INI_DISPLAY_ERRORS=off

HEALTHCHECK CMD curl -I -s -S --fail http://localhost/health.html || exit 1

Context

Just trying to build images for production releases.

Your Environment

Same behaviour whether building on my Windows-based developer laptop with Docker Desktop, or on a Jenkins agent running Amazon Linux 2.

cbtrimble commented 5 months ago

Is this a reasonable modification to my Dockerfile?

...
RUN sudo apt-get update && sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -y
...
mistraloz commented 4 months ago

Yes sur, you can do that. But the common recommandation is to add ENV DEBIAN_FRONTEND=noninteractive at begining (i did not test but should use the default action).

PS: Forcing a dist-upgrade in a Docker image is a bit risky... but you do not have many other alternatives while waiting for V5. PS2: For production, you should preferably go with the slim version (lighter, it does not include the php modules that you do not use).

cbtrimble commented 4 months ago

Okay, thanks for the advice, I will try that.