-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Symptom
When trying to build PHP containers I get the following error:
=> ERROR [stage-0 9/10] COPY ../conf/msmtprc/msmtprc /var/www/.msmtprc 0.0s
------
> [stage-0 9/10] COPY ../conf/msmtprc/msmtprc /var/www/.msmtprc:
------
php:33
--------------------
31 | && rm -rf /var/lib/apt/lists/*
32 |
33 | >>> COPY ../conf/msmtprc/msmtprc /var/www/.msmtprc
34 | RUN chown www-data:www-data /var/www/.msmtprc \
35 | && chmod 600 /var/www/.msmtprc
--------------------
failed to solve: failed to compute cache key: failed to calculate checksum of ref wpjix3ouilcrtk5nlc0bs3gz7::aq9d2423g532j79o9s5df5lcg: "/conf/msmtprc/msmtprc": not found
Reproduction
- Get latest available version
- Force rebuild of PHP containers (e.g.
docker-composer down php84 && docker-compose --env-file .env.local build php84 && docker-compose --env-file .env.local up -d php84) - See the error occuring
Cause
In the docker compose file, PHP containers are build with a specific build context:
x-php-build: &default-php-build
dockerfile: php
context: ./build
args:
<<: *default-php-build-args
But the php DockerFile tries to copy a file from outside the build context which is forbidden:
COPY ../conf/msmtprc/msmtprc /var/www/.msmtprc
Note: Mind that Docker reworks the path to be absolute within the build context: "/conf/msmtprc/msmtprc": not found
So this can't work.
Proposed solutions
Quick fix
Replace the MSMTP configuration file in the php DockerFile so it points to the build/default_configuration folder. It would allow people to update their environment as it is presently broken.
The obvious drawback of this solution, is that the configuration won't be overridable by the user.
Replace
COPY ../conf/msmtprc/msmtprc /var/www/.msmtprc
With
COPY default_configuration/msmtprc/msmtprc /var/www/.msmtprc
Prettier solutions?
From what I understand, we don't use the root folder as the build context to avoid passing the whole ./html folder to the Docker builder daemon, which makes sense.
Maybe we should consider moving the conf within the /build folder alongside /build/default_configuration and rename it to something like /build/user_configuration?
Or maybe we should set it through a volume like we do for PHP *.ini files?
volumes:
- ${CONF_FOLDER}/php/php.ini:/usr/local/etc/php/conf.d/php.ini
- ${CONF_FOLDER}/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
...