Skip to content

Commit

Permalink
refactor(dockerfile): set shell options globally
Browse files Browse the repository at this point in the history
  • Loading branch information
guoard committed Jan 5, 2024
1 parent 9278aa2 commit a9a058f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
18 changes: 7 additions & 11 deletions 8.1-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ ARG SWOOLE_VERSION="5.1.1"
# Phalcon - https://github.com/phalcon/cphalcon
ARG PHALCON_VERSION="5.5.0"

SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]

# Install dependencies
RUN set -eux \
&& apk add --no-cache \
RUN apk add --no-cache \
c-client \
ca-certificates \
freetds \
Expand Down Expand Up @@ -54,8 +55,7 @@ RUN set -eux \
#############################################

# Development dependencies
RUN set -eux \
&& apk add --no-cache --virtual .build-deps \
RUN apk add --no-cache --virtual .build-deps \
autoconf \
bzip2-dev \
cmake \
Expand Down Expand Up @@ -98,7 +98,6 @@ RUN set -eux \
&& ln -s /usr/lib /usr/local/lib64 \
\
# Enable ffi if it exists
&& set -eux \
&& if [ -f /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini ]; then \
echo "ffi.enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini; \
fi \
Expand Down Expand Up @@ -348,18 +347,16 @@ RUN set -eux \
&& rm -rf /tmp/* \
&& true

RUN set -eux \
# Fix php.ini settings for enabled extensions
&& chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
RUN chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
# Shrink binaries
&& (find /usr/local/bin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/lib -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/sbin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& true

# Install Composer
RUN set -eux \
&& curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
RUN curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
&& echo "${COMPOSER_SUM} composer.phar" | sha256sum -c - \
&& chmod +x composer.phar \
&& mv composer.phar /usr/local/bin/composer \
Expand All @@ -371,9 +368,8 @@ COPY 8.1-fpm/php-fpm.tmpl.conf /var/data/php-fpm/php-fpm.tmpl.conf
COPY 8.1-fpm/www.tmpl.conf /var/data/php-fpm/www.tmpl.conf
COPY 8.1-fpm/php.tmpl.ini /var/data/php-fpm/default-php.tmpl.ini

RUN set -eux \
# PHP-FPM templates directory
&& mkdir -p /var/data/php-fpm \
RUN mkdir -p /var/data/php-fpm \
# Remove few PHP-FPM default config files
&& rm -rf /usr/local/etc/php-fpm.d/zz-docker.conf \
&& rm -rf /usr/local/etc/php-fpm.d/docker.conf \
Expand Down
18 changes: 7 additions & 11 deletions 8.2-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ ARG SWOOLE_VERSION="5.1.1"
# Phalcon - https://github.com/phalcon/cphalcon
ARG PHALCON_VERSION="5.5.0"

SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]

# Install dependencies
RUN set -eux \
&& apk add --no-cache \
RUN apk add --no-cache \
c-client \
ca-certificates \
freetds \
Expand Down Expand Up @@ -54,8 +55,7 @@ RUN set -eux \
#############################################

# Development dependencies
RUN set -eux \
&& apk add --no-cache --virtual .build-deps \
RUN apk add --no-cache --virtual .build-deps \
autoconf \
bzip2-dev \
cmake \
Expand Down Expand Up @@ -98,7 +98,6 @@ RUN set -eux \
&& ln -s /usr/lib /usr/local/lib64 \
\
# Enable ffi if it exists
&& set -eux \
&& if [ -f /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini ]; then \
echo "ffi.enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini; \
fi \
Expand Down Expand Up @@ -342,18 +341,16 @@ RUN set -eux \
&& rm -rf /tmp/* \
&& true

RUN set -eux \
# Fix php.ini settings for enabled extensions
&& chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
RUN chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
# Shrink binaries
&& (find /usr/local/bin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/lib -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/sbin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& true

# Install Composer
RUN set -eux \
&& curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
RUN curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
&& echo "${COMPOSER_SUM} composer.phar" | sha256sum -c - \
&& chmod +x composer.phar \
&& mv composer.phar /usr/local/bin/composer \
Expand All @@ -365,9 +362,8 @@ COPY 8.2-fpm/php-fpm.tmpl.conf /var/data/php-fpm/php-fpm.tmpl.conf
COPY 8.2-fpm/www.tmpl.conf /var/data/php-fpm/www.tmpl.conf
COPY 8.2-fpm/php.tmpl.ini /var/data/php-fpm/default-php.tmpl.ini

RUN set -eux \
# PHP-FPM templates directory
&& mkdir -p /var/data/php-fpm \
RUN mkdir -p /var/data/php-fpm \
# Remove few PHP-FPM default config files
&& rm -rf /usr/local/etc/php-fpm.d/zz-docker.conf \
&& rm -rf /usr/local/etc/php-fpm.d/docker.conf \
Expand Down
18 changes: 7 additions & 11 deletions 8.3-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ ARG SWOOLE_VERSION="5.1.1"
# # Phalcon - https://github.com/phalcon/cphalcon
# ARG PHALCON_VERSION="5.4.0"

SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]

# Install dependencies
RUN set -eux \
&& apk add --no-cache \
RUN apk add --no-cache \
c-client \
ca-certificates \
freetds \
Expand Down Expand Up @@ -54,8 +55,7 @@ RUN set -eux \
#############################################

# Development dependencies
RUN set -eux \
&& apk add --no-cache --virtual .build-deps \
RUN apk add --no-cache --virtual .build-deps \
autoconf \
bzip2-dev \
cmake \
Expand Down Expand Up @@ -98,7 +98,6 @@ RUN set -eux \
&& ln -s /usr/lib /usr/local/lib64 \
\
# Enable ffi if it exists
&& set -eux \
&& if [ -f /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini ]; then \
echo "ffi.enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini; \
fi \
Expand Down Expand Up @@ -342,18 +341,16 @@ RUN set -eux \
&& rm -rf /tmp/* \
&& true

RUN set -eux \
# Fix php.ini settings for enabled extensions
&& chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
RUN chmod +x "$(php -r 'echo ini_get("extension_dir");')"/* \
# Shrink binaries
&& (find /usr/local/bin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/lib -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& (find /usr/local/sbin -type f -print0 | xargs -n1 -0 strip --strip-all -p 2>/dev/null || true) \
&& true

# Install Composer
RUN set -eux \
&& curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
RUN curl -LO "https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar" \
&& echo "${COMPOSER_SUM} composer.phar" | sha256sum -c - \
&& chmod +x composer.phar \
&& mv composer.phar /usr/local/bin/composer \
Expand All @@ -365,9 +362,8 @@ COPY 8.3-fpm/php-fpm.tmpl.conf /var/data/php-fpm/php-fpm.tmpl.conf
COPY 8.3-fpm/www.tmpl.conf /var/data/php-fpm/www.tmpl.conf
COPY 8.3-fpm/php.tmpl.ini /var/data/php-fpm/default-php.tmpl.ini

RUN set -eux \
# PHP-FPM templates directory
&& mkdir -p /var/data/php-fpm \
RUN mkdir -p /var/data/php-fpm \
# Remove few PHP-FPM default config files
&& rm -rf /usr/local/etc/php-fpm.d/zz-docker.conf \
&& rm -rf /usr/local/etc/php-fpm.d/docker.conf \
Expand Down

0 comments on commit a9a058f

Please sign in to comment.