From 0c539dedfd83a28eff3cd1d1d9db9d6f3ee4f0f1 Mon Sep 17 00:00:00 2001
From: Bertrand Gauthier <bertrand.gauthier@unicaen.fr>
Date: Thu, 28 Mar 2019 16:46:42 +0100
Subject: [PATCH] Docker: utilisation d'une variable PHP_VERSION

---
 Dockerfile         | 21 ++++++++++++---------
 Dockerfile-7.0     | 40 ----------------------------------------
 Dockerfile-7.1     | 40 ----------------------------------------
 Dockerfile-7.2     | 40 ----------------------------------------
 Dockerfile-7.3     | 40 ----------------------------------------
 docker-compose.yml |  4 +++-
 6 files changed, 15 insertions(+), 170 deletions(-)
 delete mode 100644 Dockerfile-7.0
 delete mode 100644 Dockerfile-7.1
 delete mode 100644 Dockerfile-7.2
 delete mode 100644 Dockerfile-7.3

diff --git a/Dockerfile b/Dockerfile
index 2d082e1..06ad62a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,19 +4,22 @@
 #
 ###########################################################################################
 
-FROM unicaen-dev-php7.2-apache
+ARG PHP_VERSION
+
+FROM unicaen-dev-php${PHP_VERSION}-apache
 
 LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"
 
 WORKDIR /app
 
 ENV APACHE_CONF_DIR=/etc/apache2 \
-    PHP_CONF_DIR=/etc/php/7.2
+    PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
 ## Installation de packages requis.
-RUN apt-get update -qq && apt-get install -y \
+RUN apt-get update -qq && \
+    apt-get install -y \
         sqlite3 \
-        php7.2-pdo-sqlite
+        php${PHP_VERSION}-pdo-sqlite
 
 RUN pecl install ast && \
     echo "extension=ast.so" > ${PHP_CONF_DIR}/cli/conf.d/ast.ini
@@ -31,10 +34,10 @@ RUN ln -sf /dev/stderr /var/log/apache2/error.log
 
 # Configuration Apache et FPM
 ADD docker/apache-ports.conf    ${APACHE_CONF_DIR}/ports.conf
-ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/webapp.conf
-ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/webapp-ssl.conf
-ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/webapp.conf
+ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/app.conf
+ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/app-ssl.conf
+ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/app.conf
 ADD docker/fpm/conf.d/app.ini   ${PHP_CONF_DIR}/fpm/conf.d/app.ini
 
