Issue
I have a Dockerfile like this
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install \
software-properties-common \
vim \
curl \
sudo \
dnsutils \
telnet \
git \
wget \
zip \
unzip \
unison \
gawk \
php7.4-cli \
php7.4-mysql \
php7.4-gd \
php7.4-curl \
php7.4-ldap \
php7.4-xmlrpc \
php7.4-xml \
php7.4-mbstring \
php7.4-zip \
php7.4-mbstring \
composer \
subversion \
openjdk-8-jdk \
make ruby ruby-dev gcc && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Composer install
ENV PATH "/composer/vendor/bin:$PATH"
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV COMPOSER_VERSION 1.4.2
RUN curl -s -f -L -o /tmp/installer.php https://raw.githubusercontent.com/composer/getcomposer.org/da290238de6d63faace0343efbdd5aa9354332c5/web/installer \
&& php -r " \
\$signature = '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410'; \
\$hash = hash('SHA384', file_get_contents('/tmp/installer.php')); \
if (\$signature != \$hash) { \
unlink('/tmp/installer.php'); \
echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \
exit(1); \
}" \
&& php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION} \
&& rm /tmp/installer.php \
&& composer --ansi --version --no-interaction
COPY ./asset/docker-entrypoint.sh /docker-entrypoint.sh
# Manage composer cache
RUN mkdir -p /composer && chmod -R 0777 /composer
# Manage certificate update manually
RUN sed '/DST_Root_CA_X3.crt/d' /etc/ca-certificates.conf > /tmp/cacerts.conf && mv /tmp/cacerts.conf /etc/ca-certificates.conf
RUN update-ca-certificates
RUN dpkg-reconfigure -f noninteractive ca-certificates
RUN chmod a+x /*.sh
WORKDIR /var/www/project
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]
When I am running this file from Ubuntu terminal, I am getting this below error.
All settings correct for using Composer
SHA384 is not supported by your openssl extension
Even I tried to manually copy the installer.php and moved into path /tmp/installer.php, still I am getting the same error. I tried to change the composer version to 2.6.6, but there is no change in the error.
So can someone please let me know how can I solve this issue?
Solution
The core error is about your OpenSSL version during the build process:
SHA384 is not supported by your OpenSSL extension
Instead of going through this entire troublesome process of downloading the Composer and manual installing, I would make use of the Multi Stage Build feature. It would make your Dockerfile much cleaner.
Instead of:
FROM ubuntu:20.04
Mark it as the base build using newer syntax:
#syntax=docker/dockerfile:1.4
FROM ubuntu:20.04 as base
And instead of downloading and installing Composer by yourself, you can simply copy the binary from another image:
COPY --from=composer:2 --link /usr/bin/composer /usr/bin/composer
Answered By - Mike Doe Answer Checked By - Mary Flores (WPSolving Volunteer)