Commit 0f6c9f74 authored by sreg's avatar sreg

- Mise en place d'une architecture docker de développement

parent 93cc9d6b
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
# Change these settings to your own preference
indent_style = tab
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
[*.{yaml,yml,py}]
indent_style = space
indent_size = 2
www/cache
!www/cache/.gitkeep
www/logs
#Installation de docker sur Debian / Ubuntu
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER
#Installation de docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
#Execution du docker labonneformation: écoute dur le port 8080 => http://localhost:8080
docker-compose up -d --build
#Attention cette installation n'est pas adaptée à un environnement de production
version: "3"
services:
web:
hostname: web
restart: always
build:
context: .
dockerfile: dockerfile_web
ports:
- "8080:80"
database:
hostname: database
restart: always
build:
context: .
dockerfile: dockerfile_database
volumes:
- "labonneformation:/var/lib/database"
volumes:
labonneformation:
FROM ubuntu:trusty
VOLUME labonneformation
RUN mkdir -p /var/lib/database/mysql /var/lib/database/sphinx; \
ln -sfn /var/lib/database/sphinx /home/sphinx; \
ln -sfn /var/lib/database/mysql /var/lib/mysql;
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update && \
apt-get -y install mariadb-server && \
apt-get -y install sphinxsearch && \
apt-get -y install wget bzip2
RUN wget http://sphinxsearch.com/files/sphinxsearch_2.2.10-release-0ubuntu12~trusty_amd64.deb && \
dpkg -i --force-all sphinxsearch_2.2.10-release-0ubuntu12~trusty_amd64.deb && \
apt-get -y -f install
RUN sed -i 's/=no/=yes/' /etc/default/sphinxsearch; \
mkdir -p /home/sphinx/log /home/sphinx/indexes/lbf; \
chown -R sphinxsearch: /home/sphinx /home/sphinx/*; \
echo "[mysqld]\nbind-address = 0.0.0.0" >/etc/mysql/conf.d/55-server.cnf;
ARG SCHEMA=labonneformation
RUN echo "service mysql start" >>/tmp/init.sh; \
echo "if [ ! -d /var/lib/mysql/${SCHEMA} ]; then" >>/tmp/init.sh; \
echo "mysql -e \"CREATE USER 'root'@'%' IDENTIFIED BY ''\";" >>/tmp/init.sh; \
echo "mysql -e \"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'\";" >>/tmp/init.sh; \
echo "mysql -e \"FLUSH PRIVILEGES\";" >>/tmp/init.sh; \
echo "mysql -e \"INSTALL SONAME 'ha_sphinx';\";" >>/tmp/init.sh; \
echo "mysql -e \"CREATE DATABASE ${SCHEMA}\";" >>/tmp/init.sh; \
echo "bzip2 -dcq /home/lbf_database.sql.bz2 | mysql -uroot ${SCHEMA}" >>/tmp/init.sh; \
echo "indexer --all --rotate" >>/tmp/init.sh; \
echo "fi" >>/tmp/init.sh; \
echo "service sphinxsearch start >>/var/log/sphinx.log" >>/tmp/init.sh;
COPY ./web/home/www/labonneformation/config/sphinx.conf /etc/sphinxsearch/
COPY ./database/home/database/lbf_database.sql.bz2 /home/
CMD bash /tmp/init.sh; \
sleep infinity;
FROM ubuntu:bionic
ARG PHP_VER=7.2
RUN apt-get update && \
apt-get -y install php${PHP_VER}-gd php${PHP_VER}-cli php${PHP_VER}-mysql php${PHP_VER}-mysqli \
php${PHP_VER}-mbstring php${PHP_VER}-bz2 php${PHP_VER}-xml php${PHP_VER}-tidy php${PHP_VER}-curl && \
apt-get -y install mariadb-client
RUN mkdir -p /home/www;
COPY ./web/home/www /home/www
CMD cd /home/www/labonneformation; \
php -S 0.0.0.0:80 batch/quarky.php
<?php <?php
$path=pathinfo(__FILE__)['dirname'].DIRECTORY_SEPARATOR; $path=pathinfo(__FILE__)['dirname'].DIRECTORY_SEPARATOR;
if(file_exists($path.'config.dev.php'))
require_once($path.'config.dev.php');
$protocol=(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']!=='off' || (array_key_exists('SERVER_PORT',$_SERVER) && $_SERVER['SERVER_PORT']==443))?'https':'http'; $protocol=(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']!=='off' || (array_key_exists('SERVER_PORT',$_SERVER) && $_SERVER['SERVER_PORT']==443))?'https':'http';
if(!defined('DOMAIN')) define('DOMAIN',array_key_exists('HTTP_HOST',$_S