Skip to content

Commit

Permalink
Update the entrypoint and cmd for php images
Browse files Browse the repository at this point in the history
  • Loading branch information
jalendport committed Jul 11, 2024
1 parent 1b99185 commit 7deee9f
Show file tree
Hide file tree
Showing 20 changed files with 320 additions and 90 deletions.
23 changes: 14 additions & 9 deletions php/7.4-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/7.4-cli/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 14 additions & 9 deletions php/7.4-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/7.4-fpm/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 14 additions & 9 deletions php/8.0-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/8.0-cli/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 14 additions & 9 deletions php/8.0-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/8.0-fpm/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 14 additions & 9 deletions php/8.1-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/8.1-cli/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 14 additions & 9 deletions php/8.1-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,6 +13,7 @@ RUN set -ex \
libxml2-dev \
libzip-dev \
&& apk add --no-cache \
# Runtime dependencies
freetype \
git \
gnu-libiconv \
Expand Down Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions php/8.1-fpm/composer_install.sh
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 7deee9f

Please sign in to comment.