From 8c7f3f64712919be3c51a464e6467e70d8cb5a96 Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Tue, 17 May 2022 20:34:41 +0200 Subject: [PATCH] Run php-cli as www-data on nginx container for compatability. --- php/Dockerfile.Flavours | 4 ++++ php/Makefile | 1 + php/nginx/php-cli-user-shim.sh | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 php/nginx/php-cli-user-shim.sh diff --git a/php/Dockerfile.Flavours b/php/Dockerfile.Flavours index 6e36b53..d0ac8c5 100644 --- a/php/Dockerfile.Flavours +++ b/php/Dockerfile.Flavours @@ -29,6 +29,7 @@ COPY self-signed-certificates /certs RUN apt-get -qq update && \ # Install pre-dependencies to use apt-key. apt-get -yqq install --no-install-recommends \ + sudo \ lsb-core \ gnupg \ && \ @@ -107,6 +108,9 @@ RUN apt-get -qq update && \ dos2unix -q /etc/service/*/run && \ # Make sure all our new services are executable chmod +x /etc/service/*/run && \ + # Insert shim for php-cli still running in this nginx container to run as www-data. + mv /conf/php-cli-user-shim.sh /usr/local/sbin/php && \ + chmod +x /usr/local/sbin/php && \ # Cleanup the /conf dir rm -R /conf && \ # Write the PHP version into some template locations diff --git a/php/Makefile b/php/Makefile index 6eb038d..d28730e 100644 --- a/php/Makefile +++ b/php/Makefile @@ -33,5 +33,6 @@ bake: $(MAKE) docker-php-core bake-flavours PHP_VERSION=7.3 $(MAKE) docker-php-core bake-flavours PHP_VERSION=7.4 $(MAKE) docker-php-core bake-flavours PHP_VERSION=8.0 + $(MAKE) docker-php-core bake-flavours PHP_VERSION=8.1 all: bake \ No newline at end of file diff --git a/php/nginx/php-cli-user-shim.sh b/php/nginx/php-cli-user-shim.sh new file mode 100644 index 0000000..7a9fc16 --- /dev/null +++ b/php/nginx/php-cli-user-shim.sh @@ -0,0 +1,3 @@ +#!/bin/sh +sudo -u www-data /usr/bin/php "$*" +return $?