Merge branch 'docker' into 'develop'
Introduce Docker Image See merge request framasoft/framadate!314
This commit is contained in:
commit
19bec88184
40
docker-compose.yml
Normal file
40
docker-compose.yml
Normal file
@ -0,0 +1,40 @@
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
container_name: framadate-db
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=rootpassword
|
||||
- MYSQL_USER=framadate
|
||||
- MYSQL_PASSWORD=framadatedbpassword
|
||||
- MYSQL_DATABASE=framadate
|
||||
restart: always
|
||||
ports:
|
||||
- "3307:3306"
|
||||
|
||||
framadate:
|
||||
container_name: framadate
|
||||
build:
|
||||
dockerfile: ./docker/stretch/Dockerfile
|
||||
context: .
|
||||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
- ENV=dev
|
||||
- DOMAIN=localhost
|
||||
- APP_NAME=Framadate
|
||||
- ADMIN_MAIL=mon@email.fr
|
||||
- MYSQL_USER=framadate
|
||||
- MYSQL_PASSWORD=framadatedbpassword
|
||||
- MYSQL_DB=framadate
|
||||
- MYSQL_HOST=db
|
||||
- MYSQL_PORT=3307
|
||||
- ADMIN_USER=admin
|
||||
- ADMIN_PASSWORD=adminpassword
|
||||
- DISABLE_SMTP=true
|
||||
- APACHE_RUN_USER=#1000
|
||||
restart: always
|
||||
volumes:
|
||||
- '.:/var/www/framadate'
|
30
docker/stretch/Dockerfile
Normal file
30
docker/stretch/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
FROM php:apache
|
||||
|
||||
MAINTAINER kyane@kyane.fr
|
||||
|
||||
RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq zip unzip git zlib1g-dev libicu-dev g++ mysql-client
|
||||
RUN docker-php-ext-install intl && docker-php-ext-install pdo_mysql
|
||||
|
||||
RUN a2enmod rewrite
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
COPY docker/stretch/php.ini /usr/local/etc/php/php.ini
|
||||
COPY docker/stretch/apache-framadate.conf /etc/apache2/sites-enabled/framadate.conf
|
||||
COPY docker/stretch/entrypoint.sh /usr/local/bin/entrypoint
|
||||
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
RUN set -eux; \
|
||||
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
|
||||
composer clear-cache
|
||||
ENV PATH="${PATH}:/root/.composer/vendor/bin"
|
||||
ENV COMPOSER_ALLOW_SUPERUSER 0
|
||||
|
||||
WORKDIR /var/www/framadate
|
||||
|
||||
# Some Apache and PHP configuration
|
||||
RUN if [ "$ENV" = "dev" ] ; then echo Using PHP production mode ; else echo Using PHP development mode && echo "error_reporting = E_ERROR | E_WARNING | E_PARSE\ndisplay_errors = On" > /usr/local/etc/php/conf.d/php.ini ; fi
|
||||
|
||||
RUN rm /etc/apache2/sites-enabled/000-default.conf
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["entrypoint"]
|
37
docker/stretch/README.md
Normal file
37
docker/stretch/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Framadate
|
||||
**Cette image est en phase de test. NE PAS UTILISER EN PRODUCTION**
|
||||
|
||||
Image Docker pour le déploiement de Framadate
|
||||
|
||||
## Configuration
|
||||
### Base de données
|
||||
Pour fonctionner, Framadate a besoin d'une base de données. Dans notre cas nous utilisons MySQL, que l'on déploie avec Docker. Afin que Framadate fonctionne correctement, nous devons désactiver le *SQL MODE* `NO_ZERO_DATE` de MySQL. On peut donc déployer une base de données pour Framadate ainsi (avec Docker Compose):
|
||||
```
|
||||
framadate-db:
|
||||
image: mysql:5.7
|
||||
container_name: framadate-db
|
||||
command: --sql-mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
|
||||
volumes:
|
||||
- /path/to/data/volume:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=myrootpassword
|
||||
- MYSQL_USER=framadate
|
||||
- MYSQL_PASSWORD=myframadatepassword
|
||||
- MYSQL_DATABASE=framadate
|
||||
restart: always
|
||||
```
|
||||
|
||||
### Framadate
|
||||
Pour initialiser Framadate, on utilise plusieurs variables d'environnement :
|
||||
- `DOMAIN`: sous domaine du serveur Framadate (ex: `framadate.picasoft.net`)
|
||||
- `APP_NAME`: nom de l'application (`Framadate` par défaut)
|
||||
- `ADMIN_MAIL`: adresse mail de l'administrateur du serveur
|
||||
- `NO_REPLY_MAIL`: adresse mail qui servira à l'envoi des mails
|
||||
- `MYSQL_USER`: utilisateur MySQL
|
||||
- `MYSQL_PASSWORD`: mot de passe de l'utilisateur MySQL
|
||||
- `MYSQL_DB`: nom de la base de données
|
||||
- `MYSQL_HOST`: adresse du serveur de base de données
|
||||
- `MYSQL_PORT`: port du serveur MySQL (`3306` par défaut)
|
||||
- `ADMIN_USER`: utilisateur de l'interface d'administration
|
||||
- `ADMIN_PASSWORD`: mot de passe de l'interface d'administration
|
||||
- `DISABLE_SMTP`: mettre à `true` pour désactiver SMTP (sinon `false` par défaut)
|
28
docker/stretch/apache-framadate.conf
Normal file
28
docker/stretch/apache-framadate.conf
Normal file
@ -0,0 +1,28 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/framadate
|
||||
|
||||
# URL rewrite
|
||||
<Directory "/">
|
||||
AllowOverride All
|
||||
</Directory>
|
||||
|
||||
# Admin folder
|
||||
<Directory "/var/www/framadate/admin/">
|
||||
AuthType Basic
|
||||
AuthName "Administration"
|
||||
AuthUserFile "/var/www/framadate/admin/.htpasswd"
|
||||
Require valid-user
|
||||
</Directory>
|
||||
|
||||
# Protection fichiers htpasswd et htaccess
|
||||
<FilesMatch "^\.ht.*">
|
||||
Deny from all
|
||||
Satisfy all
|
||||
ErrorDocument 403 "Accès refusé."
|
||||
</FilesMatch>
|
||||
|
||||
# Logs
|
||||
ErrorLog /dev/stdout
|
||||
CustomLog /dev/stdout combined
|
||||
|
||||
</VirtualHost>
|
86
docker/stretch/entrypoint.sh
Executable file
86
docker/stretch/entrypoint.sh
Executable file
@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read environment variables or set default values
|
||||
FRAMADATE_CONFIG=${FRAMADATE_CONFIG:-/var/www/framadate/app/inc/config.php}
|
||||
DOMAIN=${DOMAIN-localhost}
|
||||
APP_NAME=${APP_NAME-Framadate}
|
||||
ADMIN_MAIL=${ADMIN_MAIL-}
|
||||
NO_REPLY_MAIL=${NO_REPLY_MAIL-}
|
||||
MYSQL_USER=${MYSQL_USER-user}
|
||||
MYSQL_PASSWORD=${MYSQL_PASSWORD-password}
|
||||
MYSQL_DB=${MYSQL_DB-framadate}
|
||||
MYSQL_HOST=${MYSQL_HOST-mysql}
|
||||
MYSQL_PORT=${MYSQL_PORT-3306}
|
||||
DISABLE_SMTP=${DISABLE_SMTP-false}
|
||||
|
||||
# Add configuration file if not exist
|
||||
if [ ! -f $FRAMADATE_CONFIG ]; then
|
||||
echo "There is no configuration file. Create one with environment variables"
|
||||
cp /var/www/framadate/tpl/admin/config.tpl $FRAMADATE_CONFIG
|
||||
# Set values on configuration file
|
||||
if [ ! -z "$DOMAIN" ]; then
|
||||
sed -i -E "s/^(\/\/ )?const APP_URL( )?=.*;/const APP_URL = '$DOMAIN';/g" $FRAMADATE_CONFIG
|
||||
fi
|
||||
sed -i -E "s/^(\/\/ )?const NOMAPPLICATION( )?=.*;/const NOMAPPLICATION = '$APP_NAME';/g" $FRAMADATE_CONFIG
|
||||
# Configure mail
|
||||
sed -i -E "s/^(\/\/ )?const ADRESSEMAILADMIN( )?=.*;/const ADRESSEMAILADMIN = '$ADMIN_MAIL';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const ADRESSEMAILREPONSEAUTO( )?=.*;/const ADRESSEMAILREPONSEAUTO = '$NO_REPLY_MAIL';/g" $FRAMADATE_CONFIG
|
||||
# Database configuration
|
||||
sed -i -E "s/^(\/\/ )?const DB_USER( )?=.*;/const DB_USER = '$MYSQL_USER';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DB_PASSWORD( )?=.*;/const DB_PASSWORD = '$MYSQL_PASSWORD';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DB_DRIVER( )?=.*;/const DB_DRIVER = 'pdo_mysql';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DB_NAME( )?=.*;/const DB_NAME = '$MYSQL_DB';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DB_HOST( )?=.*;/const DB_HOST = '$MYSQL_HOST';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DB_PORT( )?=.*;/const DB_PORT = '$MYSQL_PORT';/g" $FRAMADATE_CONFIG
|
||||
# SMTP config
|
||||
if [ "$DISABLE_SMTP" = "true" ]; then
|
||||
sed -i -E "s/'use_smtp' => true,/'use_smtp' => false,/g" $FRAMADATE_CONFIG
|
||||
fi
|
||||
# Framadate internal config
|
||||
sed -i -E "s/^(\/\/ )?const TABLENAME_PREFIX( )?=.*;/const TABLENAME_PREFIX = 'fd_';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const MIGRATION_TABLE( )?=.*;/const MIGRATION_TABLE = 'framadate_migration';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const DEFAULT_LANGUAGE( )?=.*;/const DEFAULT_LANGUAGE = 'fr';/g" $FRAMADATE_CONFIG
|
||||
sed -i -E "s/^(\/\/ )?const URL_PROPRE( )?=.*;/const URL_PROPRE = true;/g" $FRAMADATE_CONFIG
|
||||
else
|
||||
echo "Using existing config file " $FRAMADATE_CONFIG
|
||||
fi
|
||||
|
||||
# Configure /admin basic auth
|
||||
if [ ! -f /var/www/framadate/admin/.htpasswd ]; then
|
||||
if [ "$ADMIN_USER" ] && [ "$ADMIN_PASSWORD" ]; then
|
||||
htpasswd -bc /var/www/framadate/admin/.htpasswd $ADMIN_USER $ADMIN_PASSWORD
|
||||
else
|
||||
echo "!!! You need to configure ADMIN_USER and ADMIN_PASSWORD environment variables !!!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ENV" = "dev" ]; then
|
||||
echo Installing PHP development dependencies
|
||||
composer install --no-interaction --no-progress
|
||||
else
|
||||
echo Installing PHP production dependencies
|
||||
composer install -o --no-interaction --no-progress --prefer-dist --no-dev
|
||||
composer dump-autoload --optimize --no-dev --classmap-authoritative
|
||||
fi
|
||||
|
||||
# Await MySQL Container being ready
|
||||
until /usr/bin/mysql --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASSWORD --silent --execute "SELECT 1;" $MYSQL_DB; do
|
||||
>&2 echo "MySQL is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Resuming setup"
|
||||
|
||||
echo "Setting up .htaccess"
|
||||
cp /var/www/framadate/htaccess.txt /var/www/framadate/.htaccess
|
||||
|
||||
# Run Database migrations
|
||||
echo "Running database migrations"
|
||||
php /var/www/framadate/bin/doctrine migrations:status --no-interaction -vvv
|
||||
php /var/www/framadate/bin/doctrine migrations:migrate --no-interaction -vvv
|
||||
|
||||
# Run apache server
|
||||
# chown -R www-data:www-data /var/www/framadate
|
||||
source /etc/apache2/envvars
|
||||
exec apache2 -D FOREGROUND
|
11
docker/stretch/php.ini
Normal file
11
docker/stretch/php.ini
Normal file
@ -0,0 +1,11 @@
|
||||
apc.enable_cli = 1
|
||||
date.timezone = UTC
|
||||
session.auto_start = Off
|
||||
short_open_tag = Off
|
||||
|
||||
# http://symfony.com/doc/current/performance.html
|
||||
opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 20000
|
||||
opcache.memory_consumption = 256
|
||||
realpath_cache_size = 4096K
|
||||
realpath_cache_ttl = 600
|
Loading…
Reference in New Issue
Block a user