-RUN a2ensite webapp webapp-ssl && \
-    service php7.2-fpm reload
+RUN a2ensite app app-ssl && \
+    service php${PHP_VERSION}-fpm reload
diff --git a/Dockerfile-7.0 b/Dockerfile-7.0
deleted file mode 100644
index 504cdf3..0000000
--- a/Dockerfile-7.0
+++ /dev/null
@@ -1,40 +0,0 @@
-###########################################################################################
-#
-#                               Image pour le dev.
-#
-###########################################################################################
-
-FROM unicaen-dev-php7.0-apache
-
-LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"
-
-WORKDIR /app
-
-ENV APACHE_CONF_DIR=/etc/apache2 \
-    PHP_CONF_DIR=/etc/php/7.0
-
-## Installation de packages requis.
-RUN apt-get update -qq && apt-get install -y \
-        sqlite3 \
-        php7.0-pdo-sqlite
-
-RUN pecl install ast && \
-    echo "extension=ast.so" > ${PHP_CONF_DIR}/cli/conf.d/ast.ini
-
-# Nettoyage
-RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*
-
-# Symlink apache access and error logs to stdout/stderr so Docker logs shows them
-RUN ln -sf /dev/stdout /var/log/apache2/access.log
-RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
-RUN ln -sf /dev/stderr /var/log/apache2/error.log
-
-# Configuration Apache et FPM
-ADD docker/apache-ports.conf    ${APACHE_CONF_DIR}/ports.conf
-ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/webapp.conf
-ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/webapp-ssl.conf
-ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/webapp.conf
-ADD docker/fpm/conf.d/app.ini   ${PHP_CONF_DIR}/fpm/conf.d/app.ini
-
-RUN a2ensite webapp webapp-ssl && \
-    service php7.0-fpm reload
diff --git a/Dockerfile-7.1 b/Dockerfile-7.1
deleted file mode 100644
index f064317..0000000
--- a/Dockerfile-7.1
+++ /dev/null
@@ -1,40 +0,0 @@
-###########################################################################################
-#
-#                               Image pour le dev.
-#
-###########################################################################################
-
-FROM unicaen-dev-php7.1-apache
-
-LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"
-
-WORKDIR /app
-
-ENV APACHE_CONF_DIR=/etc/apache2 \
-    PHP_CONF_DIR=/etc/php/7.1
-
-## Installation de packages requis.
-RUN apt-get update -qq && apt-get install -y \
-        sqlite3 \
-        php7.1-pdo-sqlite
-
-RUN pecl install ast && \
-    echo "extension=ast.so" > ${PHP_CONF_DIR}/cli/conf.d/ast.ini
-
-# Nettoyage
-RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*
-
-# Symlink apache access and error logs to stdout/stderr so Docker logs shows them
-RUN ln -sf /dev/stdout /var/log/apache2/access.log
-RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
-RUN ln -sf /dev/stderr /var/log/apache2/error.log
-
-# Configuration Apache et FPM
-ADD docker/apache-ports.conf    ${APACHE_CONF_DIR}/ports.conf
-ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/webapp.conf
-ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/webapp-ssl.conf
-ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/webapp.conf
-ADD docker/fpm/conf.d/app.ini   ${PHP_CONF_DIR}/fpm/conf.d/app.ini
-
-RUN a2ensite webapp webapp-ssl && \
-    service php7.1-fpm reload
diff --git a/Dockerfile-7.2 b/Dockerfile-7.2
deleted file mode 100644
index 2d082e1..0000000
--- a/Dockerfile-7.2
+++ /dev/null
@@ -1,40 +0,0 @@
-###########################################################################################
-#
-#                               Image pour le dev.
-#
-###########################################################################################
-
-FROM unicaen-dev-php7.2-apache
-
-LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"
-
-WORKDIR /app
-
-ENV APACHE_CONF_DIR=/etc/apache2 \
-    PHP_CONF_DIR=/etc/php/7.2
-
-## Installation de packages requis.
-RUN apt-get update -qq && apt-get install -y \
-        sqlite3 \
-        php7.2-pdo-sqlite
-
-RUN pecl install ast && \
-    echo "extension=ast.so" > ${PHP_CONF_DIR}/cli/conf.d/ast.ini
-
-# Nettoyage
-RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*
-
-# Symlink apache access and error logs to stdout/stderr so Docker logs shows them
-RUN ln -sf /dev/stdout /var/log/apache2/access.log
-RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
-RUN ln -sf /dev/stderr /var/log/apache2/error.log
-
-# Configuration Apache et FPM
-ADD docker/apache-ports.conf    ${APACHE_CONF_DIR}/ports.conf
-ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/webapp.conf
-ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/webapp-ssl.conf
-ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/webapp.conf
-ADD docker/fpm/conf.d/app.ini   ${PHP_CONF_DIR}/fpm/conf.d/app.ini
-
-RUN a2ensite webapp webapp-ssl && \
-    service php7.2-fpm reload
diff --git a/Dockerfile-7.3 b/Dockerfile-7.3
deleted file mode 100644
index a1489e7..0000000
--- a/Dockerfile-7.3
+++ /dev/null
@@ -1,40 +0,0 @@
-###########################################################################################
-#
-#                               Image pour le dev.
-#
-###########################################################################################
-
-FROM unicaen-dev-php7.3-apache
-
-LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"
-
-WORKDIR /app
-
-ENV APACHE_CONF_DIR=/etc/apache2 \
-    PHP_CONF_DIR=/etc/php/7.3
-
-## Installation de packages requis.
-RUN apt-get update -qq && apt-get install -y \
-        sqlite3 \
-        php7.3-pdo-sqlite
-
-RUN pecl install ast && \
-    echo "extension=ast.so" > ${PHP_CONF_DIR}/cli/conf.d/ast.ini
-
-# Nettoyage
-RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*
-
-# Symlink apache access and error logs to stdout/stderr so Docker logs shows them
-RUN ln -sf /dev/stdout /var/log/apache2/access.log
-RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
-RUN ln -sf /dev/stderr /var/log/apache2/error.log
-
-# Configuration Apache et FPM
-ADD docker/apache-ports.conf    ${APACHE_CONF_DIR}/ports.conf
-ADD docker/apache-site.conf     ${APACHE_CONF_DIR}/sites-available/webapp.conf
-ADD docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/webapp-ssl.conf
-ADD docker/fpm/pool.d/app.conf  ${PHP_CONF_DIR}/fpm/pool.d/webapp.conf
-ADD docker/fpm/conf.d/app.ini   ${PHP_CONF_DIR}/fpm/conf.d/app.ini
-
-RUN a2ensite webapp webapp-ssl && \
-    service php7.3-fpm reload
diff --git a/docker-compose.yml b/docker-compose.yml
index 7293c02..9f570db 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,10 +2,12 @@ version: '2'
 
 services:
   skeleton-application:
+    image: skeleton-application-image
     container_name: skeleton-application-container
     build:
-      dockerfile: Dockerfile
       context: .
+      args:
+        PHP_VERSION: 7.0
     ports:
      - "8880:80"
      - "8843:443"
-- 
GitLab