Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker build php on alpine image with curl support failed. How I can solve it?

I try to install curl support to php on a php:7-fpm-alpine image. Therefore I utilize the following Dockerfile:

FROM php:7-fpm-alpine

RUN apk add --update libzip-dev libcurl &&\
    docker-php-ext-install curl && \
    apk del gcc g++ &&\
    rm -rf /var/cache/apk/*

But in a similar manner with this question I have hard time installing the required libcurl even though using the apk to install the required library, as the build output shows:

Building base
Step 1/2 : FROM php:7-fpm-alpine
 ---> 3a7affb05baa
Step 2/2 : RUN apk add --update libzip-dev libcurl &&    docker-php-ext-install curl &&     apk del gcc g++ &&    rm -rf /var/cache/apk/*
 ---> Running in 27a225ce5f91
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/4) Installing pkgconf (1.6.0-r0)
(2/4) Installing zlib-dev (1.2.11-r1)
(3/4) Installing libzip (1.5.1-r2)
(4/4) Installing libzip-dev (1.5.1-r2)
Executing busybox-1.29.3-r10.trigger
OK: 18 MiB in 34 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/24) Installing m4 (1.4.18-r1)
(2/24) Installing libbz2 (1.0.6-r6)
(3/24) Installing perl (5.26.3-r0)
(4/24) Installing autoconf (2.69-r2)
(5/24) Installing dpkg-dev (1.19.2-r0)
(6/24) Installing dpkg (1.19.2-r0)
(7/24) Installing libmagic (5.36-r0)
(8/24) Installing file (5.36-r0)
(9/24) Installing libgcc (8.3.0-r0)
(10/24) Installing libstdc++ (8.3.0-r0)
(11/24) Installing binutils (2.31.1-r2)
(12/24) Installing gmp (6.1.2-r1)
(13/24) Installing isl (0.18-r0)
(14/24) Installing libgomp (8.3.0-r0)
(15/24) Installing libatomic (8.3.0-r0)
(16/24) Installing mpfr3 (3.1.5-r1)
(17/24) Installing mpc1 (1.0.3-r1)
(18/24) Installing gcc (8.3.0-r0)
(19/24) Installing musl-dev (1.1.20-r4)
(20/24) Installing libc-dev (0.7.1-r0)
(21/24) Installing g++ (8.3.0-r0)
(22/24) Installing make (4.2.1-r2)
(23/24) Installing re2c (1.1.1-r0)
(24/24) Installing .phpize-deps (0)
Executing busybox-1.29.3-r10.trigger
OK: 218 MiB in 58 packages
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20180731
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.1.1 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for cURL support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libcurl.pc... using default path
checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
Removing intermediate container 27a225ce5f91
ERROR: Service 'base' failed to build: The command '/bin/sh -c apk add --update libzip-dev libcurl &&    docker-php-ext-install curl &&     apk del gcc g++ &&    rm -rf /var/cache/apk/*' returned a non-zero code: 1

I also tried to change the following into my Dockerfile (used curl instead of libcurl)

FROM php:7-fpm-alpine

RUN apk add --update libzip-dev curl &&\
    docker-php-ext-install curl && \
    apk del gcc g++ &&\
    rm -rf /var/cache/apk/*

Also fails as well:

Building base
Step 1/2 : FROM php:7-fpm-alpine
 ---> 3a7affb05baa
Step 2/2 : RUN apk add --update libzip-dev curl &&    docker-php-ext-install curl &&     apk del gcc g++ &&    rm -rf /var/cache/apk/*
 ---> Running in 017b831ba617
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/4) Installing pkgconf (1.6.0-r0)
(2/4) Installing zlib-dev (1.2.11-r1)
(3/4) Installing libzip (1.5.1-r2)
(4/4) Installing libzip-dev (1.5.1-r2)
Executing busybox-1.29.3-r10.trigger
OK: 18 MiB in 34 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/24) Installing m4 (1.4.18-r1)
(2/24) Installing libbz2 (1.0.6-r6)
(3/24) Installing perl (5.26.3-r0)
(4/24) Installing autoconf (2.69-r2)
(5/24) Installing dpkg-dev (1.19.2-r0)
(6/24) Installing dpkg (1.19.2-r0)
(7/24) Installing libmagic (5.36-r0)
(8/24) Installing file (5.36-r0)
(9/24) Installing libgcc (8.3.0-r0)
(10/24) Installing libstdc++ (8.3.0-r0)
(11/24) Installing binutils (2.31.1-r2)
(12/24) Installing gmp (6.1.2-r1)
(13/24) Installing isl (0.18-r0)
(14/24) Installing libgomp (8.3.0-r0)
(15/24) Installing libatomic (8.3.0-r0)
(16/24) Installing mpfr3 (3.1.5-r1)
(17/24) Installing mpc1 (1.0.3-r1)
(18/24) Installing gcc (8.3.0-r0)
(19/24) Installing musl-dev (1.1.20-r4)
(20/24) Installing libc-dev (0.7.1-r0)
(21/24) Installing g++ (8.3.0-r0)
(22/24) Installing make (4.2.1-r2)
(23/24) Installing re2c (1.1.1-r0)
(24/24) Installing .phpize-deps (0)
Executing busybox-1.29.3-r10.trigger
OK: 218 MiB in 58 packages
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20180731
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.1.1 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for cURL support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libcurl.pc... using default path
checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
Removing intermediate container 017b831ba617
ERROR: Service 'base' failed to build: The command '/bin/sh -c apk add --update libzip-dev curl &&    docker-php-ext-install curl &&     apk del gcc g++ &&    rm -rf /var/cache/apk/*' returned a non-zero code: 1

Do you know how to fix this problem?

like image 844
Dimitrios Desyllas Avatar asked Dec 02 '22 09:12

Dimitrios Desyllas


2 Answers

You probably need curl-dev package.

FROM php:7-fpm-alpine

RUN apk add --update libzip-dev curl-dev &&\
    docker-php-ext-install curl && \
    apk del gcc g++ &&\
    rm -rf /var/cache/apk/*
like image 198
Qteb Avatar answered Dec 04 '22 00:12

Qteb


Also in case of these type of problems you can use the following ace in your sleeve:

  1. Launch a seperate container and search for the package:
docker run -ti php:7-fpm-alpine /bin/sh
apk update && apk search libcurl
  1. Then if no appropriate package not found then try to build the missing library.

As @Qteb says the missing package is the curl-dev one.

like image 35
Dimitrios Desyllas Avatar answered Dec 04 '22 00:12

Dimitrios Desyllas