Skip to content

Commit cc6c16b

Browse files
committed
simplify composer installation
Dockerfile's COPY instruction supports copying from another image. This feature simplifies composer installation significantly because composer can simply be copied over from official image rather than programatically installed.
1 parent 8ed25a7 commit cc6c16b

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

files/Dockerfile

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,7 @@ RUN if [ -z "$(grep '^8\.' /etc/debian_version)" ]; then \
8888
fi
8989

9090
# install composer
91-
WORKDIR /usr/src
92-
93-
# based on https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
94-
RUN \
95-
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" \
96-
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
97-
&& ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" \
98-
&& if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; \
99-
then \
100-
>&2 echo 'ERROR: Invalid installer checksum'; \
101-
rm composer-setup.php; \
102-
exit 1; \
103-
fi \
104-
&& php composer-setup.php \
105-
&& php -r "unlink('composer-setup.php');"
91+
COPY --from=composer ["/usr/bin/composer", "/usr/bin/composer"]
10692

10793
#
10894
# The explain plan in the sql tests contain partition/filtered properties
@@ -152,13 +138,9 @@ RUN \
152138
# install predis
153139
# installation will be in /usr/src/vendor/predis/predis
154140
# which is value which should be used for PREDIS_HOME
155-
RUN php composer.phar require "predis/predis"
156-
RUN php composer.phar update
157-
158-
#
159-
# install composer and make executable so it can be used in dev env
160-
#
161-
RUN cp composer.phar /usr/local/bin/composer && chmod +x /usr/local/bin/composer
141+
WORKDIR /usr/src
142+
RUN composer require "predis/predis"
143+
RUN composer update
162144

163145
#
164146
# These args need to be repeated so we can propagate the VARS within this build context.

0 commit comments

Comments
 (0)