From 99c3e9e52f7b0542d1c5047166b62259226057a3 Mon Sep 17 00:00:00 2001 From: Tom Harper Date: Fri, 14 Jun 2024 15:20:05 +0100 Subject: [PATCH] Add JQ as a dependency + install extra extensions from volker.json (#25) --- php-71/DockerFile | 2 +- php-72/DockerFile | 2 +- php-73/DockerFile | 2 +- php-74/DockerFile | 2 +- php-80/DockerFile | 2 +- php-81/DockerFile | 2 +- php-82/DockerFile | 2 +- php-83/DockerFile | 2 +- resources/scripts/php/root-start-script.sh | 34 +++++++++++++++++++++- 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/php-71/DockerFile b/php-71/DockerFile index 81d92f2..34210c9 100644 --- a/php-71/DockerFile +++ b/php-71/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-72/DockerFile b/php-72/DockerFile index e02563f..5f5e312 100644 --- a/php-72/DockerFile +++ b/php-72/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-73/DockerFile b/php-73/DockerFile index 64b8079..a72fd5e 100644 --- a/php-73/DockerFile +++ b/php-73/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-74/DockerFile b/php-74/DockerFile index 31afaf5..2957877 100644 --- a/php-74/DockerFile +++ b/php-74/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-80/DockerFile b/php-80/DockerFile index 2a9df3f..f3b10e9 100644 --- a/php-80/DockerFile +++ b/php-80/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-81/DockerFile b/php-81/DockerFile index 2af9150..374e678 100644 --- a/php-81/DockerFile +++ b/php-81/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-82/DockerFile b/php-82/DockerFile index 96334e0..7873ab1 100644 --- a/php-82/DockerFile +++ b/php-82/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/php-83/DockerFile b/php-83/DockerFile index ba391e0..cc2e166 100644 --- a/php-83/DockerFile +++ b/php-83/DockerFile @@ -19,7 +19,7 @@ COPY /resources/config/php/ /docker-config/ COPY /resources/scripts/php/install_* /docker-scripts/ # Run Installation Scripts -RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client imagemagick +RUN /docker-scripts/install_dependencies.sh sudo vim nano netcat-traditional git iputils-ping dnsutils default-mysql-client imagemagick jq RUN install-php-extensions mysqli \ pdo_mysql \ mbstring \ diff --git a/resources/scripts/php/root-start-script.sh b/resources/scripts/php/root-start-script.sh index 65917d3..f7d804b 100755 --- a/resources/scripts/php/root-start-script.sh +++ b/resources/scripts/php/root-start-script.sh @@ -66,4 +66,36 @@ if [ -f "/home/www/.config/volker/certs/volker-ca.pem" ]; then fi echo "Adding .vimrc"; -echo "syntax on" >> /home/www/.vimrc; \ No newline at end of file +echo "syntax on" >> /home/www/.vimrc; + +# Using jq, fish the extra php extensions out of volker.json and install them +install_extensions_from_volker_json() { + if [ ! -f '/var/www/volker.json' ]; then + return 0; + fi + + echo 'Attempting to install custom extensions' + + # Parse the extra extensions out of volker.json first + extensions=$(jq -r '.extra_php_extensions | join(" ")' /var/www/volker.json) + + if [ $? -ne 0 ]; then + echo "Failed to parse extra extensions out of JSON." + + return 1 + fi + + + if [ -z "$extensions" ]; then + echo "No extensions found to install." + + return 0; + fi + + echo "Attempting to install extensions: '$extensions'" + + # Run the install-php-extensions command + install-php-extensions $extensions +} + +install_extensions_from_volker_json