Loading CHANGELOG.md +10 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,16 @@ Journal des modifications - Passage à PHP 8.0. - Ajout d'une V3 à l'API ; les V1 et V2 demeurent. - Ajout de la colonne V_SYGAL_DOCTORANT_V2.code_apprenant_in_source contenant le numéro étudiant (API V3). - Dockerfile sans dépendance à l'image Unicaen ; traduit en Dockerfile.sh pour l'install manuelle. - Mise à jour de la doc d'installation. - Doc d'install : mention des ressources/config à copier sur le serveur avant de lancer Dockerfile.sh - Dockerfile.sh : install manuelle de xdebug 3.2.2 sinon core dump en PHP8.0 ; utilisation du fichier de log FPM par défaut. - Possibilité de spécifier la version d'API visée (ex : 'V3') dans la ligne de commande update-service-tables - install.sh : tentative de ne plus vider le cache de résultat - composer : ajout explicite d'une dépendance avec laminas-text - SQL Doctorants Apogée/Physalis : ajout de la colonne "code_apprenant_in_source" (numero étudiant). - SQL Origines de financement Apogée : données désormais puisées dans la table "origine_financement" et plus en dur. - [FIX] SQL : manquait la vue V_SYGAL_ROLE_V2 2.3.0 ----- Loading Dockerfile +176 −13 Original line number Diff line number Diff line ########################################################################################### # # Image Docker pour l'API sygal-import-ws # ########################################################################################### ARG PHP_VERSION FROM debian:bullseye AS distrib #FROM registre.unicaen.fr:5000/unicaen-dev-php${PHP_VERSION}-apache FROM unicaen-dev-php${PHP_VERSION}-apache ENV TZ="Europe/Paris" LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" # Symlink apache access and error logs to stdout/stderr so Docker logs shows them ARG PHP_VERSION ENV PHP_VERSION=${PHP_VERSION} ENV HTTP_PROXY=${http_proxy} \ HTTPS_PROXY=${https_proxy} \ NO_PROXY=${no_proxy} \ http_proxy=${http_proxy} \ https_proxy=${https_proxy} \ no_proxy=${no_proxy} RUN apt-get -qq update && \ apt-get install -y \ apache2 \ ca-certificates \ curl \ gcc \ git \ ldap-utils \ libaio1 \ libcurl4-openssl-dev \ libfreetype6-dev \ libicu-dev \ libjpeg62-turbo-dev \ libldap2-dev \ libmcrypt-dev \ libmemcached-dev \ libmemcached-tools \ libssl-dev \ libxml2-dev \ make \ memcached \ nano \ netcat-openbsd \ ssh \ ssl-cert \ unzip \ vim \ wget \ zlib1g-dev ########################################################################################### FROM composer:2.5.5 AS get-composer FROM distrib AS php ENV PHP_CONF_LOCAL_DIR=docker/configs/php \ PHP_CONF_DIR=/etc/php/${PHP_VERSION} \ FPM_PHP_LOG_FILE=/var/log/php-fpm.log # Repositories fournissant PHP 5.x, 7.x et 8.x RUN apt-get -qq update && \ apt-get -y install apt-transport-https lsb-release ca-certificates curl && \ curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg && \ sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # wget --no-check-certificate -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 \ php${PHP_VERSION}-curl \ php${PHP_VERSION}-dev \ php${PHP_VERSION}-fpm \ php${PHP_VERSION}-gd \ php${PHP_VERSION}-gettext \ php${PHP_VERSION}-iconv \ php${PHP_VERSION}-intl \ php${PHP_VERSION}-ldap \ php${PHP_VERSION}-mbstring \ php${PHP_VERSION}-memcached \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-soap \ # php${PHP_VERSION}-xdebug \ --> cf. install à part ci-après php${PHP_VERSION}-xml \ php${PHP_VERSION}-zip \ php${PHP_VERSION}-cli \ php${PHP_VERSION}-common \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-readline # Forçage de la version de PHP CLI RUN update-alternatives --set php /usr/bin/php${PHP_VERSION} # Installation manuelle de xdebug 3.2.2, car les 3.3.0/1/2 provoquent une "Segmentation fault" au 22/05/2024 (à cause de PHP 8.0 ?) RUN pecl install xdebug-3.2.2 && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/fpm/conf.d/20-xdebug.ini && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/cli/conf.d/20-xdebug.ini # Package PHP Oracle OCI8 ENV OCI8_PACKAGE="oci8-3.0.1" ADD docker/resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/ ADD docker/resources/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip /tmp/ ADD docker/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 -sf /usr/local/instantclient_18_5 /usr/local/instantclient && \ ln -sf /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 # Composer COPY --from=get-composer /usr/bin/composer /usr/local/bin/composer # Configuration PHP, php-fpm. ADD ${PHP_CONF_LOCAL_DIR}/fpm/pool.d/www.conf.part /tmp/ RUN cat /tmp/www.conf.part >> ${PHP_CONF_DIR}/fpm/pool.d/www.conf && rm /tmp/www.conf.part ADD ${PHP_CONF_LOCAL_DIR}/fpm/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/fpm/conf.d/ ADD ${PHP_CONF_LOCAL_DIR}/cli/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/cli/conf.d/ # Création du fichier pour les logs FPM (cf. fpm/pool.d/www.conf.part) RUN touch ${FPM_PHP_LOG_FILE} && \ chown www-data:www-data ${FPM_PHP_LOG_FILE} ########################################################################################### FROM php AS apache ENV APACHE_CONF_LOCAL_DIR=docker/configs/apache \ APACHE_CONF_DIR=/etc/apache2 RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \ a2dismod mpm_event && a2enmod mpm_worker ADD ${APACHE_CONF_LOCAL_DIR}/conf-available/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf RUN a2disconf security.conf && \ a2enconf security-unicaen.conf \ php${PHP_VERSION}-fpm # 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/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/ # Configuration Apache. ADD ${APACHE_CONF_LOCAL_DIR}/ports.conf ${APACHE_CONF_DIR}/ports.conf ADD ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws.conf ADD ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws-ssl.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf RUN a2ensite sygal-import-ws sygal-import-ws-ssl ########################################################################################### FROM apache AS bootstrap # Nettoyage RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* # Copie les fichiers situés dans ./docker/entrypoint.d dans le dossier /entrypoint.d de l'image. # Les scripts exécutables parmi eux seront exécutés au démarrage du container (cf. entrypoint.sh). # Attention : les noms de fichiers ne doivent être constitués que de lettres minuscules ou majuscules, # de chiffres, de tirets bas (underscore) ou de tirets ; extension interdite, donc. #ADD docker/entrypoint.d/* /entrypoint.d/ ## Copie des scripts complémentaires à lancer au démarrage du container. COPY docker/entrypoint.d/* /entrypoint.d/ # Entry point ADD docker/entrypoint.sh /sbin/entrypoint.sh RUN chmod 755 /sbin/entrypoint.sh CMD ["/sbin/entrypoint.sh"] RUN a2ensite app app-ssl && \ service php${PHP_VERSION}-fpm reload COPY . /app WORKDIR /app RUN composer install --no-dev --no-suggest --prefer-dist --optimize-autoloader RUN composer install --prefer-dist --optimize-autoloader --no-interaction RUN vendor/bin/laminas-development-mode disable Dockerfile.sh 100755 → 100644 +199 −38 Original line number Diff line number Diff line #!/usr/bin/env bash #!/bin/bash ######################################################################################################### # # Script d'install d'un serveur, traduction du Dockerfile. # Image Docker pour l'API sygal-import-ws # traduite en script bash, pour configurer manuellement un serveur Debian # # Pré-requis : # - Etre root sur le serveur # - Avoir récupéré les sources de l'application et être positionné dans leur répertoire # - Avoir copié le répertoire ./docker dans le répertoire /tmp du serveur : cp -r ./docker /tmp/ # ######################################################################################################### #FROM debian:bullseye AS distrib usage() { cat << EOF Script d'install d'un serveur, traduction du Dockerfile. Usage: $0 <version de PHP> EOF exit 0; } #ENV TZ="Europe/Paris" [[ -z "$1" ]] && usage #LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" ################################################################################################################ #ARG PHP_VERSION PHP_VERSION="$1" APP_DIR=$(cd `dirname $0` && pwd) export PHP_VERSION=8.0 set -e #ENV HTTP_PROXY=${http_proxy} \ # HTTPS_PROXY=${https_proxy} \ # NO_PROXY=${no_proxy} \ # http_proxy=${http_proxy} \ # https_proxy=${https_proxy} \ # no_proxy=${no_proxy} # Minimum vital apt-get -qq update && \ apt-get install -y \ apache2 \ ca-certificates \ curl \ gcc \ git \ nano ldap-utils \ libaio1 \ libcurl4-openssl-dev \ libfreetype6-dev \ libicu-dev \ libjpeg62-turbo-dev \ libldap2-dev \ libmcrypt-dev \ libmemcached-dev \ libmemcached-tools \ libssl-dev \ libxml2-dev \ make \ memcached \ nano \ netcat-openbsd \ ssh \ ssl-cert \ unzip \ vim \ wget \ zlib1g-dev ########################################################################################### #FROM composer:2.5.5 AS get-composer #FROM distrib AS php export PHP_CONF_LOCAL_DIR=/tmp/docker/configs/php \ PHP_CONF_DIR=/etc/php/${PHP_VERSION} #\ # FPM_PHP_LOG_FILE=/var/log/php-fpm.log # Repositories fournissant PHP 5.x, 7.x et 8.x apt-get -qq update && \ apt-get -y install apt-transport-https lsb-release ca-certificates curl && \ curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg && \ sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # wget --no-check-certificate -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 apt-get -qq update && \ apt-get install -y \ php-pear \ php${PHP_VERSION} \ php${PHP_VERSION}-bcmath \ php${PHP_VERSION}-curl \ php${PHP_VERSION}-dev \ php${PHP_VERSION}-fpm \ php${PHP_VERSION}-gd \ php${PHP_VERSION}-gettext \ php${PHP_VERSION}-iconv \ php${PHP_VERSION}-intl \ php${PHP_VERSION}-ldap \ php${PHP_VERSION}-mbstring \ php${PHP_VERSION}-memcached \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-soap \ # php${PHP_VERSION}-xdebug \ --> cf. install à part ci-après php${PHP_VERSION}-xml \ php${PHP_VERSION}-zip \ php${PHP_VERSION}-cli \ php${PHP_VERSION}-common \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-readline # Forçage de la version de PHP CLI update-alternatives --set php /usr/bin/php${PHP_VERSION} # Installation manuelle de xdebug 3.2.2, car les 3.3.0/1/2 provoquent une "Segmentation fault" au 22/05/2024 (à cause de PHP 8.0 ?) pecl install xdebug-3.2.2 && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/fpm/conf.d/20-xdebug.ini && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/cli/conf.d/20-xdebug.ini # Package PHP Oracle OCI8 export OCI8_PACKAGE="oci8-3.0.1" cp /tmp/docker/resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/ cp /tmp/docker/resources/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip /tmp/ cp /tmp/docker/resources/instantclient-sqlplus-linux.x64-18.5.0.0.0dbru.zip /tmp/ 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 -sf /usr/local/instantclient_18_5 /usr/local/instantclient && \ ln -sf /usr/local/instantclient/sqlplus /usr/bin/sqlplus && \ echo 'instantclient,/usr/local/instantclient' | pecl install ${OCI8_PACKAGE} && \ sh -c "echo 'extension=oci8.so' > ${PHP_CONF_DIR}/fpm/conf.d/30-php-oci8.ini" && \ sh -c "echo 'extension=oci8.so' > ${PHP_CONF_DIR}/cli/conf.d/30-php-oci8.ini" && \ sh -c "echo '/usr/local/instantclient' > /etc/ld.so.conf.d/oracle-instantclient.conf" && ldconfig # Composer #COPY --from=get-composer /usr/bin/composer /usr/local/bin/composer EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] then >&2 echo 'ERROR: Invalid installer checksum' rm composer-setup.php exit 1 fi php composer-setup.php --quiet RESULT=$? rm composer-setup.php mv composer.phar /usr/local/bin/composer # Configuration PHP, php-fpm. #cp ${PHP_CONF_LOCAL_DIR}/fpm/pool.d/www.conf.part /tmp/ #cat /tmp/www.conf.part >> ${PHP_CONF_DIR}/fpm/pool.d/www.conf && rm /tmp/www.conf.part cp ${PHP_CONF_LOCAL_DIR}/fpm/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/fpm/conf.d/ cp ${PHP_CONF_LOCAL_DIR}/cli/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/cli/conf.d/ ## Création du fichier pour les logs FPM (cf. fpm/pool.d/www.conf.part) #touch ${FPM_PHP_LOG_FILE} && \ # chown www-data:www-data ${FPM_PHP_LOG_FILE} ########################################################################################### #FROM php AS apache export APACHE_CONF_LOCAL_DIR=/tmp/docker/configs/apache \ APACHE_CONF_DIR=/etc/apache2 a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \ a2dismod mpm_event && a2enmod mpm_worker cp ${APACHE_CONF_LOCAL_DIR}/conf-available/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf a2disconf security.conf && \ a2enconf security-unicaen.conf \ php${PHP_VERSION}-fpm # 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. cp ${APACHE_CONF_LOCAL_DIR}/ports.conf ${APACHE_CONF_DIR}/ports.conf cp ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws.conf cp ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws-ssl.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf #sed -i -re 's/SetEnv APPLICATION_ENV "(development|test)"/SetEnv APPLICATION_ENV "production"/' \ # ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf a2ensite sygal-import-ws sygal-import-ws-ssl ########################################################################################### #FROM apache AS bootstrap # Nettoyage #RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* # Récupération de l'image Docker Unicaen et lancement de son Dockerfile.sh export UNICAEN_IMAGE_TMP_DIR=/tmp/docker-unicaen-image git clone https://git.unicaen.fr/open-source/docker/unicaen-image.git ${UNICAEN_IMAGE_TMP_DIR} cd ${UNICAEN_IMAGE_TMP_DIR} . Dockerfile.sh ${PHP_VERSION} # Copie les fichiers situés dans ./docker/entrypoint.d dans le dossier /entrypoint.d de l'image. # Les scripts exécutables parmi eux seront exécutés au démarrage du container (cf. entrypoint.sh). # Attention : les noms de fichiers ne doivent être constitués que de lettres minuscules ou majuscules, # de chiffres, de tirets bas (underscore) ou de tirets ; extension interdite, donc. #ADD docker/entrypoint.d/* /entrypoint.d/ ## Copie des scripts complémentaires à lancer au démarrage du container. #COPY docker/entrypoint.d/* /entrypoint.d/ # Entry point #ADD docker/entrypoint.sh /sbin/entrypoint.sh #RUN chmod 755 /sbin/entrypoint.sh #CMD ["/sbin/entrypoint.sh"] service php${PHP_VERSION}-fpm start service apache2 restart cd ${APP_DIR} # NB: Variables d'env positionnées par ${UNICAEN_IMAGE_TMP_DIR}/Dockerfile.sh # APACHE_CONF_DIR=/etc/apache2 \ # PHP_CONF_DIR=/etc/php/$1 #COPY . /app # Configuration Apache et FPM cp docker/apache-ports.conf ${APACHE_CONF_DIR}/ports.conf cp docker/apache-site.conf ${APACHE_CONF_DIR}/sites-available/app.conf cp docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/app-ssl.conf cp docker/fpm/pool.d/app.conf ${PHP_CONF_DIR}/fpm/pool.d/app.conf cp docker/fpm/conf.d/app.ini ${PHP_CONF_DIR}/fpm/conf.d/90-app.ini #WORKDIR /app sed -i -re 's/SetEnv APPLICATION_ENV "(development|test)"/SetEnv APPLICATION_ENV "production"/' \ ${APACHE_CONF_DIR}/sites-available/app-ssl.conf composer install --prefer-dist --optimize-autoloader --no-interaction a2ensite app app-ssl && \ service apache2 reload && \ service php${PHP_VERSION}-fpm reload vendor/bin/laminas-development-mode disable INSTALL.md +1 −186 File changed.Preview size limit exceeded, changes collapsed. Show changes README.md +13 −31 Original line number Diff line number Diff line sygal-import-ws =============== Que fait *sygal-import-ws* ? ---------------------------- *sygal-import-ws* est une API REST qui retourne les données présentes dans des tables `SyGAL_*` *sygal-import-ws* est une API REST qui retourne les données présentes dans des tables `SYGAL_*` d'Apogée ou de Physalis via des requêtes GET. Docker ------ - Obtention de l'image de base Unicaen (construite) à jour Installation ------------ ```bash PHP_VERSION=8.0 \ docker pull registre.unicaen.fr:5000/unicaen-dev-php${PHP_VERSION}-apache ``` Cf. [`INSTALL.md`](INSTALL.md). - Construction de l'image du web service Lancement du web service *pour le dévelopement* ----------------------------------------------- - Construction de l'image ```bash PHP_VERSION=8.0 \ Loading @@ -30,29 +27,13 @@ docker build \ . ``` - Lancement du web service - Démarrage du container : ```bash docker-compose up sygal-import-ws ``` Installation ------------ Cf. [`INSTALL.md`](INSTALL.md). Lancement du web service *pour le dévelopement* ----------------------------------------------- Se placer à la racine des sources du ws pour lancer la commande suivante : ```bash docker-compose up --build sygal-import-ws ``` Vérifier que le container `sygal-import-ws-container-php8.0` figure bien dans la liste des containers - Vérifier que le container `sygal-import-ws-container-php8.0` figure bien dans la liste des containers lancés listés par la commande suivante (cf. colonne `NAMES`) : ```bash Loading Loading @@ -83,7 +64,8 @@ Chaque vue en base de données peut être interrogée via un service dédié : - `/titre-acces` - `/variable` Il y a aussi un service `/version` () permettant de connaître le numéro de version du web service (ex : '2.3.0'). Autres services : - `/version` : permet de connaître le numéro de version du web service (ex : '2.3.0') Versionning de l'API Loading Loading
CHANGELOG.md +10 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,16 @@ Journal des modifications - Passage à PHP 8.0. - Ajout d'une V3 à l'API ; les V1 et V2 demeurent. - Ajout de la colonne V_SYGAL_DOCTORANT_V2.code_apprenant_in_source contenant le numéro étudiant (API V3). - Dockerfile sans dépendance à l'image Unicaen ; traduit en Dockerfile.sh pour l'install manuelle. - Mise à jour de la doc d'installation. - Doc d'install : mention des ressources/config à copier sur le serveur avant de lancer Dockerfile.sh - Dockerfile.sh : install manuelle de xdebug 3.2.2 sinon core dump en PHP8.0 ; utilisation du fichier de log FPM par défaut. - Possibilité de spécifier la version d'API visée (ex : 'V3') dans la ligne de commande update-service-tables - install.sh : tentative de ne plus vider le cache de résultat - composer : ajout explicite d'une dépendance avec laminas-text - SQL Doctorants Apogée/Physalis : ajout de la colonne "code_apprenant_in_source" (numero étudiant). - SQL Origines de financement Apogée : données désormais puisées dans la table "origine_financement" et plus en dur. - [FIX] SQL : manquait la vue V_SYGAL_ROLE_V2 2.3.0 ----- Loading
Dockerfile +176 −13 Original line number Diff line number Diff line ########################################################################################### # # Image Docker pour l'API sygal-import-ws # ########################################################################################### ARG PHP_VERSION FROM debian:bullseye AS distrib #FROM registre.unicaen.fr:5000/unicaen-dev-php${PHP_VERSION}-apache FROM unicaen-dev-php${PHP_VERSION}-apache ENV TZ="Europe/Paris" LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" # Symlink apache access and error logs to stdout/stderr so Docker logs shows them ARG PHP_VERSION ENV PHP_VERSION=${PHP_VERSION} ENV HTTP_PROXY=${http_proxy} \ HTTPS_PROXY=${https_proxy} \ NO_PROXY=${no_proxy} \ http_proxy=${http_proxy} \ https_proxy=${https_proxy} \ no_proxy=${no_proxy} RUN apt-get -qq update && \ apt-get install -y \ apache2 \ ca-certificates \ curl \ gcc \ git \ ldap-utils \ libaio1 \ libcurl4-openssl-dev \ libfreetype6-dev \ libicu-dev \ libjpeg62-turbo-dev \ libldap2-dev \ libmcrypt-dev \ libmemcached-dev \ libmemcached-tools \ libssl-dev \ libxml2-dev \ make \ memcached \ nano \ netcat-openbsd \ ssh \ ssl-cert \ unzip \ vim \ wget \ zlib1g-dev ########################################################################################### FROM composer:2.5.5 AS get-composer FROM distrib AS php ENV PHP_CONF_LOCAL_DIR=docker/configs/php \ PHP_CONF_DIR=/etc/php/${PHP_VERSION} \ FPM_PHP_LOG_FILE=/var/log/php-fpm.log # Repositories fournissant PHP 5.x, 7.x et 8.x RUN apt-get -qq update && \ apt-get -y install apt-transport-https lsb-release ca-certificates curl && \ curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg && \ sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # wget --no-check-certificate -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 \ php${PHP_VERSION}-curl \ php${PHP_VERSION}-dev \ php${PHP_VERSION}-fpm \ php${PHP_VERSION}-gd \ php${PHP_VERSION}-gettext \ php${PHP_VERSION}-iconv \ php${PHP_VERSION}-intl \ php${PHP_VERSION}-ldap \ php${PHP_VERSION}-mbstring \ php${PHP_VERSION}-memcached \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-soap \ # php${PHP_VERSION}-xdebug \ --> cf. install à part ci-après php${PHP_VERSION}-xml \ php${PHP_VERSION}-zip \ php${PHP_VERSION}-cli \ php${PHP_VERSION}-common \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-readline # Forçage de la version de PHP CLI RUN update-alternatives --set php /usr/bin/php${PHP_VERSION} # Installation manuelle de xdebug 3.2.2, car les 3.3.0/1/2 provoquent une "Segmentation fault" au 22/05/2024 (à cause de PHP 8.0 ?) RUN pecl install xdebug-3.2.2 && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/fpm/conf.d/20-xdebug.ini && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/cli/conf.d/20-xdebug.ini # Package PHP Oracle OCI8 ENV OCI8_PACKAGE="oci8-3.0.1" ADD docker/resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/ ADD docker/resources/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip /tmp/ ADD docker/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 -sf /usr/local/instantclient_18_5 /usr/local/instantclient && \ ln -sf /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 # Composer COPY --from=get-composer /usr/bin/composer /usr/local/bin/composer # Configuration PHP, php-fpm. ADD ${PHP_CONF_LOCAL_DIR}/fpm/pool.d/www.conf.part /tmp/ RUN cat /tmp/www.conf.part >> ${PHP_CONF_DIR}/fpm/pool.d/www.conf && rm /tmp/www.conf.part ADD ${PHP_CONF_LOCAL_DIR}/fpm/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/fpm/conf.d/ ADD ${PHP_CONF_LOCAL_DIR}/cli/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/cli/conf.d/ # Création du fichier pour les logs FPM (cf. fpm/pool.d/www.conf.part) RUN touch ${FPM_PHP_LOG_FILE} && \ chown www-data:www-data ${FPM_PHP_LOG_FILE} ########################################################################################### FROM php AS apache ENV APACHE_CONF_LOCAL_DIR=docker/configs/apache \ APACHE_CONF_DIR=/etc/apache2 RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \ a2dismod mpm_event && a2enmod mpm_worker ADD ${APACHE_CONF_LOCAL_DIR}/conf-available/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf RUN a2disconf security.conf && \ a2enconf security-unicaen.conf \ php${PHP_VERSION}-fpm # 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/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/ # Configuration Apache. ADD ${APACHE_CONF_LOCAL_DIR}/ports.conf ${APACHE_CONF_DIR}/ports.conf ADD ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws.conf ADD ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws-ssl.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf RUN a2ensite sygal-import-ws sygal-import-ws-ssl ########################################################################################### FROM apache AS bootstrap # Nettoyage RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* # Copie les fichiers situés dans ./docker/entrypoint.d dans le dossier /entrypoint.d de l'image. # Les scripts exécutables parmi eux seront exécutés au démarrage du container (cf. entrypoint.sh). # Attention : les noms de fichiers ne doivent être constitués que de lettres minuscules ou majuscules, # de chiffres, de tirets bas (underscore) ou de tirets ; extension interdite, donc. #ADD docker/entrypoint.d/* /entrypoint.d/ ## Copie des scripts complémentaires à lancer au démarrage du container. COPY docker/entrypoint.d/* /entrypoint.d/ # Entry point ADD docker/entrypoint.sh /sbin/entrypoint.sh RUN chmod 755 /sbin/entrypoint.sh CMD ["/sbin/entrypoint.sh"] RUN a2ensite app app-ssl && \ service php${PHP_VERSION}-fpm reload COPY . /app WORKDIR /app RUN composer install --no-dev --no-suggest --prefer-dist --optimize-autoloader RUN composer install --prefer-dist --optimize-autoloader --no-interaction RUN vendor/bin/laminas-development-mode disable
Dockerfile.sh 100755 → 100644 +199 −38 Original line number Diff line number Diff line #!/usr/bin/env bash #!/bin/bash ######################################################################################################### # # Script d'install d'un serveur, traduction du Dockerfile. # Image Docker pour l'API sygal-import-ws # traduite en script bash, pour configurer manuellement un serveur Debian # # Pré-requis : # - Etre root sur le serveur # - Avoir récupéré les sources de l'application et être positionné dans leur répertoire # - Avoir copié le répertoire ./docker dans le répertoire /tmp du serveur : cp -r ./docker /tmp/ # ######################################################################################################### #FROM debian:bullseye AS distrib usage() { cat << EOF Script d'install d'un serveur, traduction du Dockerfile. Usage: $0 <version de PHP> EOF exit 0; } #ENV TZ="Europe/Paris" [[ -z "$1" ]] && usage #LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" ################################################################################################################ #ARG PHP_VERSION PHP_VERSION="$1" APP_DIR=$(cd `dirname $0` && pwd) export PHP_VERSION=8.0 set -e #ENV HTTP_PROXY=${http_proxy} \ # HTTPS_PROXY=${https_proxy} \ # NO_PROXY=${no_proxy} \ # http_proxy=${http_proxy} \ # https_proxy=${https_proxy} \ # no_proxy=${no_proxy} # Minimum vital apt-get -qq update && \ apt-get install -y \ apache2 \ ca-certificates \ curl \ gcc \ git \ nano ldap-utils \ libaio1 \ libcurl4-openssl-dev \ libfreetype6-dev \ libicu-dev \ libjpeg62-turbo-dev \ libldap2-dev \ libmcrypt-dev \ libmemcached-dev \ libmemcached-tools \ libssl-dev \ libxml2-dev \ make \ memcached \ nano \ netcat-openbsd \ ssh \ ssl-cert \ unzip \ vim \ wget \ zlib1g-dev ########################################################################################### #FROM composer:2.5.5 AS get-composer #FROM distrib AS php export PHP_CONF_LOCAL_DIR=/tmp/docker/configs/php \ PHP_CONF_DIR=/etc/php/${PHP_VERSION} #\ # FPM_PHP_LOG_FILE=/var/log/php-fpm.log # Repositories fournissant PHP 5.x, 7.x et 8.x apt-get -qq update && \ apt-get -y install apt-transport-https lsb-release ca-certificates curl && \ curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg && \ sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # wget --no-check-certificate -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 apt-get -qq update && \ apt-get install -y \ php-pear \ php${PHP_VERSION} \ php${PHP_VERSION}-bcmath \ php${PHP_VERSION}-curl \ php${PHP_VERSION}-dev \ php${PHP_VERSION}-fpm \ php${PHP_VERSION}-gd \ php${PHP_VERSION}-gettext \ php${PHP_VERSION}-iconv \ php${PHP_VERSION}-intl \ php${PHP_VERSION}-ldap \ php${PHP_VERSION}-mbstring \ php${PHP_VERSION}-memcached \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-soap \ # php${PHP_VERSION}-xdebug \ --> cf. install à part ci-après php${PHP_VERSION}-xml \ php${PHP_VERSION}-zip \ php${PHP_VERSION}-cli \ php${PHP_VERSION}-common \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-readline # Forçage de la version de PHP CLI update-alternatives --set php /usr/bin/php${PHP_VERSION} # Installation manuelle de xdebug 3.2.2, car les 3.3.0/1/2 provoquent une "Segmentation fault" au 22/05/2024 (à cause de PHP 8.0 ?) pecl install xdebug-3.2.2 && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/fpm/conf.d/20-xdebug.ini && \ echo "zend_extension=xdebug" > ${PHP_CONF_DIR}/cli/conf.d/20-xdebug.ini # Package PHP Oracle OCI8 export OCI8_PACKAGE="oci8-3.0.1" cp /tmp/docker/resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/ cp /tmp/docker/resources/instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip /tmp/ cp /tmp/docker/resources/instantclient-sqlplus-linux.x64-18.5.0.0.0dbru.zip /tmp/ 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 -sf /usr/local/instantclient_18_5 /usr/local/instantclient && \ ln -sf /usr/local/instantclient/sqlplus /usr/bin/sqlplus && \ echo 'instantclient,/usr/local/instantclient' | pecl install ${OCI8_PACKAGE} && \ sh -c "echo 'extension=oci8.so' > ${PHP_CONF_DIR}/fpm/conf.d/30-php-oci8.ini" && \ sh -c "echo 'extension=oci8.so' > ${PHP_CONF_DIR}/cli/conf.d/30-php-oci8.ini" && \ sh -c "echo '/usr/local/instantclient' > /etc/ld.so.conf.d/oracle-instantclient.conf" && ldconfig # Composer #COPY --from=get-composer /usr/bin/composer /usr/local/bin/composer EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] then >&2 echo 'ERROR: Invalid installer checksum' rm composer-setup.php exit 1 fi php composer-setup.php --quiet RESULT=$? rm composer-setup.php mv composer.phar /usr/local/bin/composer # Configuration PHP, php-fpm. #cp ${PHP_CONF_LOCAL_DIR}/fpm/pool.d/www.conf.part /tmp/ #cat /tmp/www.conf.part >> ${PHP_CONF_DIR}/fpm/pool.d/www.conf && rm /tmp/www.conf.part cp ${PHP_CONF_LOCAL_DIR}/fpm/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/fpm/conf.d/ cp ${PHP_CONF_LOCAL_DIR}/cli/conf.d/99-sygal-import-ws.ini ${PHP_CONF_DIR}/cli/conf.d/ ## Création du fichier pour les logs FPM (cf. fpm/pool.d/www.conf.part) #touch ${FPM_PHP_LOG_FILE} && \ # chown www-data:www-data ${FPM_PHP_LOG_FILE} ########################################################################################### #FROM php AS apache export APACHE_CONF_LOCAL_DIR=/tmp/docker/configs/apache \ APACHE_CONF_DIR=/etc/apache2 a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \ a2dismod mpm_event && a2enmod mpm_worker cp ${APACHE_CONF_LOCAL_DIR}/conf-available/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf a2disconf security.conf && \ a2enconf security-unicaen.conf \ php${PHP_VERSION}-fpm # 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. cp ${APACHE_CONF_LOCAL_DIR}/ports.conf ${APACHE_CONF_DIR}/ports.conf cp ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws.conf cp ${APACHE_CONF_LOCAL_DIR}/sygal-import-ws-ssl.conf ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf #sed -i -re 's/SetEnv APPLICATION_ENV "(development|test)"/SetEnv APPLICATION_ENV "production"/' \ # ${APACHE_CONF_DIR}/sites-available/sygal-import-ws-ssl.conf a2ensite sygal-import-ws sygal-import-ws-ssl ########################################################################################### #FROM apache AS bootstrap # Nettoyage #RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* # Récupération de l'image Docker Unicaen et lancement de son Dockerfile.sh export UNICAEN_IMAGE_TMP_DIR=/tmp/docker-unicaen-image git clone https://git.unicaen.fr/open-source/docker/unicaen-image.git ${UNICAEN_IMAGE_TMP_DIR} cd ${UNICAEN_IMAGE_TMP_DIR} . Dockerfile.sh ${PHP_VERSION} # Copie les fichiers situés dans ./docker/entrypoint.d dans le dossier /entrypoint.d de l'image. # Les scripts exécutables parmi eux seront exécutés au démarrage du container (cf. entrypoint.sh). # Attention : les noms de fichiers ne doivent être constitués que de lettres minuscules ou majuscules, # de chiffres, de tirets bas (underscore) ou de tirets ; extension interdite, donc. #ADD docker/entrypoint.d/* /entrypoint.d/ ## Copie des scripts complémentaires à lancer au démarrage du container. #COPY docker/entrypoint.d/* /entrypoint.d/ # Entry point #ADD docker/entrypoint.sh /sbin/entrypoint.sh #RUN chmod 755 /sbin/entrypoint.sh #CMD ["/sbin/entrypoint.sh"] service php${PHP_VERSION}-fpm start service apache2 restart cd ${APP_DIR} # NB: Variables d'env positionnées par ${UNICAEN_IMAGE_TMP_DIR}/Dockerfile.sh # APACHE_CONF_DIR=/etc/apache2 \ # PHP_CONF_DIR=/etc/php/$1 #COPY . /app # Configuration Apache et FPM cp docker/apache-ports.conf ${APACHE_CONF_DIR}/ports.conf cp docker/apache-site.conf ${APACHE_CONF_DIR}/sites-available/app.conf cp docker/apache-site-ssl.conf ${APACHE_CONF_DIR}/sites-available/app-ssl.conf cp docker/fpm/pool.d/app.conf ${PHP_CONF_DIR}/fpm/pool.d/app.conf cp docker/fpm/conf.d/app.ini ${PHP_CONF_DIR}/fpm/conf.d/90-app.ini #WORKDIR /app sed -i -re 's/SetEnv APPLICATION_ENV "(development|test)"/SetEnv APPLICATION_ENV "production"/' \ ${APACHE_CONF_DIR}/sites-available/app-ssl.conf composer install --prefer-dist --optimize-autoloader --no-interaction a2ensite app app-ssl && \ service apache2 reload && \ service php${PHP_VERSION}-fpm reload vendor/bin/laminas-development-mode disable
README.md +13 −31 Original line number Diff line number Diff line sygal-import-ws =============== Que fait *sygal-import-ws* ? ---------------------------- *sygal-import-ws* est une API REST qui retourne les données présentes dans des tables `SyGAL_*` *sygal-import-ws* est une API REST qui retourne les données présentes dans des tables `SYGAL_*` d'Apogée ou de Physalis via des requêtes GET. Docker ------ - Obtention de l'image de base Unicaen (construite) à jour Installation ------------ ```bash PHP_VERSION=8.0 \ docker pull registre.unicaen.fr:5000/unicaen-dev-php${PHP_VERSION}-apache ``` Cf. [`INSTALL.md`](INSTALL.md). - Construction de l'image du web service Lancement du web service *pour le dévelopement* ----------------------------------------------- - Construction de l'image ```bash PHP_VERSION=8.0 \ Loading @@ -30,29 +27,13 @@ docker build \ . ``` - Lancement du web service - Démarrage du container : ```bash docker-compose up sygal-import-ws ``` Installation ------------ Cf. [`INSTALL.md`](INSTALL.md). Lancement du web service *pour le dévelopement* ----------------------------------------------- Se placer à la racine des sources du ws pour lancer la commande suivante : ```bash docker-compose up --build sygal-import-ws ``` Vérifier que le container `sygal-import-ws-container-php8.0` figure bien dans la liste des containers - Vérifier que le container `sygal-import-ws-container-php8.0` figure bien dans la liste des containers lancés listés par la commande suivante (cf. colonne `NAMES`) : ```bash Loading Loading @@ -83,7 +64,8 @@ Chaque vue en base de données peut être interrogée via un service dédié : - `/titre-acces` - `/variable` Il y a aussi un service `/version` () permettant de connaître le numéro de version du web service (ex : '2.3.0'). Autres services : - `/version` : permet de connaître le numéro de version du web service (ex : '2.3.0') Versionning de l'API Loading