Commit bbaf3f71 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Dockerfile-7.x : réorganisation multi-stage

parent 5479469b
Loading
Loading
Loading
Loading
+47 −42
Original line number Diff line number Diff line
@@ -13,13 +13,18 @@
#   --build-arg no_proxy
#

FROM debian:buster as distrib
FROM composer:2.3.10 AS get-composer

########################################

FROM debian:buster AS distrib
#FROM localhost:5000/stretch

LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"

# Variables d'ENVironnement nécessaires au build
ARG PHP_VERSION

# Variables d'ENVironnement nécessaires au build
ENV PHP_VERSION=${PHP_VERSION} \
    OCI8_PACKAGE="oci8-2.2.0" \
    APACHE_CONF_DIR=/etc/apache2 \
@@ -35,17 +40,6 @@ ENV HTTP_PROXY=${http_proxy} \
ENV APACHE_CONF_LOCAL_DIR=configs/apache \
    PHP_CONF_LOCAL_DIR=configs/php/7.x

# Mise à niveau de la distrib
RUN apt-get -qq update

# Repositories fournissant PHP 5.x, 7.x et 8.x
RUN apt-get install -y wget lsb-release apt-transport-https ca-certificates && \
    wget --no-dns-cache -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list


FROM distrib as install

# Installation des packages communs
RUN apt-get -qq update && \
    apt-get install -y \
@@ -72,6 +66,30 @@ RUN apt-get -qq update && \
        memcached \
        nano \
        netcat-openbsd \
        ssh \
        ssl-cert \
        subversion \
        unzip \
        vim \
        wget \
        zlib1g-dev

########################################

FROM distrib AS php

# Repositories fournissant PHP 5.x, 7.x et 8.x
RUN apt-get -qq update && \
    apt-get install -y \
        wget \
        lsb-release \
        apt-transport-https \
        ca-certificates && \
    wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list

RUN apt-get -qq update && \
    apt-get install -y \
        php-pear \
        php${PHP_VERSION} \
        php${PHP_VERSION}-bcmath \
@@ -97,14 +115,7 @@ RUN apt-get -qq update && \
        php${PHP_VERSION}-common \
        php${PHP_VERSION}-json \
        php${PHP_VERSION}-opcache \
        php${PHP_VERSION}-readline \
        ssh \
        ssl-cert \
        subversion \
        unzip \
        vim \
        wget \
        zlib1g-dev
        php${PHP_VERSION}-readline

# Forçage de la version de PHP CLI
RUN update-alternatives --set php /usr/bin/php${PHP_VERSION}
@@ -114,33 +125,27 @@ ADD ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
ADD ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
ADD ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini

## Package PHP Oracle OCI8
#ADD resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/
#ADD resources/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip /tmp/
#ADD resources/instantclient-sqlplus-linux.x64-18.5.0.0.0dbru.zip /tmp/
#RUN unzip -o /tmp/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip -d /usr/local/ && \
#    unzip -o /tmp/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip -d /usr/local/ && \
#    unzip -o /tmp/instantclient-sqlplus-linux.x64-18.5.0.0.0dbru.zip -d /usr/local/ && \
#    ln -s /usr/local/instantclient_18_5 /usr/local/instantclient && \
#    ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus && \
#    echo 'instantclient,/usr/local/instantclient' | pecl install ${OCI8_PACKAGE} && \
#    echo "extension=oci8.so" > ${PHP_CONF_DIR}/fpm/conf.d/30-php-oci8.ini && \
#    echo "extension=oci8.so" > ${PHP_CONF_DIR}/cli/conf.d/30-php-oci8.ini && \
#    echo "/usr/local/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig

# Apache
# Composer
COPY --from=get-composer /usr/bin/composer /usr/local/bin/composer

## Install de laminas-migration
#RUN composer global require laminas/laminas-migration && \
#    ln -s /root/.composer/vendor/bin/laminas-migration /usr/local/bin/laminas-migration

########################################

FROM php AS apache

RUN apt-get -qq update && \
    apt-get install -y \
        apache2

RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
    a2dismod mpm_event && a2enmod mpm_worker
ADD ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
RUN a2disconf security.conf && \
    a2enconf security-unicaen.conf php${PHP_VERSION}-fpm

# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install de laminas-migration
RUN composer global require laminas/laminas-migration && \
    ln -s /root/.composer/vendor/bin/laminas-migration /usr/local/bin/laminas-migration

# Nettoyage
RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*