0

Here is the Dockerfile (see below) that I use for my projects. Could you explain to me how to install php8.0-ssh2 from this Dockerfile.

FROM php:8.0.0-fpm-alpine

ARG UID
ARG GID

RUN apk add --no-cache mysql-client msmtp perl wget procps shadow libzip libpng libjpeg-turbo libwebp freetype icu

RUN apk add --no-cache --virtual build-essentials \
    icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev \
    libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev && \
    docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp && \
    docker-php-ext-install gd && \
    docker-php-ext-install mysqli && \
    docker-php-ext-install pdo_mysql && \
    docker-php-ext-install intl && \
    docker-php-ext-install opcache && \
    docker-php-ext-install exif && \
    docker-php-ext-install zip && \
    apk del build-essentials && rm -rf /usr/src/php*

RUN wget https://getcomposer.org/composer-stable.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer

RUN apk add --no-cache tzdata
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

COPY php.ini /usr/local/etc/php/php.ini

RUN apk --no-cache add shadow && \
    usermod -u $UID www-data && \
    groupmod -g $GID www-data

I did a lot of research and attempts, including:

RUN apk add --no-cache libssh2-dev autoconf build-base
RUN pecl install ssh2-1.2 && docker-php-ext-enable ssh2

This seems to work for PHP7, but not for PHP8.

Thanks for your help.

FloWebDev
  • 11
  • 3
  • 1
    It is always important to include _how_ something does not work. What kind of error are you getting? What have you tried to resolve that error? – ArSeN Sep 10 '21 at 19:26
  • https://pecl.php.net/package/ssh2 the only version that supports 8+ is 1.3.1 which is currently in beta status. – Sammitch Sep 10 '21 at 21:02
  • with the previous lines I get : `ERROR: make failed The command '/bin/sh -c pecl install ssh2-1.2 && docker-php-ext-enable ssh2' returned a non-zero code: 1 ERROR: Service 'php-fpm' failed to build : Build failed` – FloWebDev Sep 10 '21 at 21:09
  • @Sammitch Thank you so much. With 1.3.1 everything works ! :-) – FloWebDev Sep 10 '21 at 21:13

2 Answers2

1

I could install and activate ssh2 for php 8 :

RUN apk add --no-cache libssh2-dev autoconf build-base
RUN pecl install ssh2-1.3.1 && docker-php-ext-enable ssh2

Thanks to @Sammitch for his help.

FloWebDev
  • 11
  • 3
1

Try installing it manually

RUN apk add --no-cache build-base libssh2-dev libssh2 autoconf
RUN curl https://pecl.php.net/get/ssh2-1.2.tgz -o ssh2.tgz \
    && pecl install ssh2 ssh2.tgz \
    && docker-php-ext-enable ssh2 \
    && rm -rf ssh2.tgz
Jacky
  • 11
  • 1