From 7deee9ff0b55c330645746a5d2c2063849f51e11 Mon Sep 17 00:00:00 2001 From: Jalen Davenport Date: Thu, 11 Jul 2024 16:20:58 -0400 Subject: [PATCH] Update the entrypoint and cmd for php images --- php/7.4-cli/Dockerfile | 23 ++++++++++++++--------- php/7.4-cli/composer_install.sh | 18 ++++++++++++++++++ php/7.4-fpm/Dockerfile | 23 ++++++++++++++--------- php/7.4-fpm/composer_install.sh | 18 ++++++++++++++++++ php/8.0-cli/Dockerfile | 23 ++++++++++++++--------- php/8.0-cli/composer_install.sh | 18 ++++++++++++++++++ php/8.0-fpm/Dockerfile | 23 ++++++++++++++--------- php/8.0-fpm/composer_install.sh | 18 ++++++++++++++++++ php/8.1-cli/Dockerfile | 23 ++++++++++++++--------- php/8.1-cli/composer_install.sh | 18 ++++++++++++++++++ php/8.1-fpm/Dockerfile | 23 ++++++++++++++--------- php/8.1-fpm/composer_install.sh | 18 ++++++++++++++++++ php/8.2-cli/Dockerfile | 23 ++++++++++++++--------- php/8.2-cli/composer_install.sh | 18 ++++++++++++++++++ php/8.2-fpm/Dockerfile | 23 ++++++++++++++--------- php/8.2-fpm/composer_install.sh | 18 ++++++++++++++++++ php/8.3-cli/Dockerfile | 23 ++++++++++++++--------- php/8.3-cli/composer_install.sh | 18 ++++++++++++++++++ php/8.3-fpm/Dockerfile | 23 ++++++++++++++--------- php/8.3-fpm/composer_install.sh | 18 ++++++++++++++++++ 20 files changed, 320 insertions(+), 90 deletions(-) create mode 100644 php/7.4-cli/composer_install.sh create mode 100644 php/7.4-fpm/composer_install.sh create mode 100644 php/8.0-cli/composer_install.sh create mode 100644 php/8.0-fpm/composer_install.sh create mode 100644 php/8.1-cli/composer_install.sh create mode 100644 php/8.1-fpm/composer_install.sh create mode 100644 php/8.2-cli/composer_install.sh create mode 100644 php/8.2-fpm/composer_install.sh create mode 100644 php/8.3-cli/composer_install.sh create mode 100644 php/8.3-fpm/composer_install.sh diff --git a/php/7.4-cli/Dockerfile b/php/7.4-cli/Dockerfile index 73e5f7b..fc13f9c 100644 --- a/php/7.4-cli/Dockerfile +++ b/php/7.4-cli/Dockerfile @@ -1,14 +1,8 @@ FROM php:7.4-cli-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -53,4 +48,14 @@ RUN set -ex \ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php"] diff --git a/php/7.4-cli/composer_install.sh b/php/7.4-cli/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/7.4-cli/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/7.4-fpm/Dockerfile b/php/7.4-fpm/Dockerfile index 09888e7..a479a6a 100644 --- a/php/7.4-fpm/Dockerfile +++ b/php/7.4-fpm/Dockerfile @@ -1,14 +1,8 @@ FROM php:7.4-fpm-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -56,4 +51,14 @@ COPY ./phpfpm.conf /usr/local/etc/php-fpm.d/yy-spark.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php-fpm +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php-fpm"] diff --git a/php/7.4-fpm/composer_install.sh b/php/7.4-fpm/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/7.4-fpm/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.0-cli/Dockerfile b/php/8.0-cli/Dockerfile index 76c7dc6..d6dfea2 100644 --- a/php/8.0-cli/Dockerfile +++ b/php/8.0-cli/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.0-cli-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -53,4 +48,14 @@ RUN set -ex \ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php"] diff --git a/php/8.0-cli/composer_install.sh b/php/8.0-cli/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.0-cli/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.0-fpm/Dockerfile b/php/8.0-fpm/Dockerfile index db61abb..1910969 100644 --- a/php/8.0-fpm/Dockerfile +++ b/php/8.0-fpm/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.0-fpm-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -56,4 +51,14 @@ COPY ./phpfpm.conf /usr/local/etc/php-fpm.d/yy-spark.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php-fpm +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php-fpm"] diff --git a/php/8.0-fpm/composer_install.sh b/php/8.0-fpm/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.0-fpm/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.1-cli/Dockerfile b/php/8.1-cli/Dockerfile index 8ca9aac..40906be 100644 --- a/php/8.1-cli/Dockerfile +++ b/php/8.1-cli/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.1-cli-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -53,4 +48,14 @@ RUN set -ex \ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php"] diff --git a/php/8.1-cli/composer_install.sh b/php/8.1-cli/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.1-cli/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.1-fpm/Dockerfile b/php/8.1-fpm/Dockerfile index 6c8d50c..a959f76 100644 --- a/php/8.1-fpm/Dockerfile +++ b/php/8.1-fpm/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.1-fpm-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -56,4 +51,14 @@ COPY ./phpfpm.conf /usr/local/etc/php-fpm.d/yy-spark.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php-fpm +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php-fpm"] diff --git a/php/8.1-fpm/composer_install.sh b/php/8.1-fpm/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.1-fpm/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.2-cli/Dockerfile b/php/8.2-cli/Dockerfile index 3000d67..5633cb3 100644 --- a/php/8.2-cli/Dockerfile +++ b/php/8.2-cli/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.2-cli-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -53,4 +48,14 @@ RUN set -ex \ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php"] diff --git a/php/8.2-cli/composer_install.sh b/php/8.2-cli/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.2-cli/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.2-fpm/Dockerfile b/php/8.2-fpm/Dockerfile index 70619b6..568a6f0 100644 --- a/php/8.2-fpm/Dockerfile +++ b/php/8.2-fpm/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.2-fpm-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -56,4 +51,14 @@ COPY ./phpfpm.conf /usr/local/etc/php-fpm.d/yy-spark.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php-fpm +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php-fpm"] diff --git a/php/8.2-fpm/composer_install.sh b/php/8.2-fpm/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.2-fpm/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.3-cli/Dockerfile b/php/8.3-cli/Dockerfile index 19fafaf..3bebab5 100644 --- a/php/8.3-cli/Dockerfile +++ b/php/8.3-cli/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.3-cli-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -63,4 +58,14 @@ RUN set -ex \ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php"] diff --git a/php/8.3-cli/composer_install.sh b/php/8.3-cli/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.3-cli/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi diff --git a/php/8.3-fpm/Dockerfile b/php/8.3-fpm/Dockerfile index 855211f..81eb543 100644 --- a/php/8.3-fpm/Dockerfile +++ b/php/8.3-fpm/Dockerfile @@ -1,14 +1,8 @@ FROM php:8.3-fpm-alpine -RUN mkdir -p /app - -WORKDIR /app - # https://github.com/docker-library/php/issues/105#issuecomment-249716758 -RUN set -ex \ - && apk update \ - # Install dependencies - && apk add --no-cache --virtual .build-deps \ +RUN apk add --no-cache --virtual .build-deps \ + # Build dependencies $PHPIZE_DEPS \ freetype-dev \ icu-dev \ @@ -19,6 +13,7 @@ RUN set -ex \ libxml2-dev \ libzip-dev \ && apk add --no-cache \ + # Runtime dependencies freetype \ git \ gnu-libiconv \ @@ -66,4 +61,14 @@ COPY ./phpfpm.conf /usr/local/etc/php-fpm.d/yy-spark.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -CMD php-fpm +RUN mkdir -p /app /app-tmp + +WORKDIR /app + +COPY ./composer_install.sh /app-tmp/composer_install.sh +RUN chmod a+x /app-tmp/composer_install.sh + +# Runs "composer install" if composer.json exists but composer.lock or vendor do not exist +ENTRYPOINT ["/app-tmp/composer_install.sh"] + +CMD ["php-fpm"] diff --git a/php/8.3-fpm/composer_install.sh b/php/8.3-fpm/composer_install.sh new file mode 100644 index 0000000..28adb37 --- /dev/null +++ b/php/8.3-fpm/composer_install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +echo "Checking for composer.json and the absence of composer.lock or vendor..." +if [ -f "composer.json" ] && ( [ ! -f "composer.lock" ] || [ ! -d "vendor" ] ); then + echo "Running composer install..." + composer \ + --no-ansi \ + --no-dev \ + --no-interaction \ + --no-progress \ + --no-scripts \ + --optimize-autoloader \ + install +else + echo "No composer installation needed." +fi