Commit 781b6839 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Premier commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
.idea/

Dockerfile

0 → 100644
+26 −0
Original line number Diff line number Diff line
###########################################################################################
#
#                    Image Docker pour le web service d'import pour SyGAL.
#
###########################################################################################

ARG PHP_VERSION

FROM unicaen-dev-php${PHP_VERSION}-apache

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

# 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/

RUN a2ensite app app-ssl && \
    service php${PHP_VERSION}-fpm reload

Dockerfile.sh

0 → 100755
+55 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

#
# Script d'install d'un serveur, traduction du Dockerfile.
#

usage() {
  cat << EOF
Script d'install d'un serveur accueillant le web service d'import pour SyGAL, traduction du Dockerfile.
Usage: $0 <version de PHP>
EOF
  exit 0;
}

[[ -z "$1" ]] && usage

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

PHP_VERSION="$1"
APP_DIR=$(cd `dirname $0` && pwd)

set -e

# Minimum vital
apt-get -qq update && \
apt-get install -y \
    git \
    nano

# 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}


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

# 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

sed -i -re 's/SetEnv APPLICATION_ENV "(development|test)"/SetEnv APPLICATION_ENV "production"/' \
    ${APACHE_CONF_DIR}/sites-available/app-ssl.conf

a2ensite app app-ssl && \
    service apache2 reload && \
    service php${PHP_VERSION}-fpm reload

README.md

0 → 100644
+92 −0
Original line number Diff line number Diff line
# Image Docker pour le web service d'import pour SyGAL

## Obtention de l'image 

```bash
git clone https://git.unicaen.fr/open-source/docker/sygal-import-ws-image.git
cd sygal-import-ws-image
```

## Construction de l'image (build)

Construisez l'image pour la version de PHP désirée... 

Exemple pour PHP 7.0 :
```bash
PHP_VERSION=7.0 ; \
docker build \
--rm \
--build-arg PHP_VERSION=${PHP_VERSION} \
-t sygal-import-ws-image-php${PHP_VERSION} \
.
```

Si vous êtes derrière un proxy, passez les variables `*_proxy` à la commande `build` avec des `--build-arg` additionnels.

Exemple :
```bash
--build-arg http_proxy=http://proxy.unicaen.fr:3128 \
--build-arg https_proxy=http://proxy.unicaen.fr:3128 \
--build-arg no_proxy=*.unicaen.fr \
```

## Utilisation dans un `docker-compose.yml`

```
version: '2.2'

services:
  sygal:
    image: sygal-import-ws-image-php7.0
    container_name: sygal-import-ws-container-php7.0
    environment:
      - http_proxy
      - https_proxy
      - no_proxy
    ports:
     - "8443:443"
    volumes:
     - .:/app
    working_dir: /app
```

## Run

*Pré-requis : se placer dans le répertoire contenant les sources du web service.*

- Exemple : démarrage du container pour tester le web service en local

```bash
docker run \
--rm \
-d \
-p 8080:80 \
-p 8443:443 \
--volume ${PWD}:/app \
--name sygal-import-ws-container-php7.0 \
sygal-import-ws-image-php7.0
```

Une fois le container démarré ainsi, le web service est accessible à l'adresse `https://localhost:8443`.

- Exemple : démarrage ponctuel d'un container pour lancer un `composer install`

```bash
docker run \
--rm \
-it \
--volume ${PWD}:/app \
--workdir /app \
sygal-import-ws-image-php7.0 \
composer install
```

## Exec 

- Lancement d'une commande dans un container déjà démarré, exemple :

```bash
docker exec \
sygal-import-ws-container-php7.0 \
php -v
```
+2 −0
Original line number Diff line number Diff line
Listen 80
Listen 443
Loading