Skip to content

Commit

Permalink
Add -eo pipefail to all RUN commands to fail builds correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Sherif Abdel-Naby <[email protected]>
  • Loading branch information
sherifabdlnaby committed Jan 22, 2022
1 parent 175004a commit eef5858
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ARG XDEBUG_VERSION
# Maintainer label
LABEL maintainer="[email protected]"

# Set SHELL flags for RUN commands to allow -e and pipefail
# Rationale: https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# ------------------------------------- Install Packages Needed Inside Base Image --------------------------------------

RUN IMAGE_DEPS="tini gettext"; \
Expand Down Expand Up @@ -50,10 +54,8 @@ RUN apk add --no-cache --virtual .build-deps \
# - src: https://github.com/docker-library/wordpress/blob/master/latest/php7.4/fpm-alpine/Dockerfile \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
| tr ',' '\n' | sort -u | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
# Save Runtime Deps in a virtual deps
apk add --no-network --virtual .php-extensions-rundeps $runDeps; \
# Uninstall Everything we Installed (minus the runtime Deps)
Expand Down

0 comments on commit eef5858

Please sign in to comment.